]> gitweb.factorcode.org Git - factor.git/commitdiff
benchmark.splitting: adding a splitting benchmark.
authorJohn Benediktsson <mrjbq7@gmail.com>
Wed, 27 Mar 2013 23:12:08 +0000 (16:12 -0700)
committerJohn Benediktsson <mrjbq7@gmail.com>
Wed, 27 Mar 2013 23:12:08 +0000 (16:12 -0700)
extra/benchmark/splitting/splitting.factor [new file with mode: 0644]

diff --git a/extra/benchmark/splitting/splitting.factor b/extra/benchmark/splitting/splitting.factor
new file mode 100644 (file)
index 0000000..6a9104f
--- /dev/null
@@ -0,0 +1,15 @@
+USING: kernel math sequences splitting ;
+IN: benchmark.splitting
+
+: test-data ( -- seq seps ) 
+    1000 iota dup [ 10 /i zero? ] filter ; ! not inline to prevent type inference
+
+: splitting-benchmark ( -- )
+    test-data 1,000 [
+        over [ even? ] split-when drop
+        over [ even? ] split-when-slice drop
+        2dup split drop
+        2dup split* drop
+    ] times 2drop ;
+
+MAIN: splitting-benchmark