2 USING: combinators hash-sets kernel literals
3 math math.combinatorics sequences sets ;
5 IN: benchmark.hash-sets
8 { 10 100 1,000 10,000 50,000 100,000 }
9 [ <iota> >hash-set ] map dup append
12 : do-times ( n quot: ( set1 set2 -- set' ) -- )
13 '[ 2dup @ drop ] times 2drop ; inline
15 : bench-sets ( seq -- )
18 [ 3 [ union ] do-times ]
19 [ 5 [ intersect ] do-times ]
20 [ 100,000 [ intersects? ] do-times ]
21 [ 3 [ diff ] do-times ]
22 [ 50 [ set= ] do-times ]
23 [ 25 [ subset? ] do-times ]
27 : hash-sets-benchmark ( -- )
28 test-sets bench-sets ;
30 MAIN: hash-sets-benchmark