Advertisement
Guest User

Untitled

a guest
Mar 11th, 2017
283
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.11 KB | None | 0 0
  1. #include <algorithm>
  2. #include <iostream>
  3. #include <windows.h>
  4.  
  5. using namespace std;
  6.  
  7. double PCFreq = 0.0;
  8. __int64 CounterStart = 0;
  9.  
  10. void StartCounter( )
  11. {
  12.     LARGE_INTEGER li;
  13.     if ( !QueryPerformanceFrequency( &li ) )
  14.         cout << "QueryPerformanceFrequency failed!\n";
  15.  
  16.     PCFreq = double( li.QuadPart ) / 1000.0;
  17.  
  18.     QueryPerformanceCounter( &li );
  19.     CounterStart = li.QuadPart;
  20. }
  21. double GetCounter( )
  22. {
  23.     LARGE_INTEGER li;
  24.     QueryPerformanceCounter( &li );
  25.     return double( li.QuadPart - CounterStart ) / PCFreq;
  26. }
  27.  
  28. const int sizeofbigdata = 209715200;
  29.  
  30.  
  31. char * bigdata = new char[ sizeofbigdata ];
  32. char * bigdata2 = new char[ sizeofbigdata ];
  33.  
  34.  
  35. void check1( )
  36. {
  37.     memcpy( bigdata, bigdata2, sizeofbigdata );
  38. }
  39.  
  40. void check2( )
  41. {
  42.     copy( bigdata2, bigdata2 + sizeofbigdata, bigdata );
  43. }
  44.  
  45.  
  46. int main( )
  47. {
  48.     int i ;
  49.  
  50.     while ( true )
  51.     {
  52.         i = 100;
  53.  
  54.  
  55.         StartCounter( );
  56.         while ( i-- )
  57.         {
  58.             check1( );
  59.         }
  60.         cout << GetCounter( ) << "\n";
  61.  
  62.  
  63.         i = 100;
  64.         StartCounter( );
  65.         while ( i-- )
  66.         {
  67.             check2( );
  68.         }
  69.         cout << GetCounter( ) << "\n";
  70.  
  71.         system( "pause" );
  72.     }
  73.     return 0;
  74. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement