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 ranges
5 IN: benchmark.binary-search
7 ! Force computation of the primes list before benchmarking the binary search
8 CONSTANT: primes-under-million $[ 1,000,000 primes-upto ]
10 : binary-search-benchmark ( -- )
11 1,000,000 [1..b] [ primes-under-million sorted-member? ] map
12 length 1,000,000 assert= ;
14 MAIN: binary-search-benchmark