1 ! Copyright (C) 2008 Slava Pestov.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: binary-search compiler.units kernel math.primes math.ranges
4 memoize prettyprint sequences ;
5 IN: benchmark.binary-search
8 MEMO: primes-under-million ( -- seq ) 1000000 primes-upto ;
9 ] with-compilation-unit
11 ! Force computation of the primes list before benchmarking the binary search
12 primes-under-million drop
14 : binary-search-benchmark ( -- )
15 1 1000000 [a,b] [ primes-under-million sorted-member? ] map length . ;
17 MAIN: binary-search-benchmark