Http://www.cnblogs.com/zhjh256/p/6346501.html tells the basic map operation, when testing, found that the performance of the map is very low, compared with Java is nearly 200 times times. The logic of the test is as follows:
//Map Definitionmap<int, firstcppcls*>mapstudent; for(i=0;i<10000; i++) {firstcppcls clz; Clz.setappversion ("12.32.33"); Clz.setclustername ("Osm-service"); Clz.setcompanyid ("239383"); Clz.setserviceid ("sysl.1.223"); Clz.setsubsystemid (" at"); Clz.setsystemid (" +"); Mapstudent.insert (Pair<int, Firstcppcls*> (i, &clz)); } //get time-relative counter, VC-specificBegin =GetTickCount (); for(j=0;j< -; j + +) { for(f=0;f<10000; f++) { //Map LookupMapstudent.find (f); }} End=GetTickCount (); //Print Time Differencecout <<"Map Lookup time consuming:"<< (End-begin) << Endl;//about 4 seconds on average .System"Pause");
In Java the same implementation, get 100 0000 times only took 20ms. So search C + + map performance, see the two posts are as follows:
http://blog.csdn.net/a418382926/article/details/22302907
Http://blog.sina.com.cn/s/blog_5f93da790101hxxi.html
Http://www.ideawu.net/blog/archives/751.html
Subsequently, the HASH_MAP and unordered_map tests are performed, as follows:
//hash_map Definitionhash_map<int, firstcppcls*>hash_mapstudent; for(i=0;i<10000; i++) {firstcppcls clz; Clz.setappversion ("12.32.33"); Clz.setclustername ("Osm-service"); Clz.setcompanyid ("239383"); Clz.setserviceid ("sysl.1.223"); Clz.setsubsystemid (" at"); Clz.setsystemid (" +"); Hash_mapstudent.insert (Pair<int, Firstcppcls*> (i, &clz)); } //get time-relative counter, VC-specificBegin =GetTickCount (); for(j=0;j< -; j + +) { for(f=0;f<10000; f++) { //Map LookupHash_mapstudent.find (f); }} End=GetTickCount (); //Print Time Differencecout <<"HashMap Find time:"<< (End-begin) << Endl;//about 4 seconds on average .System"Pause"); //hash_map Definitionunordered_map<int, firstcppcls*>unordered_mapstudent; for(i=0;i<10000; i++) {firstcppcls clz; Clz.setappversion ("12.32.33"); Clz.setclustername ("Osm-service"); Clz.setcompanyid ("239383"); Clz.setserviceid ("sysl.1.223"); Clz.setsubsystemid (" at"); Clz.setsystemid (" +"); Unordered_mapstudent.insert (Pair<int, Firstcppcls*> (i, &clz)); } //get time-relative counter, VC-specificBegin =GetTickCount (); for(j=0;j< -; j + +) { for(f=0;f<10000; f++) { //Map LookupUnordered_mapstudent.find (f); }} End=GetTickCount (); //Print Time Differencecout <<"Unorderedmap Find time:"<< (End-begin) << Endl;//about 4 seconds on average .System"Pause");
The output is as follows:
HashMap Find time: 1610 Please press any key to continue ... Unorderedmap Find time: 1797 please press any key to continue ...
Although, compared to Std::map, did raise more than 50%, but with Java, or slow mess, because the STL has not been studied, not sure what the specific cause.
Performance comparison of map implementations for C + + performance