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