From: "Pat Rogers" <progers@classwide.com>
Subject: Re: CPU time for Win32 & GNAT
Date: Fri, 12 Oct 2001 13:50:12 GMT
Date: 2001-10-12T13:50:12+00:00 [thread overview]
Message-ID: <oyCx7.10592$Lz2.3580572774@newssvr30.news.prodigy.com> (raw)
In-Reply-To: 17cd177c.0110120321.3077bccf@posting.google.com
"Gautier" <gautier_niouzes@hotmail.com> wrote in message
news:17cd177c.0110120321.3077bccf@posting.google.com...
> Hi!
>
> Does someone know how to obtain the CPU time (or a CPU
> duration...) for Win32 (under GNAT) in a simple way ?
> The program doesn't use tasking and no more resolution
> than the one of Duration is needed for time spans.
> I'm sure someone has a ready-made function in his/her toolbox...
Better yet, why not use the Pentium ReadTimeStampCounter (RDTSC)
instruction? It samples the register that keeps a count of the number of
clock cycles since boot-up. Given the exact clock speed you can compute
exactly how much time has elapsed between two samples.
with Interfaces;
package Pentium_Cycle_Counter is
pragma Suppress( All_Checks );
type Count is new Interfaces.Unsigned_64;
function Sample return Count;
pragma Inline( Sample );
end Pentium_Cycle_Counter;
with Machine_Code;
package body Pentium_Cycle_Counter is
use Machine_Code;
function Sample return Count is
Result : Count;
begin
Asm( "RDTSC", Count'Asm_Output("=A",Result), Volatile => True );
return Result;
end Sample;
end Pentium_Cycle_Counter;
---
Patrick Rogers Consulting and Training in:
http://www.classwide.com Real-Time/OO Languages
progers@classwide.com Hard Deadline Schedulability Analysis
(281)648-3165 Software Fault Tolerance
next prev parent reply other threads:[~2001-10-12 13:50 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-10-12 11:21 CPU time for Win32 & GNAT Gautier
2001-10-12 13:50 ` Pat Rogers [this message]
2001-10-12 14:43 ` Ted Dennison
2001-10-12 14:48 ` Pat Rogers
2001-10-12 17:17 ` Ted Dennison
2001-10-12 14:36 ` Ted Dennison
2001-10-12 18:30 ` Sune Falck
-- strict thread matches above, loose matches on Subject: below --
2001-10-14 19:54 Gautier Write-only-address
2001-10-15 14:33 ` Ted Dennison
2001-10-15 9:47 Gautier Write-only-address
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox