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.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,cae92f92d6a1d4b1,start X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news4.google.com!feeder.news-service.com!85.214.198.2.MISMATCH!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail From: BrianG Newsgroups: comp.lang.ada Subject: Ada.Execution_Time Date: Sat, 11 Dec 2010 23:19:50 -0500 Organization: A noiseless patient Spider Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Sun, 12 Dec 2010 04:19:54 +0000 (UTC) Injection-Info: mx03.eternal-september.org; posting-host="BssHc7ONlcOOcC5Vapr56Q"; logging-data="13314"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+zxyKsmni0JlUwXt9sYiFD" User-Agent: Thunderbird 2.0.0.24 (X11/20100623) Cancel-Lock: sha1:0UdrwwsFBc7rLRfNh6AKLR95bhs= Xref: g2news1.google.com comp.lang.ada:15900 Date: 2010-12-11T23:19:50-05:00 List-Id: Has anyone actually used Ada.Execution_Time? How is it supposed to be used? I tried to use it for two (what I thought would be) simple uses: display the execution time of one task and sum the of execution time of a group of related tasks. In both cases, I don't see anything in that package (or in Ada.Real_Time, which appears to be needed to use it) that provides any straightforward way to use the value reported. For display, you can't use CPU_Time directly, since it's private. You can Split it, but you get a Time_Span, which is also private. So the best you can do is Split it, and then convert the parts to a type that can be used (like duration). For summing, there is "+", but only between CPU_Time and Time_Span, so you can't add two CPU_Times. Perhaps you can use Split, sum the seconds, and then use "+" to add the fractions to the next Clock (before repeating Split/add/"+" with it, then you need to figure out what to do with the last fractional second), but that seems an odd intended use. The best I could come up with was to create my own function, like this (using the same definition for T as in Clock), which can be used for both: function Task_CPU_Time return Duration (T : ...) is Sec : Ada.Execution_Time.Seconds_Count; Fraction : Ada.Real_Time.Time_Span; begin Ada.Execution_Time.Split(Ada.Execution_Time.Clock(T), Sec, Fraction); return To_Duration(Ada.Real_Time.Seconds(Integer(Sec))) + To_Duration(Fraction); end Task_CPU_Time; Wouldn't it make sense to put something like this into that package? Then, at least, there'd be something that's directly available to use - and you wouldn't need another package. (I'm not sure about the definitions of CPU_Time and Duration, and whether the conversions would be guaranteed to work.) --BrianG