benchmark.timers: adding a timer benchmark.

db4
John Benediktsson 2013-02-19 15:39:50 -08:00
parent 10a4413bec
commit 5262c8a1ae
1 changed files with 25 additions and 0 deletions
extra/benchmark/timers

View File

@ -0,0 +1,25 @@
USING: concurrency.flags kernel math namespaces timers ;
IN: benchmark.timers
SYMBOL: loop-flag
SYMBOL: loop-count
SYMBOL: loop-max
: inner-loop ( -- )
loop-count counter loop-max get-global > [
loop-flag get-global raise-flag
] when ;
: outer-loop ( n -- )
loop-max set-global
0 loop-count set-global
<flag> loop-flag set-global
[ inner-loop ] 1 every
loop-flag get-global wait-for-flag
stop-timer ;
: timers-benchmark ( -- )
20,000 [ outer-loop ] [ loop-max get-global assert= ] bi ;
MAIN: timers-benchmark