From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,ef7281a41a574423,start X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news2.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!goblin1!goblin3!goblin.stu.neva.ru!news.tu-darmstadt.de!news.belwue.de!newsfeed.arcor.de!newsspool4.arcor-online.net!news.arcor.de.POSTED!not-for-mail From: "Dmitry A. Kazakov" Subject: Task execution time test Newsgroups: comp.lang.ada User-Agent: 40tude_Dialog/2.0.15.1 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Reply-To: mailbox@dmitry-kazakov.de Organization: cbb software GmbH Date: Sun, 26 Dec 2010 11:25:21 +0100 Message-ID: NNTP-Posting-Date: 26 Dec 2010 11:25:20 CET NNTP-Posting-Host: 0016a0b3.newsspool2.arcor-online.net X-Trace: DXC=ggm=3T[E4_6QbA1[CgMQ00A9EHlD;3Yc24Fo<]lROoR18kF[HY5^EOVk Here is a small test for task execution time. Five worker tasks are used to generate background CPU load. When the measured task enters delay 0.1ms (on a system where delay is non-busy) it should lose the CPU prematurely. Under at least some Windows systems the test might fail because Windows performance counters are CPU quants 1ms or 10ms, depending on settings. Under VxWorks the test may fail because real-time clock there is driven by the timer interrupts, so it is impossible to have non-busy wait for 0.1ms. (I cannot say anything about Linux, because I never used it for RT applications, maybe other people could comment) ---------------------------------------------------- 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 is task type Measured; task body Measured is Count : Seconds_Count; Fraction : Time_Span; begin for I in 1..1_000 loop delay 0.000_1; end loop; Split (Ada.Execution_Time.Clock, Count, Fraction); Put_Line ( "Seconds" & Seconds_Count'Image (Count) & " Fraction" & Duration'Image (To_Duration (Fraction)) ); 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; -- This might be needed for some buggy versions of GNAT declare Workers : array (1..5) of Worker; Test : Measured; begin null; end; end Executuion_Time; ----------------------------------------------------- On my Windows XP SP3 the test yields 0-0. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de