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.

Re: calculate CPU cycles by Arkady

Arkady
Mon Sep 20 11:07:53 CDT 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...
> 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.
>
>



Re: calculate CPU cycles by oette

oette
Mon Sep 20 15:36:26 CDT 2004

beginthreadex wrote:

> 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.
Although an API might exist you can surround your short code snippets(!)
with rtdsc machine commands.
__declspec( naked ) __int64 RDTSC( )
{
_asm _emit 0x0f
_asm _emit 0x31

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

Good luck!






Re: calculate CPU cycles by Stephan

Stephan
Mon Sep 20 15:58:50 CDT 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:

>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...
>> 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.

Re: calculate CPU cycles by Tim

Tim
Wed Sep 22 01:04:00 CDT 2004

oette.scibulski@ausmschacht.de (Oette Scibulski) wrote:
>
>Although an API might exist you can surround your short code snippets(!)
>with rtdsc machine commands.
>__declspec( naked ) __int64 RDTSC( )
>{
> _asm _emit 0x0f
> _asm _emit 0x31
>
> _asm ret
>}

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