-
February 20th, 2005, 08:50 AM
#1
high performance counter?
i need a high performance counter for my programm
i wanted it to be crossplattform ... but thats the problem ...
so can somebody give me good counters for windows and linux
(plz several .. for choice .. or with pro and contra ...)
i know QueryPerformanceCounter for windows ... but thats it =)
would be nice if u post the frequency of the counter ... (and how to get it in code)
Last edited by hydro; February 20th, 2005 at 08:56 AM.
-
February 20th, 2005, 09:20 AM
#2
Re: high performance counter?
B+!
'There is no cat' - A. Einstein
Use [code] [/code] tags!
Did YOU share your photo with us at CG Members photo gallery ?
-
February 20th, 2005, 09:45 AM
#3
Re: high performance counter?
Well...there is basically no portable way since it depends on the underlying API...
-
February 21st, 2005, 03:01 PM
#4
Re: high performance counter?
hydro,
Indeed it is platform dependent. The following example might be useful for IA32 x86 with MSVC and GCC.
The example has some related stuff from the class, but it's pretty clear how to deal with the assembly dialects alone.
Good luck, Chris.
Code:
const ef_UINT64 e_float_cpu_ia32::tick(void) const
{
if(!supported())
{
return 0;
}
else
{
volatile ef_UINT32 lo = 0;
volatile ef_UINT32 hi = 0;
#if defined(USE_INTEL_x86_SYSTEM)
#if defined(_MSC_VER)
__asm
{
xor eax, eax
cpuid
rdtsc
mov dword ptr lo, eax
mov dword ptr hi, edx
}
#elif defined(__GNUC__)
asm volatile("xorl %%eax, %%eax\n"
"cpuid\n"
"rdtsc\n"
"movl %%eax, %0\n"
"movl %%edx, %1" : "=g" (lo), "=g" (hi) : : "eax", "edx");
#endif
#endif
return (static_cast<ef_UINT64>(hi) << 32) | lo;
}
}
You're gonna go blind staring into that box all day.
-
February 21st, 2005, 03:02 PM
#5
Re: high performance counter?
... it's basically some of the stuff from the FAQ but augmented for GCC as well.
Chris.
You're gonna go blind staring into that box all day.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|