2009-04-17 18:52:22 -04:00
|
|
|
! Copyright (C) 2007, 2009 Slava Pestov.
|
2007-09-20 18:09:08 -04:00
|
|
|
! See http://factorcode.org/license.txt for BSD license.
|
2009-05-04 07:44:17 -04:00
|
|
|
USING: kernel vocabs vocabs.loader tools.time vocabs.hierarchy
|
2008-02-12 16:51:34 -05:00
|
|
|
arrays assocs io.styles io help.markup prettyprint sequences
|
2009-07-16 04:30:11 -04:00
|
|
|
continuations debugger math namespaces memory fry ;
|
2007-09-20 18:09:08 -04:00
|
|
|
IN: benchmark
|
|
|
|
|
2009-04-17 18:52:22 -04:00
|
|
|
<PRIVATE
|
|
|
|
|
|
|
|
SYMBOL: timings
|
|
|
|
SYMBOL: errors
|
|
|
|
|
|
|
|
PRIVATE>
|
|
|
|
|
2009-09-10 19:32:45 -04:00
|
|
|
: run-benchmark ( vocab -- time )
|
2009-07-16 04:30:11 -04:00
|
|
|
[ 5 ] dip '[ gc [ _ run ] benchmark ] replicate infimum ;
|
|
|
|
|
2009-09-10 19:32:45 -04:00
|
|
|
<PRIVATE
|
|
|
|
|
|
|
|
: record-benchmark ( vocab -- )
|
2009-07-06 05:55:23 -04:00
|
|
|
[ "=== " write print flush ] [
|
2009-09-10 22:41:12 -04:00
|
|
|
[ [ require ] [ run-benchmark ] [ ] tri timings ]
|
2009-04-17 18:52:22 -04:00
|
|
|
[ swap errors ]
|
|
|
|
recover get set-at
|
2008-12-10 02:12:08 -05:00
|
|
|
] bi ;
|
2007-09-20 18:09:08 -04:00
|
|
|
|
2009-09-10 19:32:45 -04:00
|
|
|
PRIVATE>
|
|
|
|
|
2009-04-17 18:52:22 -04:00
|
|
|
: run-benchmarks ( -- timings errors )
|
|
|
|
[
|
|
|
|
V{ } clone timings set
|
|
|
|
V{ } clone errors set
|
2009-07-06 05:55:23 -04:00
|
|
|
"benchmark" child-vocab-names
|
2009-07-16 04:30:11 -04:00
|
|
|
[ find-vocab-root ] filter
|
2009-09-10 19:32:45 -04:00
|
|
|
[ record-benchmark ] each
|
2009-04-17 18:52:22 -04:00
|
|
|
timings get
|
|
|
|
errors get
|
|
|
|
] with-scope ;
|
2007-09-20 18:09:08 -04:00
|
|
|
|
2009-04-17 18:52:22 -04:00
|
|
|
: timings. ( assocs -- )
|
2007-09-20 18:09:08 -04:00
|
|
|
standard-table-style [
|
|
|
|
[
|
|
|
|
[ "Benchmark" write ] with-cell
|
2008-11-24 06:46:43 -05:00
|
|
|
[ "Time (seconds)" write ] with-cell
|
2007-09-20 18:09:08 -04:00
|
|
|
] with-row
|
|
|
|
[
|
|
|
|
[
|
2008-03-13 04:35:54 -04:00
|
|
|
[ [ 1array $vocab-link ] with-cell ]
|
2009-11-20 00:50:30 -05:00
|
|
|
[ 1,000,000,000 /f pprint-cell ]
|
2009-04-17 18:52:22 -04:00
|
|
|
bi*
|
2007-09-20 18:09:08 -04:00
|
|
|
] with-row
|
|
|
|
] assoc-each
|
2009-03-16 00:25:36 -04:00
|
|
|
] tabular-output nl ;
|
2007-09-20 18:09:08 -04:00
|
|
|
|
2009-04-17 18:52:22 -04:00
|
|
|
: benchmark-errors. ( errors -- )
|
|
|
|
[
|
|
|
|
[ "=== " write vocab-name print ]
|
|
|
|
[ error. ]
|
|
|
|
bi*
|
|
|
|
] assoc-each ;
|
|
|
|
|
2007-09-20 18:09:08 -04:00
|
|
|
: benchmarks ( -- )
|
2009-04-17 18:52:22 -04:00
|
|
|
run-benchmarks [ timings. ] [ benchmark-errors. ] bi* ;
|
2007-09-20 18:09:08 -04:00
|
|
|
|
|
|
|
MAIN: benchmarks
|
|
|
|
|