1 ! Copyright (c) 2007 Aaron Schaefer.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: continuations io kernel math math.functions math.parser math.statistics
4 namespaces make tools.time ;
5 IN: project-euler.ave-time
7 : collect-benchmarks ( quot n -- seq )
9 >r >r datastack r> [ benchmark , ] curry tuck
10 [ with-datastack drop ] 2curry r> swap times call
13 : nth-place ( x n -- y )
14 10 swap ^ [ * round ] keep / ;
16 : ave-time ( quot n -- )
17 [ collect-benchmarks ] keep
18 swap [ std 2 nth-place ] [ mean round ] bi [
19 # " ms ave run time - " % # " SD (" % # " trials)" %
20 ] "" make print flush ; inline