]> gitweb.factorcode.org Git - factor.git/blob - extra/benchmark/binary-search/binary-search.factor
ddaaa2f66970b0f2cdc041b67ec1d02a551faffc
[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 literals math.primes math.ranges
4 sequences ;
5 IN: benchmark.binary-search
6
7 ! Force computation of the primes list before benchmarking the binary search
8 CONSTANT: primes-under-million $[ 1,000,000 primes-upto ]
9
10 : binary-search-benchmark ( -- )
11     1,000,000 [1..b] [ primes-under-million sorted-member? ] map
12     length 1,000,000 assert= ;
13
14 MAIN: binary-search-benchmark