Paste: faster?
Author: | randy7 |
Mode: | factor |
Date: | Fri, 23 Jan 2009 19:09:48 |
Plain Text |
IN: little-test
USING: continuations kernel math sequences system ;
: isolated-time ( quote -- delta-in-millis )
{ } swap '[ millis @ millis ] with-datastack
[ first ] [ peek ] bi swap - ;
: faster? ( quot1 quot2 -- ? )
[ isolated-time ] bi@ < ;
Author: | randy7 |
Mode: | factor |
Date: | Fri, 23 Jan 2009 20:01:55 |
Plain Text |
:: bench-ave-time ( n quot -- avg )
SYMBOL: accum-vector
V{ } clone accum-vector set
12 [
[ n quot times ] isolated-time
accum-vector get swap suffix accum-vector set
] times
accum-vector get
natural-sort 1 tail 1 head* mean
n pprint " operations took: " write >float pprint " milliseconds." write nl
;
Author: | randy7 |
Mode: | factor |
Date: | Fri, 23 Jan 2009 20:25:24 |
Plain Text |
IN: little-test
USING: fry locals continuations kernel math sequences system math.statistics ;
: isolated-time ( quote -- delta-in-millis )
{ } swap '[ millis @ millis ] with-datastack
[ first ] [ peek ] bi swap - ;
: faster? ( quot1 quot2 -- ? )
[ isolated-time ] bi@ < ;
:: bench-ave-time ( n quot -- avg )
SYMBOL: accum-vector
V{ } clone accum-vector set
12 [
[ n quot times ] isolated-time
accum-vector get swap suffix accum-vector set
] times
accum-vector get
natural-sort 1 tail 1 head* mean ;
: bench-timed. ( n quot -- )
[ bench-ave-time ]
[ drop pprint " operations took: " write >float pprint " milliseconds." write nl ] 2bi ;
: bfaster? ( n quot1 quot2 -- ? )
pick swap [ bench-ave-time ] 2bi@ < ;
New Annotation