In my quest to count teeny bits of time in REBOL, I created the following 
counting expression which makes note of how high REBOL can count in 
increments of 1 within a single second.

forever [ t: now
              c: 1
              while [ now = t ][ c: c + 1 ]
              print c
              append b c
              c: copy []
]

Of course, the results are entirely dependent upon the computer system you 
are using and how many other tasks the computer may be processing at the 
moment. Here are the results of running the expression on an Intel Celeron 
333MHz workstation running Windows NT 4 (bear in mind the first number 
returned is the remaining number of times the expression can count from 1 
within the second the expression begins):

2498
37594
37261
37103
37313
37555
37551
37274
37472
37563
37195
37539
37556
37496
37579
37386
37540
37108
>>

I guess this is a REBOL benchmarking expression of sorts.

If you could run this expression continuously while running other REBOL 
scripts--and if you could call the count from within the expression using 
another REBOL script running in parallel--you could create a fraction of a 
second based on the average count total during a specified period of time.

For example, you call 'c from the expression when 'c = 2000. Perhaps the 
average number of counts during the previous 10 seconds was 37,501 counts 
per second. Then the fraction would be .053331 seconds. REBOL could 
return a special 'now of

>> now
== 19-Jun-2000/18:20:44.053331-5:00

or

>> current-time: now/time
== 18:20:44.053331-5:00

Then you have your milliseconds, microseconds, and nanoseconds as 
follows:

>> print current-time/second
44
>> print current-time/millisecond
5
>> print current-time/microsecond
33
>> print current-time/nanosecond
31

Of course, this is a very imprecise way of measuring sub-second intervals in 
REBOL.

Any suggestions on how this might be implemented?

-Ryan

Reply via email to