1 ! Copyright (C) 2007, 2009 Slava Pestov.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: kernel vocabs vocabs.loader tools.time vocabs.hierarchy
4 arrays assocs io.styles io help.markup prettyprint sequences
5 continuations debugger math namespaces memory fry ;
15 : (run-benchmark) ( vocab -- time )
16 [ 5 ] dip '[ gc [ _ run ] benchmark ] replicate infimum ;
18 : run-benchmark ( vocab -- )
19 [ "=== " write print flush ] [
20 [ [ require ] [ (run-benchmark) ] [ ] tri timings ]
25 : run-benchmarks ( -- timings errors )
27 V{ } clone timings set
29 "benchmark" child-vocab-names
30 [ find-vocab-root ] filter
31 [ run-benchmark ] each
36 : timings. ( assocs -- )
37 standard-table-style [
39 [ "Benchmark" write ] with-cell
40 [ "Time (seconds)" write ] with-cell
44 [ [ 1array $vocab-link ] with-cell ]
45 [ 1000000 /f pprint-cell ]
51 : benchmark-errors. ( errors -- )
53 [ "=== " write vocab-name print ]
59 run-benchmarks [ timings. ] [ benchmark-errors. ] bi* ;