]> gitweb.factorcode.org Git - factor.git/blob - extra/benchmark/binary-search/binary-search.factor
Merge branch 'master' of git://factorcode.org/git/factor into s3
[factor.git] / extra / benchmark / binary-search / binary-search.factor
1 ! Copyright (C) 2008, 2010 Slava Pestov.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: binary-search kernel math.primes math.ranges memoize
4 prettyprint sequences ;
5 IN: benchmark.binary-search
6
7 MEMO: primes-under-million ( -- seq ) 1000000 primes-upto ;
8
9 ! Force computation of the primes list before benchmarking the binary search
10 primes-under-million drop
11
12 : binary-search-benchmark ( -- )
13     1 1000000 [a,b] [ primes-under-million sorted-member? ] map length . ;
14
15 MAIN: binary-search-benchmark