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.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,d1f23f0bd3971bec X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news1.google.com!newsread.com!news-xfer.newsread.com!news-feed01.roc.ny.frontiernet.net!nntp.frontiernet.net!newscon06.news.prodigy.com!prodigy.net!border1.nntp.dca.giganews.com!nntp.giganews.com!local01.nntp.dca.giganews.com!nntp.comcast.com!news.comcast.com.POSTED!not-for-mail NNTP-Posting-Date: Thu, 21 Apr 2005 13:00:03 -0500 From: tmoran@acm.org Newsgroups: comp.lang.ada Subject: Re: Timing Block of GNAT code in milliseconds References: <1114090119.383842.20950@l41g2000cwc.googlegroups.com> X-Newsreader: Tom's custom newsreader Message-ID: Date: Thu, 21 Apr 2005 13:00:03 -0500 NNTP-Posting-Host: 67.161.24.234 X-Trace: sv3-Sz3mI0qI+Ouydc2rcljTrC7YCyviQ9wDeOLfAw7ES0uCU5lPjLsWCeO2Mkw7qu5jezs9BQ6clSXc07B!5tIV9lIVHM36DgOGmwfqjokCHDhYPphS4nD8bU8cr10Di3/M2pmzBietLtk1mQ== X-Complaints-To: abuse@comcast.net X-DMCA-Complaints-To: dmca@comcast.net X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.3.31 Xref: g2news1.google.com comp.lang.ada:10630 Date: 2005-04-21T13:00:03-05:00 List-Id: >I am trying to time a block of code down to the millisecond level. Can >anyone help in this area? The traditional way is T0 := Ada.Calendar.Clock; for i in 1 .. 1000 loop -- code to be timed end loop; Result := (Ada.Calendar.Clock - T0)/1000; If the code to be timed is short so the loop overhead is significant, then you time an empty loop (making sure the compiler doesn't optimize it away) and subtract that. On Windows machines it doesn't take long to call Ada.Calendar.Clock, and that's accurate to better than one microsecond, so if you want millisecond accuracy you could even dispense with the loop and just do T0 := Ada.Calendar.Clock; -- code to be timed Result := (Ada.Calendar.Clock - T0)/1000;