Advertisement
Guest User

Untitled

a guest
Mar 11th, 2010
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.75 KB | None | 0 0
  1. #include <windows.h>
  2. #include <map>
  3. #include <string>
  4. #include <iostream>
  5.  
  6. std::map< std::string, int > Properties;
  7.  
  8. void Test( int NumberSearches )
  9. {
  10.     int Finds = 0;
  11.     DWORD Start = timeGetTime();
  12.         for( int i = 0; i < NumberSearches; ++i )
  13.         {
  14.             if( Properties.find( "Property" ) != Properties.end() )
  15.                 Finds++;
  16.         }
  17.     DWORD End = timeGetTime();
  18.    
  19.     std::cout << "Searches : " << NumberSearches << " Finds : " << Finds << " Search Time : " << (End - Start) << " ms\n\n";
  20. }
  21.  
  22. int main()
  23. {
  24.     for( int i = 0; i < 50; ++i )
  25.     {
  26.         char Buffer[80];
  27.         sprintf( Buffer, "Property_%d", i );
  28.         Properties[Buffer] = i;
  29.     }
  30.    
  31.     Test(100000);
  32.     Test(1000000);
  33.     Test(10000000);
  34.     Test(100000000);
  35.  
  36.     std::cout << "Done Test ... \n";
  37.  
  38.     std::cin.get();
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement