Skip to content
Browse files

benchmark.hash-sets: adding a benchmark for hash-sets.

  • Loading branch information...
1 parent f938ab0 commit cbde9a46432fed2bfcf653057e8ab16842d6cc82 @mrjbq7 committed Apr 16, 2012
Showing with 24 additions and 0 deletions.
  1. +24 −0 extra/benchmark/hash-sets/hash-sets.factor
View
24 extra/benchmark/hash-sets/hash-sets.factor
@@ -0,0 +1,24 @@
+
+USING: combinators hash-sets kernel math.combinatorics sequences sets ;
+
+IN: benchmark.hash-sets
+
+: make-sets ( -- seq )
+ { 10 100 1,000 10,000 100,000 1,000000 } [ iota >hash-set ] map ;
+
+: bench-sets ( seq -- )
+ 2 [
+ first2 {
+ [ union drop ]
+ [ intersect drop ]
+ [ intersects? drop ]
+ [ diff drop ]
+ [ set= drop ]
+ [ subset? drop ]
+ } 2cleave
+ ] each-combination ;
+
+: hash-sets-benchmark ( -- )
+ make-sets bench-sets ;
+
+MAIN: hash-sets-benchmark

0 comments on commit cbde9a4

Please sign in to comment.
Something went wrong with that request. Please try again.