Comments on: Changes to high resolution time in R3

Carl Sassenrath, CTO
REBOL Technologies
10-Nov-2009 18:35 GMT

Article #0293
Main page || Index || Prior Article [0292] || Next Article [0294] || 1 Comments || Send feedback

I wanted to make this note so as not to be lost along the way. The A95 release (TBR this week) has some changes to high-resolution stats/timer timestamps:

  • Changed from integer! to time! datatype (and delta-time has been updated for that change)
  • Resolution is microseconds
  • At boot time, prior to any initialization, it is set to 0:00:00.0 (see the note below to understand this value.)
  • Computes delta with high-resolution timer ticks (on Win32) before frequency division. See warning note below.


  1. Keep in mind that your system is multitasking, so you will see variations in timing based on time used by other applications.
  2. To get more accurate timings for code-speed evaluation, you will need to use various timing techniques, such as those suggested by Ladislav, Simply timing one loop of a section of code is not accurate.
  3. Setting the base time to 0:00 on boot is an interesting feature. It lets you determine the time it takes for REBOL to initialize (quite a lot happens during boot.) Perhaps this value is debatable. An alternative might be to set it to the current time-of-day. However, by doing so, users might incorrectly assume that it would accurately indicate time-of-day, a false assumption.
  4. If your CPU changes speed (clock frequency) during the use of stats/timer, the result may not be accurate. That happens because we now compute the time delta based the full precision of the CPU counter and only divide the counter frequency after the delta is subtracted.


Script that accurately shows total boot time:

REBOL [file: %boot-time.r]
print stats/timer

Result when script is run:

Evaluating: /C/rebol/boot-time.r

Simple example timing the SINE function:

delta-time [loop 100 [sine 123]]

This line was evaluated several times to observe that the result was relatively accurate.



10-Nov-2009 14:42:02
Point 3 is cool as I've been wanting to read the uptime for a REBOL process for a while now. Boot time can be derived using NOW, so having it start at zero is fine.

Post a Comment:

You can post a comment here. Keep it on-topic.


Blog id:



 Note: HTML tags allowed for: b i u li ol ul font span div a p br pre tt blockquote

This is a technical blog related to the above topic. We reserve the right to remove comments that are off-topic, irrelevant links, advertisements, spams, personal attacks, politics, religion, etc.

Updated 27-May-2024 - Edit - Copyright REBOL Technologies -