logo To Foot
© J R Stockton, ≥ 2005-06-17

Borland Pascal Optimisation 0.

No-Frame * Framed Index * Frame This
Links within this site :-

A Simple Timing Example

Rather than using GetTime, it is IMHO easier to access the integer or word at $40:$6C directly for the 55 ms timer; it saves fiddling with hours, minutes, seconds, centiseconds. Just remember the rollover at multiples of 65536 ticks (hourly: if word, at almost xx:00:00; if integer, at almost xx:30:00) and at midnight - see Borland Pascal Time and Date.

This code compares a string assignment with Move; alter the value of T[0] to change string length. String contents do not matter.

var S, T : string ; T1, T2, T3, T4 : word ; J : longint ;
const N = 1000000 ;
var Tix : word absolute $40:$6C ;
BEGIN ;
  T[0] := #255 ;
  T1 := Tix ;
  for J := 1 to N do ;
  T2 := Tix ;
  for J := 1 to N do S := T ;
  T3 := Tix ;
  for J := 1 to N do Move(T[0], S[0], Length(T)) ;
  T4 := Tix ;
  Writeln(Ord(S[0]):10, T2-T1:10, T3-T2:10, T4-T3:10) ;
  END.

( Note - will fail if run both with checks on and across an hour-change)

It is IMHO better, however, to loop-wait for a transition of this counter, and run one's test code (assumed short, as in the original question) until the next transition, counting test loops. As long as the test code takes substantially less than 55 ms, one can thus obtain good, stable speed resolution in 1/18.2s in a pure DOS environment.

TurboPower's TPTimer

TPTIMER, in BONUS507.ZIP (which contains free stuff from TurboPower) has been spoken highly of. I expect BONUS is on all the best FTP sites; try Garbo.

Their OpCrt unit is, AIUI, susceptible to Start-Up RunTime Error 200.

2003-01-08 : I read that TurboPower is out of business.

Some References

Home Page
Mail: no HTML
© Dr J R Stockton, near London, UK.
All Rights Reserved.
These pages are tested mainly with Firefox 3.0 and W3's Tidy.
This site, http://www.merlyn.demon.co.uk/, is maintained by me.
Head.