]> gitweb.factorcode.org Git - factor.git/blob - extra/benchmark/heaps/heaps.factor
Switch to https urls
[factor.git] / extra / benchmark / heaps / heaps.factor
1 ! Copyright (C) 2009 Slava Pestov.
2 ! See https://factorcode.org/license.txt for BSD license.
3 USING: heaps math sequences kernel ;
4 IN: benchmark.heaps
5
6 : data ( -- seq )
7     1 6000 [ 13 + 79 * 13591 mod dup ] replicate nip ;
8
9 : heap-test ( -- )
10     <min-heap>
11     data
12     [ [ dup pick heap-push ] each ]
13     [ length [ dup heap-pop* ] times ] bi
14     drop ;
15
16 : heaps-benchmark ( -- )
17     100 [ heap-test ] times ;
18
19 MAIN: heaps-benchmark