Last active
August 23, 2017 21:04
-
-
Save honix/261bfad3b1524a97440277e743186921 to your computer and use it in GitHub Desktop.
This file contains 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 [] | |
time: func [ | |
do-block | |
/repeat | |
n | |
/local | |
acc | |
start | |
][ | |
either repeat [ | |
acc: make time! [] | |
loop n [ | |
acc: acc + time do-block | |
acc / n | |
] | |
][ | |
start: now/precise | |
do do-block | |
difference now/precise start | |
] | |
] | |
fastest: func [ | |
block-a | |
block-b | |
/diff | |
/repeat | |
n | |
/local | |
time-a | |
time-b | |
][ | |
time-a: time/repeat block-a any [n 1'000] | |
time-b: time/repeat block-b any [n 1'000] | |
either time-a < time-b [ | |
if diff [print time-b - time-a] | |
:block-a | |
][ | |
if diff [print time-a - time-b] | |
:block-b | |
] | |
] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment