]> gitweb.factorcode.org Git - factor.git/commitdiff
benchmark.hash-sets: adding a benchmark for hash-sets.
authorJohn Benediktsson <mrjbq7@gmail.com>
Mon, 16 Apr 2012 17:57:57 +0000 (10:57 -0700)
committerJohn Benediktsson <mrjbq7@gmail.com>
Mon, 16 Apr 2012 17:57:57 +0000 (10:57 -0700)
extra/benchmark/hash-sets/hash-sets.factor [new file with mode: 0644]

diff --git a/extra/benchmark/hash-sets/hash-sets.factor b/extra/benchmark/hash-sets/hash-sets.factor
new file mode 100644 (file)
index 0000000..2aabff1
--- /dev/null
@@ -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