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=-1.2 required=5.0 tests=BAYES_00,FROM_LOCAL_HEX, FROM_STARTS_WITH_NUMS autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,cae92f92d6a1d4b1 X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news3.google.com!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: "Vinzent Hoefler" <0439279208b62c95f1880bf0f8776eeb@t-domaingrabbing.de> Newsgroups: comp.lang.ada Subject: Re: Ada.Execution_Time Date: Sun, 19 Dec 2010 05:01:22 +0100 Message-ID: References: <4d05e737$0$6980$9b4e6d93@newsspool4.arcor-online.net> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit X-Trace: individual.net m9NRVVK4I6zaluW399qGnArx5a1SF+JgeMZJRoRjkACyzJMawt Cancel-Lock: sha1:EiyU+nXEjAgsYxy+42ltxcmtO10= User-Agent: Opera Mail/10.63 (Win32) Xref: g2news2.google.com comp.lang.ada:17008 Date: 2010-12-19T05:01:22+01:00 List-Id: BrianG wrote: > If you mean that they both define a Clock and a Split, maybe. If you mean > any program that actually does anything, that's not possible. That was my > original comment: Execution_Time does not provide any types/operations > useful, without also 'with'ing Real_Time. Yes, but so what? The intention of Ada.Execution_Time wasn't to provide the user with means to instrument the software and to Text_IO some mostly meaningless values (any decent profiler can do that for you), but rather a way to implement user-defined schedulers based on actual CPU usage. You may want to take a look at the child packages Timers and Group_Budget to see the intended usage. And well, if you're ranting about CPU_Time, Real_Time.Time_Span is not much better. It's a pain in the ass to convert an Ada.Real.Time_Span to another type to interface with OS-specific time types (like time_t) if you're opting for speed, portability and accuracy. BTW, has anyone any better ideas to convert TimeSpan into a record containing seconds and nanoseconds than this: function To_Interval (TS : in Ada.Real_Time.Time_Span) return ASAAC_Types.TimeInterval is Nanos_Per_Sec : constant := 1_000_000_000.0; One_Second : constant Ada.Real_Time.Time_Span := Ada.Real_Time.Milliseconds (1000); Max_Interval : constant Ada.Real_Time.Time_Span := Integer (ASAAC_Types.Second'Last) * One_Second; Seconds : ASAAC_Types.Second; Nano_Seconds : ASAAC_Types.Nanosec; begin declare Sub_Seconds : Ada.Real_Time.Time_Span; begin if TS >= Max_Interval then Seconds := ASAAC_Types.Second'Last; Nano_Seconds := ASAAC_Types.Nanosec'Last; elsif TS < Ada.Real_Time.Time_Span_Zero then Seconds := ASAAC_Types.Second'First; Nano_Seconds := ASAAC_Types.Nanosec'First; else Seconds := ASAAC_Types.Second (TS / One_Second); Sub_Seconds := TS - (Integer (Seconds) * One_Second); Nano_Seconds := ASAAC_Types.Nanosec (Nanos_Per_Sec * Ada.Real_Time.To_Duration (Sub_Seconds)); end if; end; return ASAAC_Types.TimeInterval'(Sec => Seconds, NSec => Nano_Seconds); end To_Interval; The solution I came up with here generally works, but suffers some potential overflow problems and doesn't look very efficient to me (although that'a minor problem given the context it's usually used in). Vinzent. -- You know, we're sitting on four million pounds of fuel, one nuclear weapon, and a thing that has 270,000 moving parts built by the lowest bidder. Makes you feel good, doesn't it? -- Rockhound, "Armageddon"