Subject: Millisecond timing 10. ***** Q: How is millisecond timing done? A: A difficult task, but the facilities are readily available. TurboPower Software's commercial Turbo Professional (don't confuse with Borland's Turbo Professional) has a unit for this. (The usual disclaimer applies). It is called tptimer and is part of the ftp://garbo.uwasa.fi/pc/turbopas/bonus507.zip package. This one has been released to the PD. I have also seen a SimTel upload announcement of a ztimer11.zip for C and ASM, but I have no further information on that. ftp://garbo.uwasa.fi/pc/turbopas/qwktimer.zip is another option. It is not quite as accurate as tptimer. To test the tptimer unit in bonus507.zip you can use the following example code uses Crt, tptimer; var time1, time2 : longint; begin InitializeTimer; time1 := ReadTimer; Delay (1356); (* Or whatever code you wish to benchmark *) time2 := ReadTimer; RestoreTimer; writeln ('Elapsed = ', ElapsedTime (time1, time2)/1000.0 : 0 : 3); end. It is quite another question when you really need the millisecond timing. The most common purpose for millisecond timing is testing the efficiency of alternative procedures and functions, right? The way I compare mine is simple. I call the procedures or functions I want to compare for speed, say, a thousand times in a loop. And test this for elapsed time. This way the normal resolution (18.2 cycles per second) of the system clock becomes sufficient. This is accurate enough for the comparisons. var elapsed : real; i : word; elapsed := TIMERFN; (* e.g. from /pc/ts/tspa3455.zip *) for i := 1 to 1000 do YOURTEST; (* Try out the alternatives *) elapsed := TIMERFN - elapsed; writeln ('Elapsed : ', elapsed : 0 : 2); Incidentally, if you want to make more elaborate evaluations of the efficiency of your code, Borland's Turbo Profiler is a useful tool. (The usual disclaimer naturally applies.) --------------------------------------------------------------------