Paste: dispatch speed test

Author: prunedtree
Mode: factor
Date: Wed, 15 Oct 2008 15:45:58
Plain Text |
USING: kernel math hashtables arrays assocs sequences unicode.case 
       splitting prettyprint strings fry make ;
       
USING: kernel.private system sequences.private ;
 
 
: do-stuff-once ( c a -- c a ) [ 0 swap nth-unsafe + ] keep ; inline

: do-stuff ( c a -- c ) 
   do-stuff-once 
   do-stuff-once 
   do-stuff-once 
   do-stuff-once 
   do-stuff-once 

   do-stuff-once 
   do-stuff-once 
   do-stuff-once 
   do-stuff-once 
   do-stuff-once 
   
   drop
   ; inline
  
: test2 ( -- foo ) 0 10 1000 1000 * * [ { fixnum } declare { { 1 } } first { array } declare do-stuff ] times ;
: test ( -- foo ) 0 10 1000 1000 * * [ { { 1 } } first do-stuff ] times ;
: count-ms ( quot -- ms ) millis [ call ] dip  millis swap - ;
: count ( -- call/ms ) [ test drop ] count-ms [ test2 drop ] count-ms - 10 1000 1000 * * swap / >float ;

New Annotation

Summary:
Author:
Mode:
Body: