]> gitweb.factorcode.org Git - factor.git/commitdiff
benchmark.msgpack: adding msgpack benchmark.
authorJohn Benediktsson <mrjbq7@gmail.com>
Mon, 25 Nov 2013 18:43:42 +0000 (10:43 -0800)
committerJohn Benediktsson <mrjbq7@gmail.com>
Mon, 25 Nov 2013 18:43:42 +0000 (10:43 -0800)
extra/benchmark/msgpack/msgpack.factor [new file with mode: 0644]

diff --git a/extra/benchmark/msgpack/msgpack.factor b/extra/benchmark/msgpack/msgpack.factor
new file mode 100644 (file)
index 0000000..b0b82c9
--- /dev/null
@@ -0,0 +1,15 @@
+USING: kernel math math.constants msgpack sequences ;
+IN: benchmark.msgpack
+
+: pack-sum ( seq -- n )
+    0 [ >msgpack msgpack> + ] reduce ;
+
+: pack-sum-lengths ( seq -- n )
+    0 [ >msgpack msgpack> length + ] reduce ;
+
+: msgpack-benchmark ( -- )
+    500,000 iota pack-sum 124,999,750,000 assert=
+    500,000 "hello" <repetition> pack-sum-lengths 2,500,000 assert=
+    500,000 pi <repetition> pack-sum 0x1.7f7ec53a9f04ap20 assert= ;
+
+MAIN: msgpack-benchmark