Dear All,
In an application that I'm writing I need a way to 'block' computations
for very short periods of time. I thought at first that Delay would do
the job, but running

for I in 0..1000;10 do T1 T2 in
  T1 = {Property.get 'time.total'}
  {Delay I}
  T2 = {Property.get 'time.total'}
  {ShowInfo I#'\t'#T2-T1#'\t'#{Int.toFloat (T2-T1)}/{Int.toFloat I}}
end

shows that (at least under Windows) results of calls to {Delay I} aren't
very precise: {Delay 10} delays for 16 ms, {Delay 20} for 31 ms, {Delay
100} for 109 ms, etc. See the table produced by the above code at the
end of this message. (On the other hand I've noticed that I do get exact times for {Delay I} when I are multiples of 125 - if that's by coincidence, I don't know..?. )

Now, I've read about Delay in CTM and I think I understand the above
behaviour. {Delay I} suspends the calling thread T for *at least* I ms,
and when T is allowed to run again, it is subject to the ordinary thread
scheduling mechanism, which means that it may take a bit longer to
actually run. So I guess Delay does what it is supposed to do. The fact
remains that I need timing more exact than that though, so here are my
questions:

- Is it possible to write a version of Delay which is more exact for
small Is?
- Is there anything else that I can use? {MyDelay I} does not
necessarily have to suspend the calling thread - it can just eat cycles
from it - not too many though...
- Is the exactness of {Delay I} when I are multiples of 125 something I
can rely on?

Cheers,
Torbjörn

 I      T      I/T
===    ===    =====
  0      0    -1.#IND
 10     16    1.6
 20     31    1.55
 30     31    1.03333
 40     47    1.175
 50     63    1.26
 60     62    1.03333
 70     78    1.11429
 80     94    1.175
 90     94    1.04444
100    109    1.09
110    125    1.13636
120    125    1.04167
130    141    1.08462
140    141    1.00714
150    156    1.04
160    172    1.075
170    172    1.01176
180    187    1.03889
190    203    1.06842
200    203    1.015
210    219    1.04286
220    234    1.06364
230    235    1.02174
240    250    1.04167
250    250    1.0
260    265    1.01923
270    282    1.04444
280    281    1.00357
290    297    1.02414
300    312    1.04
310    313    1.00968
320    328    1.025
330    344    1.04242
340    343    1.00882
350    360    1.02857
360    375    1.04167
370    375    1.01351
380    390    1.02632
390    391    1.00256
400    406    1.015
410    422    1.02927
420    422    1.00476
430    438    1.0186
440    453    1.02955
450    453    1.00667
460    469    1.01957
470    484    1.02979
480    484    1.00833
490    500    1.02041
500    500    1.0
510    516    1.01176
520    531    1.02115
530    531    1.00189
540    547    1.01296
550    563    1.02364
560    562    1.00357
570    578    1.01404
580    594    1.02414
590    594    1.00678
600    609    1.015
610    625    1.02459
620    625    1.00806
630    641    1.01746
640    641    1.00156
650    656    1.00923
660    672    1.01818
670    672    1.00299
680    687    1.01029
690    703    1.01884
700    703    1.00429
710    719    1.01268
720    734    1.01944
730    735    1.00685
740    750    1.01351
750    750    1.0
760    765    1.00658
770    782    1.01558
780    781    1.00128
790    797    1.00886
800    812    1.015
810    813    1.0037
820    828    1.00976
830    844    1.01687
840    843    1.00357
850    860    1.01176
860    875    1.01744
870    875    1.00575
880    890    1.01136
890    891    1.00112
900    906    1.00667
910    922    1.01319
920    922    1.00217
930    938    1.0086
940    953    1.01383
950    953    1.00316
960    969    1.00937
970    984    1.01443
980    984    1.00408
990   1000    1.0101
1000  1000    1.0


_________________________________________________________________________________
mozart-users mailing list                               
[email protected]
http://www.mozart-oz.org/mailman/listinfo/mozart-users
  • Delay Torbjörn Lager

Reply via email to