g***@hotmail.com
2011-10-20 17:56:47 UTC
Hello all
we use here Visual Studio 2010 and notice quite an impressive
performance difference between the boost and std unordered_map: about
a factor 10 in favor of the boost implementation. Is there something
specified in the std which makes them slower?
boost::unordered_map 0.574148
stl::unordered_map 5.758360
stl::map 17.927353
Test code is quite simple (it uses a value of std::pair<int,
std::string>):
int g_n = 0;
void f()
{
std::map<int, std::string> mapStl;
std::unordered_map<int, std::string> umapStl;
boost::unordered_map<int, std::string> umapBoost;
const int nMaxSize = 500000;
const int nMaxFind = 100000000;
//create maps with 500000 elements
//find
{
DBG_PRF_PROFILE_FUNCTION_TEXT("_stl_map_find");
for (int n = 0; n < nMaxFind; ++n)
{
g_n += mapStl.count(n % nMaxSize);
}
}
etc...
}
we use here Visual Studio 2010 and notice quite an impressive
performance difference between the boost and std unordered_map: about
a factor 10 in favor of the boost implementation. Is there something
specified in the std which makes them slower?
boost::unordered_map 0.574148
stl::unordered_map 5.758360
stl::map 17.927353
Test code is quite simple (it uses a value of std::pair<int,
std::string>):
int g_n = 0;
void f()
{
std::map<int, std::string> mapStl;
std::unordered_map<int, std::string> umapStl;
boost::unordered_map<int, std::string> umapBoost;
const int nMaxSize = 500000;
const int nMaxFind = 100000000;
//create maps with 500000 elements
//find
{
DBG_PRF_PROFILE_FUNCTION_TEXT("_stl_map_find");
for (int n = 0; n < nMaxFind; ++n)
{
g_n += mapStl.count(n % nMaxSize);
}
}
etc...
}
--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]