2010-04-17 01:57:53 -04:00
|
|
|
! Copyright (C) 2008, 2010 Slava Pestov.
|
2008-08-24 04:59:22 -04:00
|
|
|
! See http://factorcode.org/license.txt for BSD license.
|
2010-04-17 01:57:53 -04:00
|
|
|
USING: binary-search kernel math.primes math.ranges memoize
|
|
|
|
prettyprint sequences ;
|
2008-08-24 04:59:22 -04:00
|
|
|
IN: benchmark.binary-search
|
|
|
|
|
2010-04-17 01:57:53 -04:00
|
|
|
MEMO: primes-under-million ( -- seq ) 1000000 primes-upto ;
|
2008-08-24 04:59:22 -04:00
|
|
|
|
2008-12-29 15:29:26 -05:00
|
|
|
! Force computation of the primes list before benchmarking the binary search
|
|
|
|
primes-under-million drop
|
|
|
|
|
2009-01-07 04:34:07 -05:00
|
|
|
: binary-search-benchmark ( -- )
|
2012-07-13 19:11:01 -04:00
|
|
|
1 1000000 [a,b] [ primes-under-million sorted-member? ] map
|
|
|
|
length 1000000 assert= ;
|
2009-01-07 04:34:07 -05:00
|
|
|
|
2008-08-24 04:59:22 -04:00
|
|
|
MAIN: binary-search-benchmark
|