Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding benchmark scripts to run on both of CRuby and JRuby
* Benchmark scripts are not complete yet. To be added are: * large array which contain many hash objects * benchmark which runs on many threads * long running benchmark / test with memory usage monitoring * Add viiita on Gemfile to bundle it in development of msgpack-ruby itself
- Loading branch information
Showing
6 changed files
with
124 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -1,3 +1,4 @@ | |||
source 'https://rubygems.org/' | source 'https://rubygems.org/' | ||
|
|
||
gemspec | gemspec | ||
gem "viiite" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,23 @@ | |||
require 'viiite' | |||
require 'msgpack' | |||
|
|||
data = { 'hello' => 'world', 'nested' => ['structure', {value: 42}] } | |||
data_sym = { hello: 'world', nested: ['structure', {value: 42}] } | |||
|
|||
data = MessagePack.pack(:hello => 'world', :nested => ['structure', {:value => 42}]) | |||
|
|||
Viiite.bench do |b| | |||
b.range_over([10_000, 100_000, 1000_000], :runs) do |runs| | |||
b.report(:strings) do | |||
runs.times do | |||
MessagePack.pack(data) | |||
end | |||
end | |||
|
|||
b.report(:symbols) do | |||
runs.times do | |||
MessagePack.pack(data_sym) | |||
end | |||
end | |||
end | |||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,33 @@ | |||
require 'viiite' | |||
require 'msgpack' | |||
|
|||
data_plain = { 'message' => '127.0.0.1 - - [10/Oct/2000:13:55:36 -0700] "GET /apache_pb.gif HTTP/1.0" 200 2326 "http://www.example.com/start.html" "Mozilla/4.08 [en] (Win98; I ;Nav)"' } | |||
data_structure = { | |||
'remote_host' => '127.0.0.1', | |||
'remote_user' => '-', | |||
'date' => '10/Oct/2000:13:55:36 -0700', | |||
'request' => 'GET /apache_pb.gif HTTP/1.0', | |||
'method' => 'GET', | |||
'path' => '/apache_pb.gif', | |||
'protocol' => 'HTTP/1.0', | |||
'status' => 200, | |||
'bytes' => 2326, | |||
'referer' => 'http://www.example.com/start.html', | |||
'agent' => 'Mozilla/4.08 [en] (Win98; I ;Nav)', | |||
} | |||
|
|||
Viiite.bench do |b| | |||
b.range_over([10_000, 100_000, 1000_000], :runs) do |runs| | |||
b.report(:plain) do | |||
runs.times do | |||
MessagePack.pack(data_plain) | |||
end | |||
end | |||
|
|||
b.report(:structure) do | |||
runs.times do | |||
MessagePack.pack(data_structure) | |||
end | |||
end | |||
end | |||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,12 @@ | |||
#!/bin/sh | |||
|
|||
# execute `rbenv shell 2.2.1`(or jruby-x.x.x or ...) and `bundle install` | |||
|
|||
echo "pack" | |||
viiite report --regroup bench,runs bench/pack.rb | |||
echo "unpack" | |||
viiite report --regroup bench,runs bench/unpack.rb | |||
echo "pack log" | |||
viiite report --regroup bench,runs bench/pack_log.rb | |||
echo "unpack log" | |||
viiite report --regroup bench,runs bench/unpack_log.rb |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,21 @@ | |||
require 'viiite' | |||
require 'msgpack' | |||
|
|||
data = MessagePack.pack(:hello => 'world', :nested => ['structure', {:value => 42}]) | |||
|
|||
Viiite.bench do |b| | |||
b.range_over([10_000, 100_000, 1000_000], :runs) do |runs| | |||
b.report(:strings) do | |||
runs.times do | |||
MessagePack.unpack(data) | |||
end | |||
end | |||
|
|||
b.report(:symbols) do | |||
options = {:symbolize_keys => true} | |||
runs.times do | |||
MessagePack.unpack(data, options) | |||
end | |||
end | |||
end | |||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,34 @@ | |||
require 'viiite' | |||
require 'msgpack' | |||
|
|||
data_plain = MessagePack.pack({ 'message' => '127.0.0.1 - - [10/Oct/2000:13:55:36 -0700] "GET /apache_pb.gif HTTP/1.0" 200 2326 "http://www.example.com/start.html" "Mozilla/4.08 [en] (Win98; I ;Nav)"' }) | |||
|
|||
data_structure = MessagePack.pack({ | |||
'remote_host' => '127.0.0.1', | |||
'remote_user' => '-', | |||
'date' => '10/Oct/2000:13:55:36 -0700', | |||
'request' => 'GET /apache_pb.gif HTTP/1.0', | |||
'method' => 'GET', | |||
'path' => '/apache_pb.gif', | |||
'protocol' => 'HTTP/1.0', | |||
'status' => 200, | |||
'bytes' => 2326, | |||
'referer' => 'http://www.example.com/start.html', | |||
'agent' => 'Mozilla/4.08 [en] (Win98; I ;Nav)', | |||
}) | |||
|
|||
Viiite.bench do |b| | |||
b.range_over([10_000, 100_000, 1000_000], :runs) do |runs| | |||
b.report(:plain) do | |||
runs.times do | |||
MessagePack.unpack(data_plain) | |||
end | |||
end | |||
|
|||
b.report(:structure) do | |||
runs.times do | |||
MessagePack.unpack(data_structure) | |||
end | |||
end | |||
end | |||
end |