Fix ave-time considering switch to micro seconds

db4
Aaron Schaefer 2008-11-24 22:05:43 -05:00
parent addcb36c57
commit 6333710f7d
1 changed files with 9 additions and 6 deletions

View File

@ -1,21 +1,24 @@
! Copyright (c) 2007 Aaron Schaefer.
! Copyright (c) 2007, 2008 Aaron Schaefer.
! See http://factorcode.org/license.txt for BSD license.
USING: continuations fry io kernel make math math.functions math.parser
math.statistics memory tools.time ;
IN: project-euler.ave-time
: nth-place ( x n -- y )
10 swap ^ [ * round >integer ] keep /f ;
: collect-benchmarks ( quot n -- seq )
[
[ datastack ]
[ '[ _ gc benchmark , ] tuck '[ _ _ with-datastack drop ] ]
[
'[ _ gc benchmark 1000 / , ] tuck
'[ _ _ with-datastack drop ]
]
[ 1- ] tri* swap times call
] { } make ; inline
: nth-place ( x n -- y )
10 swap ^ [ * round ] keep / ;
: ave-time ( quot n -- )
[ collect-benchmarks ] keep swap
[ std 2 nth-place ] [ mean round ] bi [
[ std 2 nth-place ] [ mean round >integer ] bi [
# " ms ave run time - " % # " SD (" % # " trials)" %
] "" make print flush ; inline