Skip to content

Instantly share code, notes, and snippets.

@honix
Last active August 23, 2017 21:04
Show Gist options
  • Save honix/261bfad3b1524a97440277e743186921 to your computer and use it in GitHub Desktop.
Save honix/261bfad3b1524a97440277e743186921 to your computer and use it in GitHub Desktop.
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