Currently I'm benchmarking my codes
like this :
Code:
// MSDN CODE SAMPLE ///////////////////////////////////////
///////////////////////////////////////////////////////////
#include <intrin.h>
#include <iostream>
#pragma intrinsic(__rdtsc)
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
unsigned __int64 i;
i = __rdtsc();
// DOING SOME FUN HERE ////////////////////////////////
cout<<"TICK TIME : "<< __rdtsc() - i<<endl;
i = __rdtsc();
// DOING SOME FUN HERE ////////////////////////////////
cout<<"TICK TIME : "<< __rdtsc() - i<<endl;
i = __rdtsc();
// DOING SOME FUN HERE ////////////////////////////////
cout<<"TICK TIME : "<< __rdtsc() - i<<endl;
// START ANOTHER FUN //////////////////////////////////
i = __rdtsc();
// DOING ANOTHER FUN HERE /////////////////////////////
cout<<"TICK TIME : "<< __rdtsc() - i<<endl;
i = __rdtsc();
// DOING ANOTHER FUN HERE /////////////////////////////
cout<<"TICK TIME : "<< __rdtsc() - i<<endl;
i = __rdtsc();
// DOING ANOTHER FUN HERE /////////////////////////////
cout<<"TICK TIME : "<< __rdtsc() - i<<endl;
return 0;
}
But always
"ANOTHER FUN" [I mean the last functions] is faster [according to the tick time] no matter how much the first functions are faster [in code]. Any body knows whats the matter or better way for benchmarking?