VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Read the cpu clock cycle count for sub-microsecond timing. VB+ASM (Updated 07/05)

by Paul Caton (14 Submissions)
Category: Miscellaneous
Compatability: Visual Basic 5.0
Difficulty: Intermediate
Date Added: Wed 3rd February 2021
Rating: (16 Votes)

Pentium class cpu's include a 64 bit register that increments from power-on at the CPU clock frequency. With a 2GHz processor, you have in effect, a 2GHz clock. The cCpuClk class allows the user to retrieve the 64 bit CPU clock cycle count into a passed currency parameter. The class can be used as a basis for sub-microsecond benchmarking and delay timing. Note that with the extreme resolution provided, multitasking and the state of the cpu caches will show in the results. Thanks to David Fritts and Robert Rayment for the vtable trick.
Update 7/1/2003 - I said... at this resolution cache FX come into play. In determining the call overhead, I should have born that in mind. Just goes to show you have to be extra, extra careful with benchmarks.
Update 7/5/2003 - I got asked to do an article for a benchmark site based on this submission so I thought I'd put a little more effort into the data displayed. See new screenshot.

Rate Read the cpu clock cycle count for sub-microsecond timing. VB+ASM (Updated 07/05)

Download Read the cpu clock cycle count for sub-microsecond timing. VB+ASM (Updated 07/05)

Download Read the cpu clock cycle count for sub-microsecond timing. VB+ASM (Updated 07/05) (6 KB)

Read the cpu clock cycle count for sub-microsecond timing. VB+ASM (Updated 07/05) Comments

No comments have been posted about Read the cpu clock cycle count for sub-microsecond timing. VB+ASM (Updated 07/05). Why not be the first to post a comment about Read the cpu clock cycle count for sub-microsecond timing. VB+ASM (Updated 07/05).

Post your comment

Subject:
Message:
0/1000 characters