Tech Support > Microsoft Windows > Drivers > calculate CPU cycles
calculate CPU cycles
Posted by beginthreadex on September 20th, 2004


Is there an API that I can tap into from an NT Service that will allow me to
get an estimated CPU clock cycles it takes to do X code? I have to do
reports on performance and we normally do GetTickCount() but I need someone
closer to the CPU Cycle level.


Posted by Arkady Frenkel on September 20th, 2004


Look at http://www.sysinternals.com/ntw2k/info/timer.shtml
Arkady

"beginthreadex" <thomas_remkus@westwoodone.com> wrote in message
news:eco5KwxnEHA.536@TK2MSFTNGP11.phx.gbl...


Posted by Oette Scibulski on September 20th, 2004


beginthreadex wrote:

with rtdsc machine commands.
__declspec( naked ) __int64 RDTSC( )
{
_asm _emit 0x0f
_asm _emit 0x31

_asm ret
}
_64StartTime = RDTSC( );
VeryShortCodeSnippet
_64StopTime = RDTSC( ) - _64StartTime;

Good luck!






Posted by Stephan Wolf [MVP] on September 20th, 2004


I'd suggest the same site, but a different article See

"Performance Instrumenting Device Drivers"
http://www.sysinternals.com/ntw2k/info/sysperf.shtml

[How could we all live if there were no SysInternals...]

Stephan
---
On Mon, 20 Sep 2004 19:07:53 +0300, "Arkady Frenkel"
<arkadyf@hotmailxdotx.com> wrote:

Posted by Tim Roberts on September 22nd, 2004


oette.scibulski@ausmschacht.de (Oette Scibulski) wrote:
Visual C++ 6.0 and beyond support the rdtsc instruction. Much easier to
read:

__declspe(naked) __int64 RDTSC()
{
_asm rdtsc
_asm ret
}
--
- Tim Roberts, timr@probo.com
Providenza & Boekelheide, Inc


Similar Posts