Path: utzoo!attcan!uunet!tut.cis.ohio-state.edu!ucsd!nosc!crash!nkraft From: nkraft@crash.cts.com (Norman Kraft) Newsgroups: comp.lang.pascal Subject: Re: Timing in Turbo Pascal Message-ID: <5307@crash.cts.com> Date: 28 Oct 90 00:14:42 GMT References: <2280@oucsace.cs.OHIOU.EDU> Distribution: na Organization: Crash TimeSharing, El Cajon, CA Lines: 33 In article <2280@oucsace.cs.OHIOU.EDU> tswingle@oucsace.cs.ohiou.edu (Tom Swingle) writes: >Does anybody know of a way to *accurately* time an event down to at least 1/100 >of a second in Turbo Pascal? I have tried using the GetTime procedure, but it >relies on DOS, which is only accurate to about 5/100 of a second. Turbo Pascal >has the Delay procedure which can accurately time to 1/1000 of a second. Does >anybody know how they do this? Well, what they do, on an AT machine at least, is call a BIOS function which waits for a millisecond. Unfortunately, we have found that the accuracy of this BIOS routine varies from machine to machine, and if one desires to have timings with resolutions of 1ms, the Turbo delay funtion just won't do it. >Here is what I would like to do. I would like to create a little unit called >Timer which would have procedures for timing how long a block takes to execute >regardless of the speed of the machine it is working on. It would work >something like this: Before you start this project, look at Abrash's "Zen of Assembly Language". In the first several chapters he developes an assembler routine which does not depend on the BIOS, but uses timer chips in a very efficient and accurate way. The "ZenTimer", as it is called, achieves a resolution of 1 microsecond (1 millionth of a second), and uses the 8253. Abrash uses it to time 4 cycle assembler routines: a serious challenge, that! -------------------------------------------------------------------------- Norman R. Kraft "Things should be as simple Director, Software Development as possible, but not simpler." Postal Buddy Corporation, San Diego, CA - Albert Einstein INET nkraft@crash.cts.com UUCP {hplabs!hp-sdd ucsd nosc}!crash!nkraft Usual disclaimer applies... --------------------------------------------------------------------------