msgpack 1.5.2 → 1.5.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ChangeLog +18 -0
- data/README.md +3 -1
- data/bench/bench.rb +78 -0
- data/ext/msgpack/buffer.c +9 -36
- data/ext/msgpack/buffer.h +9 -1
- data/ext/msgpack/buffer_class.c +6 -6
- data/ext/msgpack/compat.h +0 -99
- data/ext/msgpack/extconf.rb +9 -11
- data/ext/msgpack/packer.c +0 -24
- data/ext/msgpack/packer.h +1 -7
- data/ext/msgpack/packer_class.c +1 -1
- data/ext/msgpack/unpacker.c +56 -65
- data/ext/msgpack/unpacker.h +10 -6
- data/ext/msgpack/unpacker_class.c +2 -3
- data/lib/msgpack/version.rb +1 -1
- data/msgpack.gemspec +1 -0
- data/spec/factory_spec.rb +28 -0
- data/spec/spec_helper.rb +5 -1
- data/spec/unpacker_spec.rb +12 -0
- metadata +18 -13
- data/bench/pack.rb +0 -23
- data/bench/pack_log.rb +0 -33
- data/bench/pack_log_long.rb +0 -65
- data/bench/pack_symbols.rb +0 -28
- data/bench/run.sh +0 -14
- data/bench/run_long.sh +0 -35
- data/bench/run_symbols.sh +0 -26
- data/bench/unpack.rb +0 -21
- data/bench/unpack_log.rb +0 -34
- data/bench/unpack_log_long.rb +0 -67
data/bench/run.sh
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
#!/bin/sh
|
2
|
-
|
3
|
-
# prerequisites
|
4
|
-
# $ rbenv shell 2.2.1 (or jruby-x.x.x or ...)
|
5
|
-
# $ rake install
|
6
|
-
|
7
|
-
echo "pack"
|
8
|
-
viiite report --regroup bench,runs bench/pack.rb
|
9
|
-
echo "unpack"
|
10
|
-
viiite report --regroup bench,runs bench/unpack.rb
|
11
|
-
echo "pack log"
|
12
|
-
viiite report --regroup bench,runs bench/pack_log.rb
|
13
|
-
echo "unpack log"
|
14
|
-
viiite report --regroup bench,runs bench/unpack_log.rb
|
data/bench/run_long.sh
DELETED
@@ -1,35 +0,0 @@
|
|
1
|
-
#!/bin/sh
|
2
|
-
|
3
|
-
# prerequisites
|
4
|
-
# $ sudo apt-get install sysstat
|
5
|
-
# $ rbenv shell 2.2.1 (or jruby-x.x.x or ...)
|
6
|
-
# $ rake install
|
7
|
-
|
8
|
-
# 60 * 600 : 60*60 * 5[threads] * 2[bench]
|
9
|
-
|
10
|
-
ruby -v
|
11
|
-
|
12
|
-
echo "pack log long"
|
13
|
-
viiite report --regroup bench,threads bench/pack_log_long.rb &
|
14
|
-
sar -o pack_log_long.sar -r 60 600 > /dev/null 2>&1 &
|
15
|
-
|
16
|
-
declare -i i=0
|
17
|
-
while [ $i -lt 600 ]; do
|
18
|
-
ps auxww | grep ruby | grep -v grep | awk '{print $5,$6;}' >> pack_log_long.mem.txt
|
19
|
-
i=i+1
|
20
|
-
sleep 60
|
21
|
-
done
|
22
|
-
|
23
|
-
sleep 120 # cool down
|
24
|
-
|
25
|
-
echo "unpack log long"
|
26
|
-
viiite report --regroup bench,threads bench/unpack_log_long.rb &
|
27
|
-
sar -o unpack_log_long.sar -r 60 600 > /dev/null 2>&1 &
|
28
|
-
|
29
|
-
i=0
|
30
|
-
while [ $i -lt 600 ]; do
|
31
|
-
ps auxww | grep ruby | grep -v grep | awk '{print $5,$6;}' >> pack_log_long.mem.txt
|
32
|
-
i=i+1
|
33
|
-
sleep 60
|
34
|
-
done
|
35
|
-
|
data/bench/run_symbols.sh
DELETED
@@ -1,26 +0,0 @@
|
|
1
|
-
#!/bin/sh
|
2
|
-
|
3
|
-
# so master and this branch have the benchmark file in any case
|
4
|
-
cp bench/pack_symbols.rb bench/pack_symbols_tmp.rb
|
5
|
-
|
6
|
-
benchmark=""
|
7
|
-
current_branch=`git rev-parse --abbrev-ref HEAD`
|
8
|
-
|
9
|
-
for branch in master $current_branch; do
|
10
|
-
echo "Testing branch $branch"
|
11
|
-
git checkout $branch
|
12
|
-
|
13
|
-
echo "Installing gem..."
|
14
|
-
rake install
|
15
|
-
|
16
|
-
echo "Running benchmark..."
|
17
|
-
if [ "$benchmark" ]; then
|
18
|
-
benchmark+=$'\n'
|
19
|
-
fi
|
20
|
-
benchmark+=$(viiite run bench/pack_symbols_tmp.rb)
|
21
|
-
echo
|
22
|
-
done
|
23
|
-
|
24
|
-
rm bench/pack_symbols_tmp.rb
|
25
|
-
|
26
|
-
echo "$benchmark" | viiite report --regroup bench,reg_type,count,branch
|
data/bench/unpack.rb
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
require 'viiite'
|
2
|
-
require 'msgpack'
|
3
|
-
|
4
|
-
data = MessagePack.pack(:hello => 'world', :nested => ['structure', {:value => 42}])
|
5
|
-
|
6
|
-
Viiite.bench do |b|
|
7
|
-
b.range_over([10_000, 100_000, 1000_000], :runs) do |runs|
|
8
|
-
b.report(:strings) do
|
9
|
-
runs.times do
|
10
|
-
MessagePack.unpack(data)
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
b.report(:symbols) do
|
15
|
-
options = {:symbolize_keys => true}
|
16
|
-
runs.times do
|
17
|
-
MessagePack.unpack(data, options)
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
data/bench/unpack_log.rb
DELETED
@@ -1,34 +0,0 @@
|
|
1
|
-
require 'viiite'
|
2
|
-
require 'msgpack'
|
3
|
-
|
4
|
-
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)"' })
|
5
|
-
|
6
|
-
data_structure = MessagePack.pack({
|
7
|
-
'remote_host' => '127.0.0.1',
|
8
|
-
'remote_user' => '-',
|
9
|
-
'date' => '10/Oct/2000:13:55:36 -0700',
|
10
|
-
'request' => 'GET /apache_pb.gif HTTP/1.0',
|
11
|
-
'method' => 'GET',
|
12
|
-
'path' => '/apache_pb.gif',
|
13
|
-
'protocol' => 'HTTP/1.0',
|
14
|
-
'status' => 200,
|
15
|
-
'bytes' => 2326,
|
16
|
-
'referer' => 'http://www.example.com/start.html',
|
17
|
-
'agent' => 'Mozilla/4.08 [en] (Win98; I ;Nav)',
|
18
|
-
})
|
19
|
-
|
20
|
-
Viiite.bench do |b|
|
21
|
-
b.range_over([10_000, 100_000, 1000_000], :runs) do |runs|
|
22
|
-
b.report(:plain) do
|
23
|
-
runs.times do
|
24
|
-
MessagePack.unpack(data_plain)
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
b.report(:structure) do
|
29
|
-
runs.times do
|
30
|
-
MessagePack.unpack(data_structure)
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
data/bench/unpack_log_long.rb
DELETED
@@ -1,67 +0,0 @@
|
|
1
|
-
# viiite report --regroup bench,threads bench/pack_log_long.rb
|
2
|
-
|
3
|
-
require 'viiite'
|
4
|
-
require 'msgpack'
|
5
|
-
|
6
|
-
data_plain = MessagePack.pack({
|
7
|
-
'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)"'
|
8
|
-
})
|
9
|
-
data_structure = MessagePack.pack({
|
10
|
-
'remote_host' => '127.0.0.1',
|
11
|
-
'remote_user' => '-',
|
12
|
-
'date' => '10/Oct/2000:13:55:36 -0700',
|
13
|
-
'request' => 'GET /apache_pb.gif HTTP/1.0',
|
14
|
-
'method' => 'GET',
|
15
|
-
'path' => '/apache_pb.gif',
|
16
|
-
'protocol' => 'HTTP/1.0',
|
17
|
-
'status' => 200,
|
18
|
-
'bytes' => 2326,
|
19
|
-
'referer' => 'http://www.example.com/start.html',
|
20
|
-
'agent' => 'Mozilla/4.08 [en] (Win98; I ;Nav)',
|
21
|
-
})
|
22
|
-
|
23
|
-
seconds = 3600 # 1 hour
|
24
|
-
|
25
|
-
Viiite.bench do |b|
|
26
|
-
b.range_over([1, 2, 4, 8, 16], :threads) do |threads|
|
27
|
-
b.report(:plain) do
|
28
|
-
ths = []
|
29
|
-
end_at = Time.now + seconds
|
30
|
-
threads.times do
|
31
|
-
t = Thread.new do
|
32
|
-
packs = 0
|
33
|
-
while Time.now < end_at
|
34
|
-
10000.times do
|
35
|
-
MessagePack.unpack(data_plain)
|
36
|
-
end
|
37
|
-
packs += 10000
|
38
|
-
end
|
39
|
-
packs
|
40
|
-
end
|
41
|
-
ths.push t
|
42
|
-
end
|
43
|
-
sum = ths.reduce(0){|r,t| r + t.value }
|
44
|
-
puts "MessagePack.unpack, plain, #{threads} threads: #{sum} times, #{sum / seconds} times/second."
|
45
|
-
end
|
46
|
-
|
47
|
-
b.report(:structure) do
|
48
|
-
ths = []
|
49
|
-
end_at = Time.now + seconds
|
50
|
-
threads.times do
|
51
|
-
t = Thread.new do
|
52
|
-
packs = 0
|
53
|
-
while Time.now < end_at
|
54
|
-
10000.times do
|
55
|
-
MessagePack.unpack(data_structure)
|
56
|
-
end
|
57
|
-
packs += 10000
|
58
|
-
end
|
59
|
-
packs
|
60
|
-
end
|
61
|
-
ths.push t
|
62
|
-
end
|
63
|
-
sum = ths.reduce(0){|r,t| r + t.value }
|
64
|
-
puts "MessagePack.unpack, structured, #{threads} threads: #{sum} times, #{sum / seconds} times/second."
|
65
|
-
end
|
66
|
-
end
|
67
|
-
end
|