Horde3D
http://horde3d.org/forums/

Code Benchmarking [SOLVED]
http://horde3d.org/forums/viewtopic.php?f=5&t=694
Page 1 of 1

Author:  Siavash [ 05.04.2009, 16:39 ]
Post subject:  Code Benchmarking [SOLVED]

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?

Author:  Volker [ 05.04.2009, 17:45 ]
Post subject:  Re: Code Benchmarking

Not sure if it does relate to your problem, but as far as I know using __rdtsc for benchmarking is not the best idea ( see also http://msdn.microsoft.com/en-us/library/bb173458.aspx )

Author:  marciano [ 05.04.2009, 17:50 ]
Post subject:  Re: Code Benchmarking

Volker is right, the rdtsc instruction is not safe any more, since processors can dynamically adapt the clockrate and since threads can run on different cores (each core has its own time stamp counter).

http://en.wikipedia.org/wiki/Time_Stamp_Counter

The good news is that we have timing functionality in Horde since Beta3. You can use the Timer class implemented in utTimer.h for benchmarking and the EngineStat CustomTime, so your results are shown in the infobox (press F9 two times in the samples).

Author:  Siavash [ 05.04.2009, 19:47 ]
Post subject:  Re: Code Benchmarking

Thanks a lot to the beta3 8)

Page 1 of 1 All times are UTC + 1 hour
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/