]> gitweb.factorcode.org Git - factor.git/commitdiff
benchmark.parse-ratio: adding a ratio parse benchmark.
authorJohn Benediktsson <mrjbq7@gmail.com>
Thu, 28 Mar 2013 21:31:45 +0000 (14:31 -0700)
committerJohn Benediktsson <mrjbq7@gmail.com>
Thu, 28 Mar 2013 21:31:45 +0000 (14:31 -0700)
extra/benchmark/parse-ratio/parse-ratio.factor [new file with mode: 0644]

diff --git a/extra/benchmark/parse-ratio/parse-ratio.factor b/extra/benchmark/parse-ratio/parse-ratio.factor
new file mode 100644 (file)
index 0000000..79b4b32
--- /dev/null
@@ -0,0 +1,15 @@
+USING: kernel literals math.parser math.vectors random
+sequences ;
+IN: benchmark.parse-ratio
+
+CONSTANT: test-ratios $[
+    200,000 100,000 random-integers
+    200,000 1,000 random-integers 1 v+n v/
+]
+
+: parse-ratio-benchmark ( -- )
+    test-ratios [
+        [ number>string string>number ] [ assert= ] bi
+    ] each ;
+
+MAIN: parse-ratio-benchmark