]> gitweb.factorcode.org Git - factor.git/blob - extra/project-euler/ave-time/ave-time.factor
Fix init-wiki
[factor.git] / extra / project-euler / ave-time / ave-time.factor
1 ! Copyright (c) 2007 Aaron Schaefer
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: arrays combinators io kernel math math.functions math.parser
4     math.statistics namespaces sequences tools.time continuations ;
5 IN: project-euler.ave-time
6
7 : collect-benchmarks ( quot n -- seq )
8   [
9     >r >r datastack r> [ benchmark , ] curry tuck
10     [ with-datastack drop ] 2curry r> swap times call
11   ] { } make ;
12
13 : ave-time ( quot n -- )
14     [ collect-benchmarks ] keep swap mean round [
15         # " ms run time - " % # " trials" %
16     ] "" make print flush ; inline