]> gitweb.factorcode.org Git - factor.git/commitdiff
Update collect-benchmarks so that it does not rely onto computed stack effect
authorSamuel Tardieu <sam@rfc1149.net>
Fri, 28 Dec 2007 13:17:31 +0000 (14:17 +0100)
committerSamuel Tardieu <sam@rfc1149.net>
Fri, 28 Dec 2007 13:19:19 +0000 (14:19 +0100)
extra/project-euler/ave-time/ave-time.factor

index d481b30c84995e02029a89afe87ebac7ed545032..b908dbd7b02568f1ba38446992e2b087b3bf960d 100644 (file)
@@ -1,23 +1,21 @@
 ! Copyright (c) 2007 Aaron Schaefer
 ! See http://factorcode.org/license.txt for BSD license.
-USING: arrays effects inference io kernel math math.functions math.parser
+USING: arrays combinators io kernel math math.functions math.parser
     math.statistics namespaces sequences tools.time ;
 IN: project-euler.ave-time
 
 <PRIVATE
 
-: clean-stack ( quot -- )
-    infer dup effect-out swap effect-in - [ drop ] times ;
-
 : ave-benchmarks ( seq -- pair )
     flip [ mean round ] map ;
 
 PRIVATE>
 
 : collect-benchmarks ( quot n -- seq )
-    [
-        1- [ [ benchmark ] keep -rot 2array , [ clean-stack ] keep ] times
-    ] curry { } make >r benchmark 2array r> swap add ; inline
+  [
+    >r >r datastack r> [ benchmark 2array , ] curry tuck
+    [ with-datastack drop ] 2curry r> swap times call
+  ] { } make ;
 
 : ave-time ( quot n -- )
     [ collect-benchmarks ] keep swap ave-benchmarks [