Update collect-benchmarks so that it does not rely onto computed stack effect
parent
caa2a606c2
commit
9760eb4fb1
|
@ -1,23 +1,21 @@
|
||||||
! Copyright (c) 2007 Aaron Schaefer
|
! Copyright (c) 2007 Aaron Schaefer
|
||||||
! See http://factorcode.org/license.txt for BSD license.
|
! 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 ;
|
math.statistics namespaces sequences tools.time ;
|
||||||
IN: project-euler.ave-time
|
IN: project-euler.ave-time
|
||||||
|
|
||||||
<PRIVATE
|
<PRIVATE
|
||||||
|
|
||||||
: clean-stack ( quot -- )
|
|
||||||
infer dup effect-out swap effect-in - [ drop ] times ;
|
|
||||||
|
|
||||||
: ave-benchmarks ( seq -- pair )
|
: ave-benchmarks ( seq -- pair )
|
||||||
flip [ mean round ] map ;
|
flip [ mean round ] map ;
|
||||||
|
|
||||||
PRIVATE>
|
PRIVATE>
|
||||||
|
|
||||||
: collect-benchmarks ( quot n -- seq )
|
: collect-benchmarks ( quot n -- seq )
|
||||||
[
|
[
|
||||||
1- [ [ benchmark ] keep -rot 2array , [ clean-stack ] keep ] times
|
>r >r datastack r> [ benchmark 2array , ] curry tuck
|
||||||
] curry { } make >r benchmark 2array r> swap add ; inline
|
[ with-datastack drop ] 2curry r> swap times call
|
||||||
|
] { } make ;
|
||||||
|
|
||||||
: ave-time ( quot n -- )
|
: ave-time ( quot n -- )
|
||||||
[ collect-benchmarks ] keep swap ave-benchmarks [
|
[ collect-benchmarks ] keep swap ave-benchmarks [
|
||||||
|
|
Loading…
Reference in New Issue