Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <algorithm>
- #include <iostream>
- #include <windows.h>
- using namespace std;
- double PCFreq = 0.0;
- __int64 CounterStart = 0;
- void StartCounter( )
- {
- LARGE_INTEGER li;
- if ( !QueryPerformanceFrequency( &li ) )
- cout << "QueryPerformanceFrequency failed!\n";
- PCFreq = double( li.QuadPart ) / 1000.0;
- QueryPerformanceCounter( &li );
- CounterStart = li.QuadPart;
- }
- double GetCounter( )
- {
- LARGE_INTEGER li;
- QueryPerformanceCounter( &li );
- return double( li.QuadPart - CounterStart ) / PCFreq;
- }
- const int sizeofbigdata = 209715200;
- char * bigdata = new char[ sizeofbigdata ];
- char * bigdata2 = new char[ sizeofbigdata ];
- void check1( )
- {
- memcpy( bigdata, bigdata2, sizeofbigdata );
- }
- void check2( )
- {
- copy( bigdata2, bigdata2 + sizeofbigdata, bigdata );
- }
- int main( )
- {
- int i ;
- while ( true )
- {
- i = 100;
- StartCounter( );
- while ( i-- )
- {
- check1( );
- }
- cout << GetCounter( ) << "\n";
- i = 100;
- StartCounter( );
- while ( i-- )
- {
- check2( );
- }
- cout << GetCounter( ) << "\n";
- system( "pause" );
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement