Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Timer function in C++

Name: Ekce 2006-02-03 23:19

alright, so I got my program written out in c++, but I want to know how long it takes to run. So I'm wondering if anyone knows anysort of timer functions? I need the most time effecient one, granted it would only run once (or twice depending on the function), but there is still an emphasis on time. as for operating system I am using Yoper linux, I don't know if it matters, but I've heard it does.

Name: FrozenVoid 2011-10-08 5:39

>>13
In asm there is RDTSC which accurate to a single CPU cycle,and more portable, does not require any "OS interface".

static __inline__ unsigned long long rdtsc(void){
  unsigned long long int x;
     __asm__ volatile (".byte 0x0f, 0x31" : "=A" (x));
     return x;}
#define RDTSC_DELAY 0// RDTSC opcode latency in cycles for this CPU
a=rdtsc();
some code;
b=rstsc();printf("%llu",b-a-RDTSC_DELAY);

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List