2009-10-27 04:37:05 -04:00
|
|
|
! Copyright (C) 2003, 2009 Slava Pestov.
|
2007-09-20 18:09:08 -04:00
|
|
|
! See http://factorcode.org/license.txt for BSD license.
|
2009-05-06 15:56:50 -04:00
|
|
|
USING: kernel math memory io io.styles prettyprint
|
2009-04-28 23:45:19 -04:00
|
|
|
namespaces system sequences splitting grouping assocs strings
|
|
|
|
generic.single combinators ;
|
2007-09-20 18:09:08 -04:00
|
|
|
IN: tools.time
|
|
|
|
|
2008-05-09 10:05:52 -04:00
|
|
|
: benchmark ( quot -- runtime )
|
2008-12-03 09:46:16 -05:00
|
|
|
micros [ call micros ] dip - ; inline
|
2008-05-07 18:42:41 -04:00
|
|
|
|
2009-04-28 23:45:19 -04:00
|
|
|
: time. ( time -- )
|
2009-04-30 21:03:52 -04:00
|
|
|
"== Running time ==" print nl 1000000 /f pprint " seconds" print ;
|
2009-04-28 23:45:19 -04:00
|
|
|
|
|
|
|
: dispatch-stats. ( stats -- )
|
|
|
|
"== Megamorphic caches ==" print nl
|
2009-11-02 04:25:39 -05:00
|
|
|
[ { "Hits" "Misses" } ] dip zip simple-table. ;
|
2009-04-28 23:45:19 -04:00
|
|
|
|
|
|
|
: inline-cache-stats. ( stats -- )
|
2009-10-27 04:37:05 -04:00
|
|
|
"== Polymorphic inline caches ==" print nl
|
2009-04-28 23:45:19 -04:00
|
|
|
3 cut
|
|
|
|
[
|
2009-10-27 04:37:05 -04:00
|
|
|
"- Transitions:" print
|
2009-11-02 04:25:39 -05:00
|
|
|
[ { "Cold to monomorphic" "Mono to polymorphic" "Poly to megamorphic" } ] dip zip
|
2009-04-28 23:45:19 -04:00
|
|
|
simple-table. nl
|
|
|
|
] [
|
2009-10-27 04:37:05 -04:00
|
|
|
"- Type check stubs:" print
|
2009-11-02 04:25:39 -05:00
|
|
|
[ { "Tag" "Tuple" } ] dip zip
|
2009-04-28 23:45:19 -04:00
|
|
|
simple-table.
|
|
|
|
] bi* ;
|
|
|
|
|
2007-09-20 18:09:08 -04:00
|
|
|
: time ( quot -- )
|
2009-04-28 23:45:19 -04:00
|
|
|
reset-dispatch-stats
|
|
|
|
reset-inline-cache-stats
|
2009-10-27 04:37:05 -04:00
|
|
|
benchmark dispatch-stats inline-cache-stats
|
|
|
|
[ time. nl ]
|
|
|
|
[ dispatch-stats. nl ]
|
|
|
|
[ inline-cache-stats. ]
|
|
|
|
tri* ; inline
|