Horde3D

Next-Generation Graphics Engine
It is currently 28.03.2024, 08:55

All times are UTC + 1 hour




Post new topic Reply to topic  [ 4 posts ] 
Author Message
PostPosted: 05.04.2009, 16:39 
Offline

Joined: 21.08.2008, 11:44
Posts: 354
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?


Last edited by Siavash on 05.04.2009, 19:48, edited 1 time in total.

Top
 Profile  
Reply with quote  
 Post subject: Re: Code Benchmarking
PostPosted: 05.04.2009, 17:45 
Offline
Tool Developer

Joined: 13.11.2007, 11:07
Posts: 1150
Location: Germany
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 )


Top
 Profile  
Reply with quote  
 Post subject: Re: Code Benchmarking
PostPosted: 05.04.2009, 17:50 
Offline
Engine Developer

Joined: 10.09.2006, 15:52
Posts: 1217
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).


Top
 Profile  
Reply with quote  
 Post subject: Re: Code Benchmarking
PostPosted: 05.04.2009, 19:47 
Offline

Joined: 21.08.2008, 11:44
Posts: 354
Thanks a lot to the beta3 8)


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group