Permalink
Browse files

added benchmark for serializing symbols

  • Loading branch information...
1 parent dd9c536 commit 5d244ae34e28d4973868c6d4be077569b0a954c6 @christopheraue christopheraue committed with tagomoris May 13, 2016
Showing with 54 additions and 0 deletions.
  1. +28 −0 bench/pack_symbols.rb
  2. +26 −0 bench/run_symbols.sh
View
@@ -0,0 +1,28 @@
+require 'viiite'
+require 'msgpack'
+
+data = :symbol
+
+Viiite.bench do |b|
+ b.variation_point :branch, `git rev-parse --abbrev-ref HEAD`
+
+ b.range_over([:symbol, :none], :reg_type) do |reg_type|
+ packer = MessagePack::Packer.new
+ packer.register_type(0x00, Symbol, :to_msgpack_ext) if reg_type == :symbol
+
+ b.range_over([100_000, 1_000_000, 10_000_000], :count) do |count|
+ packer.clear
+ b.report(:multi_run) do
+ count.times do
+ packer.pack(data)
+ end
+ end
+
+ packer.clear
+ items_data = [].fill(data, 0, count)
+ b.report(:large_run) do
+ packer.pack(items_data)
+ end
+ end
+ end
+end
View
@@ -0,0 +1,26 @@
+#!/bin/sh
+
+# so master and this branch have the benchmark file in any case
+cp bench/pack_symbols.rb bench/pack_symbols_tmp.rb
+
+benchmark=""
+current_branch=`git rev-parse --abbrev-ref HEAD`
+
+for branch in master $current_branch; do
+ echo "Testing branch $branch"
+ git checkout $branch
+
+ echo "Installing gem..."
+ rake install
+
+ echo "Running benchmark..."
+ if [ "$benchmark" ]; then
+ benchmark+=$'\n'
+ fi
+ benchmark+=$(viiite run bench/pack_symbols_tmp.rb)
+ echo
+done
+
+rm bench/pack_symbols_tmp.rb
+
+echo "$benchmark" | viiite report --regroup bench,reg_type,count,branch

0 comments on commit 5d244ae

Please sign in to comment.