Created
October 7, 2016 09:18
-
-
Save DideC/7b4f47c8cb275c47f8a22b20f1f87e9a to your computer and use it in GitHub Desktop.
Small func to compute running time of a Red/Rebol code
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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