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 ;
20 : record-benchmark ( vocab -- )
21 [ "=== " write print flush ] [
22 [ [ require ] [ run-benchmark ] [ ] tri timings ]
29 : run-benchmarks ( -- timings errors )
31 V{ } clone timings set
33 "benchmark" child-vocab-names
34 [ find-vocab-root ] filter
35 [ record-benchmark ] each
40 : timings. ( assocs -- )
41 standard-table-style [
43 [ "Benchmark" write ] with-cell
44 [ "Time (seconds)" write ] with-cell
48 [ [ 1array $vocab-link ] with-cell ]
49 [ 1,000,000,000 /f pprint-cell ]
55 : benchmark-errors. ( errors -- )
57 [ "=== " write vocab-name print ]
63 run-benchmarks [ timings. ] [ benchmark-errors. ] bi* ;