From f521805bb3fb8ef3e3bd75242adc4c4e210e740c Mon Sep 17 00:00:00 2001 From: Samuel Tardieu Date: Mon, 29 Dec 2008 13:55:47 +0100 Subject: [PATCH 1/2] Memoize small primes list This makes "benchmark.binary-search" work again in a reasonable time. --- extra/math/primes/list/list.factor | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/extra/math/primes/list/list.factor b/extra/math/primes/list/list.factor index 08212840c3..7467d126d0 100644 --- a/extra/math/primes/list/list.factor +++ b/extra/math/primes/list/list.factor @@ -1,4 +1,4 @@ -USING: math.primes ; +USING: math.primes memoize ; IN: math.primes.list -: primes-under-million ( -- seq ) 1000000 primes-upto ; +MEMO: primes-under-million ( -- seq ) 1000000 primes-upto ; From c1c1ebf3d4265e08419720bb6d8c1c4cdb4939f0 Mon Sep 17 00:00:00 2001 From: Samuel Tardieu Date: Mon, 29 Dec 2008 21:29:26 +0100 Subject: [PATCH 2/2] Force primes list evaluation before benchmark --- extra/benchmark/binary-search/binary-search.factor | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/extra/benchmark/binary-search/binary-search.factor b/extra/benchmark/binary-search/binary-search.factor index 1018e643ef..e5c81a954d 100644 --- a/extra/benchmark/binary-search/binary-search.factor +++ b/extra/benchmark/binary-search/binary-search.factor @@ -1,10 +1,13 @@ ! Copyright (C) 2008 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. -USING: binary-search math.primes.list math.ranges sequences +USING: binary-search kernel math.primes.list math.ranges sequences prettyprint ; IN: benchmark.binary-search : binary-search-benchmark ( -- ) 1 1000000 [a,b] [ primes-under-million sorted-member? ] map length . ; +! Force computation of the primes list before benchmarking the binary search +primes-under-million drop + MAIN: binary-search-benchmark