1 ! Copyright (C) 2007, 2009 Slava Pestov.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: arrays assocs continuations debugger fry help.markup io
4 io.styles kernel math memory namespaces prettyprint sequences
5 tools.profiler.sampling tools.time vocabs vocabs.hierarchy
16 : run-timing-benchmark ( vocab -- time )
17 [ 5 ] dip '[ gc [ _ run ] benchmark ] replicate infimum ;
19 : run-profile-benchmark ( vocab -- profile )
20 compact-gc '[ _ run ] profile most-recent-profile-data ;
22 : find-benchmark-vocabs ( -- seq )
23 "benchmark" child-vocab-names
24 [ find-vocab-root ] filter ;
28 : print-record-header ( vocab -- )
29 "=== " write print flush ;
31 : run-benchmark ( vocab quot -- )
32 [ drop print-record-header ] [
34 _ [ [ require ] _ [ ] tri results ]
40 : run-benchmarks ( quot -- results errors )
43 [ [ V{ } clone swap set ] bi@ ]
44 [ 2drop find-benchmark-vocabs [ _ run-benchmark ] each ]
51 : run-timing-benchmarks ( -- results errors )
52 [ run-timing-benchmark ] run-benchmarks ;
54 : run-profile-benchmarks ( -- results errors )
55 [ run-profile-benchmark ] run-benchmarks ;
57 : timings. ( assocs -- )
58 standard-table-style [
60 [ "Benchmark" write ] with-cell
61 [ "Time (seconds)" write ] with-cell
65 [ [ 1array $vocab-link ] with-cell ]
66 [ 1,000,000,000 /f pprint-cell ]
72 : benchmark-errors. ( errors -- )
74 [ "=== " write vocab-name print ]
79 : timing-benchmarks ( -- )
81 [ timings. ] [ benchmark-errors. ] bi* ;
83 MAIN: timing-benchmarks