direct3d9 - How to convert ticks to clock cycles when profiling API calls -


i profiling direct3d9 api calls. have read lot of documentation here describes process. have question though calculating elapsed clock cycles. here current method:

// measurement vars large_integer start, stop, freq;  // // flush command buffer here //  //  // issue begin query here //  // start timer queryperformancecounter(&start);  // //draw //  // // issue end query here , wait on results //  // stop timer queryperformancecounter(&stop);  // calc elapsed ticks stop.quadpart -= start.quadpart;  // frequency queryperformancefrequency(&freq);  // ticks easier handling ulong ticks = stop.quadpart;  // calc elapsed clock cycles cycles = (2.8e9 * ticks) / (double)freq.quadpart; 

my question concerns value 2.8e9 supposed represent speed of processor. correct way of calculating clock cycles? profiling single api calls , results differ found on above link. if set processor speed 1e9 numbers within range...i wanted check method...

the number of processor cycles (approximately) difference.

longlong cycles = stop.quadpart - start.quadpart; 

the correct way convert seconds is:

double seconds = (double)cycles / (double)freq.quadpart; 

queryperformancecounter used implemented wrapper around rdtsc doesn't work modern clock frequency stepping power-management. therefore, qpc other stable clock on system might not ' cpu processor cycles'.

if want true 'cpu processor cycles' should use __rdtsc() intrinsic directly, remember don't have robust way convert directly time--and on old amd athalon 64 machines have problems of not being sync'd between cores.

reserve use of ticksfor calls gettickccount64 (or deprecated gettickccount) returns "ticks in milliseconds".

see acquiring high-resolution time stamps.


Comments

Popular posts from this blog

javascript - AngularJS custom datepicker directive -

javascript - jQuery date picker - Disable dates after the selection from the first date picker -