[comp.lang.pascal] Interesting: interaction between Timing and DELAY in TP

cncst3@unix.cis.pitt.edu (Chunqing N. Cheng) (11/02/90)

After I post my background music unit and timing program, I found
the timing program from SIMTEL by following the net information.
It is in the ZIP file BONUS507.zip.  By testing this TPtimer unit
and my unit, there is a very interesting phenomena:

The following conclusion is obtained based on DELAY procedure in
TP v5.5 is the best doing-nothing timing procedure.

I test the timing units by doing the following

    1.   initialize timer
         in my unit, first set INCREASE_CLOCK_SPEED_BY:=55
         which gives 1001 clicks every one second.
         TPtimer is set to be 1000 clicks every one second
         by default.
    2.   mark the begin time
    3.    DELAY(Given_time)
    4.   get the end Time;
    5.  Elapsed_clicks = End_time - Start_time  
    6.  Elapsed_time
         t = Elapsed_click/18.2/INCREASE_CLOSK_SPEED_BY  (my unit)
         t = Elapsedtime(end_time,start_time)            (TPTimer unit)


(1) overhead time is proportional to the Given_time in DELAY procedure.
    it is very very funny phenomena!!!!
    it is true in both cases.  The rough numbers are:

      Given_time      Elapsed click numbers   Times in second
       1000                1196                 1.194 (my unit)
                           1195                 3598???(TPtimer unit)
       2000                2392                 2.388 (my unit)
                           2389                 3597???(TPtimer unit)
       3000                3588                 3.581 (my unit)
                           3584                 3596??(TPtimer)
      ......     
(2)  calibration of TPTIMER seems to me doing more harm than good.
     Note the click number and the time in second of TPTimer unit
     are divided by 1000 before listing them.  I think the document
     in their file is wrong.   It can be seen that the click 
     number is basically the same but by ajusting to times,
     calibration in TPtimer does more harm than good.
     Any comment from people in Turbo Power or anybody else?

(3) why overhead time is proportional to the time in the delay
    procedure, any comment from any body, Borland people,
    Turbo Power people?  Can we trust delay routine in this
    matter?

(4) For the testing, I also asked a timing procedure from one
    of my friend.  My timer and Turbo Power timer have about
    190 clicks overhead for each second specified in DELAY
    procedure, and my friend's timer only has about 13 clicks
    overhead. (By the way, my friend's timer is written in
    in-line code, not regular pascal code.)

If my friend permits, I'll post his Timer program later.


Conclusion:   For those who really depends on micron second scale
              timing, just watch out. Do we have any benchmark
              program to justify these timing program???

Chunqing Cheng