Skip to content

Latest commit

 

History

15 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 

Repository files navigation

swisstable

Implement the UnorderedMap and UnorderedSet containers based on Swisstable, has the same interface as STL(support mostly), and is 2 to 1000 times faster than STL.

The implementation is more concise than the official one, and you can directly include the header file to use.

compile

g++ -O2 -std=c++17 ./perf_test.cpp -o perf_test

performance test

x86_64
- cpu: 16 Intel(R) Xeon(R) Gold 6161 CPU @ 2.20GHz
- memory: 64G
ARM
- cpu: Neoverse N2
- memory: 32G
insert x86 insert arm insert
find x86 find arm find
erase x86 erase arm erase
clear x86 clear arm clear
iterate x86 iterate arm iterate

usage

#include "swisstable.h"
int main() {
    UnorderedMap<int, int> m;

    for (size_t i = 0; i < 100; ++i) {
        m.try_empace(i, i);
    }

    for (size_t i = 0; i < 100; ++i) {
        m.find(i);
    }

    size_t sum = 0;
    auto cal_sum = [&sum](HashPair<int, int> &pair) {
        sum += pair.second;
    };
    map.ctraverse(map.cbegin(), map.cend(), cal_sum);

    for (size_t i = 0; i < 100; ++i) {
        m.erase(i);
    }
}

About

C++11 implementation of Google's SwissTable in a single header file. Provides UnorderedMap and UnorderedSet containers with performance surpassing std::unordered_map/set.

Resources

Stars

20 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages