[LLVMbugs] [Bug 14555] New: libc++'s hash_set is 44% slower than libstdc++'s

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Sun Dec 9 11:23:58 PST 2012


http://llvm.org/bugs/show_bug.cgi?id=14555

             Bug #: 14555
           Summary: libc++'s hash_set is 44% slower than libstdc++'s
           Product: libc++
           Version: unspecified
          Platform: PC
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: All Bugs
        AssignedTo: hhinnant at apple.com
        ReportedBy: nicolasweber at gmx.de
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified


This is like bug 14554 but for hash_set instead of map:

/*
   $ clang++ -o s151_hash sec151_stlunorderedmap.cpp -O2 -stdlib=libc++
   $ time ./s151_hash < ~/Downloads/bible11.txt > /dev/null 

   real    0m0.424s
   user    0m0.418s
   sys    0m0.005s

   $ clang++ -o s151_hash sec151_stlunorderedmap.cpp -O2
   $ time ./s151_hash < ~/Downloads/bible11.txt > /dev/null 

   real    0m0.294s
   user    0m0.288s
   sys    0m0.005s
 */
#include <iostream>
#include <string>

// hash_map instead of unordered_map to compare to gcc4.2
#pragma clang diagnostic ignored "-W#warnings"
#include <ext/hash_map>
using __gnu_cxx::hash_map;
using namespace std;

namespace __gnu_cxx {
template<>
struct hash<std::string> {
  size_t operator()(const std::string& s) const {
    return hash<const char*>()(s.c_str());
  }
};
}

int main(void)
{   hash_map<string, int> M;
    hash_map<string, int>::iterator j;
    string t;
    while (cin >> t)
        M[t]++;
    for (j = M.begin(); j != M.end(); ++j)
        cout << j->first << " " << j->second << "\n";
    return 0;
}

-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.



More information about the llvm-bugs mailing list