Re: Time measurement using RDTSC instruction

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



jslim <gomting00@xxxxxxxxx> wrote:

I implemented my own device driver which generates software interrupt
( INT n).
And I want to measure the execution time of my interrupt service
routine.
The execution time is too small to measure using nornal time function.

No, it's not, at least in this case.

What I tried to do is "RDTSC" as follows

void myISR()
{
__asm{
RDTSC
MOV first_lowvalue, EAX
MOV first_highvalue, EDX
}

// Some code of my ISR

__asm{
RDTSC
MOV second_lowvalue, EAX
MOV second_highvalue, EDX
}
}

There are intrinsics for this.

__int64 first = __rdtsc();
// code
__int64 second = __rdtsc();
__int64 delta = second - first;

After doing this, I could get some value of RDTSC
first : 16756678044338
second : 16756736846933
subtraction : 58802595

What is the meaning of "Subtraction : 58802595"?
Is that core clock cycle??
MSDN said that "RDTSC time stamp is the number of clock cycles since
the last reset"
Then how can I change this into time( unit of nano sec, micro sec or
milli sec )?

How can you possibly include assembler instructions in your driver when you
don't know what they do?

58 million cycles. On a typical 2 GHz processor, that's 29 milliseconds,
which is way, way, WAAAAY too long for an ISR. Your ISR should run in a
few microseconds -- thousands or tens of thousands of cycles, no more.
Time-consuming processing needs to be deferred to a DPC.
--
Tim Roberts, timr@xxxxxxxxx
Providenza & Boekelheide, Inc.
.



Relevant Pages

  • Time measurement using RDTSC instruction
    ... I implemented my own device driver which generates software interrupt ... The execution time is too small to measure using nornal time function. ... MOV first_highvalue, EDX ... I could get some value of RDTSC ...
    (microsoft.public.development.device.drivers)
  • Re: which way is faster?
    ... The code posted is nice but not useful in order to verify the numbers. ... beside that 'mov reg,imm' is faster than 'mov reg,' ... it helped a bit on RD-modify-WR cycles on old VGA-cards. ... that is 65_536_000 dots / sec. or 65 mega pixels. ...
    (alt.lang.asm)
  • Re: which way is faster?
    ... beside that 'mov reg,imm' is faster than 'mov reg,' ... Since I am allowed to rewrite the stack in that case, ... you can calculate the theoretical timing and compare it to the ... it helped a bit on RD-modify-WR cycles on old VGA-cards. ...
    (alt.lang.asm)
  • Re: Fastest logical not?
    ... temporary registers? ... cmp reg, 0; alternative: or reg,reg ... mov 00,0 ... jump takes 10 cycles and up, ...
    (comp.lang.asm.x86)
  • Re: Fastest logical not?
    ... RDTSC timing is machine specific (5...else cycles). ... MOV esi,result_buf;16 bytes needed yet here ... The second test-run follows immediate still with IRQs disabled. ...
    (comp.lang.asm.x86)