VBcoders Browse New Submit Contact Sign In

No account? Register free

Forgot password?

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

Paul Caton  (14 Submissions)   Miscellaneous   Visual Basic 5.0   Intermediate   Wed 3rd February 2021

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) (16(16 Vote))

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

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

No comments yet — be the first to post one!

Post a Comment

0/1000 characters