Is gcc std::unordered_map implementation slow? If so - why?

后端 未结 3 1057
旧时难觅i
旧时难觅i 2020-12-02 08:31

We are developing a highly performance critical software in C++. There we need a concurrent hash map and implemented one. So we wrote a benchmark to figure out, how much slo

3条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-02 09:26

    I have run your code using a 64 bit / AMD / 4 cores (2.1GHz) computer and it gave me the following results:

    MinGW-W64 4.9.2:

    Using std::unordered_map:

    inserts: 9280 
    get: 3302
    

    Using std::map:

    inserts: 23946
    get: 24824
    

    VC 2015 with all the optimization flags I know:

    Using std::unordered_map:

    inserts: 7289
    get: 1908
    

    Using std::map:

    inserts: 19222 
    get: 19711
    

    I have not tested the code using GCC but I think it may be comparable to the performance of VC, so if that is true, then GCC 4.9 std::unordered_map it's still broken.

    [EDIT]

    So yes, as someone said in the comments, there is no reason to think that the performance of GCC 4.9.x would be comparable to VC performance. When I have the change I will be testing the code on GCC.

    My answer is just to establish some kind of knowledge base to other answers.

提交回复
热议问题