benchmark: run each benchmark 5 times and take the best time

db4
Slava Pestov 2009-07-16 03:30:11 -05:00
parent fbf907308e
commit 4931ab0d5f
1 changed files with 6 additions and 2 deletions

View File

@ -2,7 +2,7 @@
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: kernel vocabs vocabs.loader tools.time vocabs.hierarchy USING: kernel vocabs vocabs.loader tools.time vocabs.hierarchy
arrays assocs io.styles io help.markup prettyprint sequences arrays assocs io.styles io help.markup prettyprint sequences
continuations debugger math namespaces memory ; continuations debugger math namespaces memory fry ;
IN: benchmark IN: benchmark
<PRIVATE <PRIVATE
@ -12,9 +12,12 @@ SYMBOL: errors
PRIVATE> PRIVATE>
: (run-benchmark) ( vocab -- time )
[ 5 ] dip '[ gc [ _ run ] benchmark ] replicate infimum ;
: run-benchmark ( vocab -- ) : run-benchmark ( vocab -- )
[ "=== " write print flush ] [ [ "=== " write print flush ] [
[ [ require ] [ gc [ run ] benchmark ] [ ] tri timings ] [ [ require ] [ (run-benchmark) ] [ ] tri timings ]
[ swap errors ] [ swap errors ]
recover get set-at recover get set-at
] bi ; ] bi ;
@ -24,6 +27,7 @@ PRIVATE>
V{ } clone timings set V{ } clone timings set
V{ } clone errors set V{ } clone errors set
"benchmark" child-vocab-names "benchmark" child-vocab-names
[ find-vocab-root ] filter
[ run-benchmark ] each [ run-benchmark ] each
timings get timings get
errors get errors get