]> gitweb.factorcode.org Git - factor.git/commitdiff
benchmark.hash-sets: do more benching (create sets in a literal).
authorJohn Benediktsson <mrjbq7@gmail.com>
Wed, 27 Mar 2013 00:35:04 +0000 (17:35 -0700)
committerJohn Benediktsson <mrjbq7@gmail.com>
Wed, 27 Mar 2013 00:42:41 +0000 (17:42 -0700)
Don't run the "intersects?" test on old hash-sets, they are sloooooow.

extra/benchmark/hash-sets/hash-sets.factor

index 2aabff14e4d800eb843b268d5eb09927d42e8c80..cef4f996220ab7c0fa31f6c529934ebdb0054b25 100644 (file)
@@ -1,24 +1,30 @@
 
-USING: combinators hash-sets kernel math.combinatorics sequences sets ;
+USING: combinators fry hash-sets kernel literals
+math 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 ;
+CONSTANT: test-sets $[
+    { 10 100 1,000 10,000 50,000 100,000 }
+    [ iota >hash-set ] map dup append
+]
+
+: do-times ( n quot: ( set1 set2 -- set' ) -- )
+    '[ 2dup @ drop ] times 2drop ; inline
 
 : bench-sets ( seq -- )
     2 [
         first2 {
-            [ union drop ]
-            [ intersect drop ]
-            [ intersects? drop ]
-            [ diff drop ]
-            [ set= drop ]
-            [ subset? drop ]
+            [ 3 [ union ] do-times ]
+            [ 5 [ intersect ] do-times ]
+            [ 100,000 [ intersects? ] do-times ]
+            [ 3 [ diff ] do-times ]
+            [ 50 [ set= ] do-times ]
+            [ 25 [ subset? ] do-times ]
         } 2cleave
     ] each-combination ;
 
 : hash-sets-benchmark ( -- )
-    make-sets bench-sets ;
+    test-sets bench-sets ;
 
 MAIN: hash-sets-benchmark