]> gitweb.factorcode.org Git - factor.git/blob - extra/benchmark/binary-search/binary-search.factor
Merge branch 'master' into experimental
[factor.git] / extra / benchmark / binary-search / binary-search.factor
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
6
7 [
8     MEMO: primes-under-million ( -- seq ) 1000000 primes-upto ;
9 ] with-compilation-unit
10
11 ! Force computation of the primes list before benchmarking the binary search
12 primes-under-million drop
13
14 : binary-search-benchmark ( -- )
15     1 1000000 [a,b] [ primes-under-million sorted-member? ] map length . ;
16
17 MAIN: binary-search-benchmark