Skip to content

Instantly share code, notes, and snippets.

@DideC
Created October 7, 2016 09:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DideC/7b4f47c8cb275c47f8a22b20f1f87e9a to your computer and use it in GitHub Desktop.
Save DideC/7b4f47c8cb275c47f8a22b20f1f87e9a to your computer and use it in GitHub Desktop.
Small func to compute running time of a Red/Rebol code
Red [
title: "Compute the time taken to run a code a number of times."
author: "Didier Cadieu"
]
dt: func [n [integer!] code [block!] /local st] [
st: now/time/precise
loop n code
print [n "loops in" st: now/time/precise - st " => one in" st / n]
]
; Usage:
; red>> dt 10000 [4 * random 100 / sine pi]
; 10000 loops in 0:00:00.014000001 => one in 0:00:01.401e-6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment