From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Task execution time 2
Date: Thu, 30 Dec 2010 09:54:36 +0100
Date: 2010-12-30T09:54:34+01:00 [thread overview]
Message-ID: <dp9nbzsz7tpq$.1qojc7io83gkd$.dlg@40tude.net> (raw)
Here is a better test for the thing. It measures the execution time using
real-time clock and Windows services. The idea is to give up the processor
after 0.5ms, before the system time quant expires.
The test must run considerably long time. Because the task Measured should
lose the processor each 0.5ms and return back after other tasks would take
their share. If the test completes shortly, that possibly mean something
wrong. Increase the number of worker task.
----------------------------------------------------------------
with Ada.Execution_Time; use Ada.Execution_Time;
with Ada.Real_Time; use Ada.Real_Time;
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Numerics.Elementary_Functions;
procedure Executuion_Time_1 is
task type Measured;
task body Measured is
Count : Seconds_Count;
Fraction : Time_Span;
Estimated : Time_Span := Time_Span_Zero;
Start : Time;
begin
for I in 1..1_000 loop
Start := Clock;
while To_Duration (Clock - Start) < 0.000_5 loop
null;
end loop;
Estimated := Estimated + Clock - Start;
delay 0.0;
end loop;
Split (Ada.Execution_Time.Clock, Count, Fraction);
Put_Line
( "Measured: seconds" & Seconds_Count'Image (Count) &
" Fraction " & Duration'Image (To_Duration (Fraction))
);
Put_Line
( "Estimated:" & Duration'Image (To_Duration (Estimated))
);
end Measured;
task type Worker; -- Used to generate CPU load
task body Worker is
use Ada.Numerics.Elementary_Functions;
X : Float;
begin
for I in Positive'Range loop
X := sin (Float (I));
end loop;
end Worker;
begin
delay 0.1;
declare
Workers : array (1..5) of Worker;
Test : Measured;
begin
null;
end;
end Executuion_Time_1;
-----------------------------------------------------------
Windows XP SP3
Measured: seconds 0 Fraction 0.000000000
Estimated: 0.690618774
--
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de
reply other threads:[~2010-12-30 8:54 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox