msgpack 0.6.0-x86-mswin32-60

Sign up to get free protection for your applications and to get access to all the features.
Files changed (76) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +20 -0
  3. data/.travis.yml +26 -0
  4. data/ChangeLog +129 -0
  5. data/Dockerfile +62 -0
  6. data/LICENSE +177 -0
  7. data/README.rdoc +141 -0
  8. data/Rakefile +68 -0
  9. data/bench/pack.rb +23 -0
  10. data/bench/pack_log.rb +33 -0
  11. data/bench/pack_log_long.rb +65 -0
  12. data/bench/run.sh +14 -0
  13. data/bench/run_long.sh +35 -0
  14. data/bench/unpack.rb +21 -0
  15. data/bench/unpack_log.rb +34 -0
  16. data/bench/unpack_log_long.rb +67 -0
  17. data/doclib/msgpack.rb +77 -0
  18. data/doclib/msgpack/buffer.rb +193 -0
  19. data/doclib/msgpack/core_ext.rb +101 -0
  20. data/doclib/msgpack/error.rb +14 -0
  21. data/doclib/msgpack/packer.rb +134 -0
  22. data/doclib/msgpack/unpacker.rb +146 -0
  23. data/ext/java/org/msgpack/jruby/Buffer.java +221 -0
  24. data/ext/java/org/msgpack/jruby/Decoder.java +201 -0
  25. data/ext/java/org/msgpack/jruby/Encoder.java +308 -0
  26. data/ext/java/org/msgpack/jruby/ExtensionValue.java +136 -0
  27. data/ext/java/org/msgpack/jruby/MessagePackLibrary.java +107 -0
  28. data/ext/java/org/msgpack/jruby/Packer.java +78 -0
  29. data/ext/java/org/msgpack/jruby/Types.java +37 -0
  30. data/ext/java/org/msgpack/jruby/Unpacker.java +170 -0
  31. data/ext/msgpack/buffer.c +695 -0
  32. data/ext/msgpack/buffer.h +447 -0
  33. data/ext/msgpack/buffer_class.c +507 -0
  34. data/ext/msgpack/buffer_class.h +32 -0
  35. data/ext/msgpack/compat.h +114 -0
  36. data/ext/msgpack/core_ext.c +129 -0
  37. data/ext/msgpack/core_ext.h +26 -0
  38. data/ext/msgpack/extconf.rb +30 -0
  39. data/ext/msgpack/packer.c +168 -0
  40. data/ext/msgpack/packer.h +441 -0
  41. data/ext/msgpack/packer_class.c +302 -0
  42. data/ext/msgpack/packer_class.h +30 -0
  43. data/ext/msgpack/rbinit.c +33 -0
  44. data/ext/msgpack/rmem.c +94 -0
  45. data/ext/msgpack/rmem.h +109 -0
  46. data/ext/msgpack/sysdep.h +115 -0
  47. data/ext/msgpack/sysdep_endian.h +50 -0
  48. data/ext/msgpack/sysdep_types.h +46 -0
  49. data/ext/msgpack/unpacker.c +771 -0
  50. data/ext/msgpack/unpacker.h +122 -0
  51. data/ext/msgpack/unpacker_class.c +405 -0
  52. data/ext/msgpack/unpacker_class.h +32 -0
  53. data/lib/msgpack.rb +13 -0
  54. data/lib/msgpack/version.rb +3 -0
  55. data/msgpack.gemspec +31 -0
  56. data/msgpack.org.md +46 -0
  57. data/spec/cases.json +1 -0
  58. data/spec/cases.msg +0 -0
  59. data/spec/cases_compact.msg +0 -0
  60. data/spec/cases_spec.rb +39 -0
  61. data/spec/cruby/buffer_io_spec.rb +256 -0
  62. data/spec/cruby/buffer_packer.rb +29 -0
  63. data/spec/cruby/buffer_spec.rb +572 -0
  64. data/spec/cruby/buffer_unpacker.rb +19 -0
  65. data/spec/cruby/packer_spec.rb +120 -0
  66. data/spec/cruby/unpacker_spec.rb +305 -0
  67. data/spec/format_spec.rb +282 -0
  68. data/spec/jruby/benchmarks/shootout_bm.rb +73 -0
  69. data/spec/jruby/benchmarks/symbolize_keys_bm.rb +25 -0
  70. data/spec/jruby/msgpack/unpacker_spec.rb +290 -0
  71. data/spec/jruby/msgpack_spec.rb +142 -0
  72. data/spec/pack_spec.rb +67 -0
  73. data/spec/random_compat.rb +24 -0
  74. data/spec/spec_helper.rb +27 -0
  75. data/spec/unpack_spec.rb +60 -0
  76. metadata +208 -0
@@ -0,0 +1,68 @@
1
+
2
+ require 'bundler'
3
+ Bundler::GemHelper.install_tasks
4
+
5
+ require 'fileutils'
6
+
7
+ require 'rspec/core'
8
+ require 'rspec/core/rake_task'
9
+ require 'yard'
10
+
11
+ task :spec => :compile
12
+
13
+ desc 'Run RSpec code examples and measure coverage'
14
+ task :coverage do |t|
15
+ ENV['SIMPLE_COV'] = '1'
16
+ Rake::Task["spec"].invoke
17
+ end
18
+
19
+ desc 'Generate YARD document'
20
+ YARD::Rake::YardocTask.new(:doc) do |t|
21
+ t.files = ['lib/msgpack/version.rb','doclib/**/*.rb']
22
+ t.options = []
23
+ t.options << '--debug' << '--verbose' if $trace
24
+ end
25
+
26
+ spec = eval File.read("msgpack.gemspec")
27
+
28
+ if RUBY_PLATFORM =~ /java/
29
+ require 'rake/javaextensiontask'
30
+
31
+ Rake::JavaExtensionTask.new('msgpack', spec) do |ext|
32
+ ext.ext_dir = 'ext/java'
33
+ jruby_home = RbConfig::CONFIG['prefix']
34
+ jars = ["#{jruby_home}/lib/jruby.jar"]
35
+ ext.classpath = jars.map { |x| File.expand_path(x) }.join(':')
36
+ ext.lib_dir = File.join(*['lib', 'msgpack', ENV['FAT_DIR']].compact)
37
+ ext.source_version = '1.6'
38
+ ext.target_version = '1.6'
39
+ end
40
+
41
+ RSpec::Core::RakeTask.new(:spec) do |t|
42
+ t.rspec_opts = ["-c", "-f progress"]
43
+ t.rspec_opts << "-Ilib"
44
+ t.pattern = 'spec/{,jruby/}*_spec.rb'
45
+ t.verbose = true
46
+ end
47
+
48
+ else
49
+ require 'rake/extensiontask'
50
+
51
+ Rake::ExtensionTask.new('msgpack', spec) do |ext|
52
+ ext.ext_dir = 'ext/msgpack'
53
+ ext.cross_compile = true
54
+ ext.lib_dir = File.join(*['lib', 'msgpack', ENV['FAT_DIR']].compact)
55
+ ext.cross_platform = ['i386-mswin32-60', 'x64-mingw32']
56
+ end
57
+
58
+ RSpec::Core::RakeTask.new(:spec) do |t|
59
+ t.rspec_opts = ["-c", "-f progress"]
60
+ t.rspec_opts << "-Ilib"
61
+ t.pattern = 'spec/{,cruby/}*_spec.rb'
62
+ t.verbose = true
63
+ end
64
+ end
65
+
66
+ CLEAN.include('lib/msgpack/msgpack.*')
67
+
68
+ task :default => [:spec, :build, :doc]
@@ -0,0 +1,23 @@
1
+ require 'viiite'
2
+ require 'msgpack'
3
+
4
+ data = { 'hello' => 'world', 'nested' => ['structure', {value: 42}] }
5
+ data_sym = { hello: 'world', nested: ['structure', {value: 42}] }
6
+
7
+ data = MessagePack.pack(:hello => 'world', :nested => ['structure', {:value => 42}])
8
+
9
+ Viiite.bench do |b|
10
+ b.range_over([10_000, 100_000, 1000_000], :runs) do |runs|
11
+ b.report(:strings) do
12
+ runs.times do
13
+ MessagePack.pack(data)
14
+ end
15
+ end
16
+
17
+ b.report(:symbols) do
18
+ runs.times do
19
+ MessagePack.pack(data_sym)
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,33 @@
1
+ require 'viiite'
2
+ require 'msgpack'
3
+
4
+ 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)"' }
5
+ data_structure = {
6
+ 'remote_host' => '127.0.0.1',
7
+ 'remote_user' => '-',
8
+ 'date' => '10/Oct/2000:13:55:36 -0700',
9
+ 'request' => 'GET /apache_pb.gif HTTP/1.0',
10
+ 'method' => 'GET',
11
+ 'path' => '/apache_pb.gif',
12
+ 'protocol' => 'HTTP/1.0',
13
+ 'status' => 200,
14
+ 'bytes' => 2326,
15
+ 'referer' => 'http://www.example.com/start.html',
16
+ 'agent' => 'Mozilla/4.08 [en] (Win98; I ;Nav)',
17
+ }
18
+
19
+ Viiite.bench do |b|
20
+ b.range_over([10_000, 100_000, 1000_000], :runs) do |runs|
21
+ b.report(:plain) do
22
+ runs.times do
23
+ MessagePack.pack(data_plain)
24
+ end
25
+ end
26
+
27
+ b.report(:structure) do
28
+ runs.times do
29
+ MessagePack.pack(data_structure)
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,65 @@
1
+ # viiite report --regroup bench,threads bench/pack_log_long.rb
2
+
3
+ require 'viiite'
4
+ require 'msgpack'
5
+
6
+ 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)"' }
7
+ data_structure = {
8
+ 'remote_host' => '127.0.0.1',
9
+ 'remote_user' => '-',
10
+ 'date' => '10/Oct/2000:13:55:36 -0700',
11
+ 'request' => 'GET /apache_pb.gif HTTP/1.0',
12
+ 'method' => 'GET',
13
+ 'path' => '/apache_pb.gif',
14
+ 'protocol' => 'HTTP/1.0',
15
+ 'status' => 200,
16
+ 'bytes' => 2326,
17
+ 'referer' => 'http://www.example.com/start.html',
18
+ 'agent' => 'Mozilla/4.08 [en] (Win98; I ;Nav)',
19
+ }
20
+
21
+ seconds = 3600 # 1 hour
22
+
23
+ Viiite.bench do |b|
24
+ b.range_over([1, 2, 4, 8, 16], :threads) do |threads|
25
+ b.report(:plain) do
26
+ ths = []
27
+ end_at = Time.now + seconds
28
+ threads.times do
29
+ t = Thread.new do
30
+ packs = 0
31
+ while Time.now < end_at
32
+ 10000.times do
33
+ MessagePack.pack(data_plain)
34
+ end
35
+ packs += 10000
36
+ end
37
+ packs
38
+ end
39
+ ths.push t
40
+ end
41
+ sum = ths.reduce(0){|r,t| r + t.value }
42
+ puts "MessagePack.pack, plain, #{threads} threads: #{sum} times, #{sum / seconds} times/second."
43
+ end
44
+
45
+ b.report(:structure) do
46
+ ths = []
47
+ end_at = Time.now + seconds
48
+ threads.times do
49
+ t = Thread.new do
50
+ packs = 0
51
+ while Time.now < end_at
52
+ 10000.times do
53
+ MessagePack.pack(data_structure)
54
+ end
55
+ packs += 10000
56
+ end
57
+ packs
58
+ end
59
+ ths.push t
60
+ end
61
+ sum = ths.reduce(0){|r,t| r + t.value }
62
+ puts "MessagePack.pack, structured, #{threads} threads: #{sum} times, #{sum / seconds} times/second."
63
+ end
64
+ end
65
+ end
@@ -0,0 +1,14 @@
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
@@ -0,0 +1,35 @@
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
+
@@ -0,0 +1,21 @@
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
@@ -0,0 +1,34 @@
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
@@ -0,0 +1,67 @@
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
@@ -0,0 +1,77 @@
1
+
2
+ module MessagePack
3
+ #
4
+ # Serializes an object into an IO or String.
5
+ #
6
+ # @overload dump(obj, options={})
7
+ # @param obj [Object] object to be serialized
8
+ # @param options [Hash]
9
+ # @return [String] serialized data
10
+ #
11
+ # @overload dump(obj, io, options={})
12
+ # @param obj [Object] object to be serialized
13
+ # @param io [IO]
14
+ # @param options [Hash]
15
+ # @return [IO]
16
+ #
17
+ # See Packer#initialize for supported options.
18
+ #
19
+ def self.dump(obj)
20
+ end
21
+
22
+ #
23
+ # Serializes an object into an IO or String. Alias of dump.
24
+ #
25
+ # @overload pack(obj, options={})
26
+ # @param obj [Object] object to be serialized
27
+ # @param options [Hash]
28
+ # @return [String] serialized data
29
+ #
30
+ # @overload pack(obj, io, options={})
31
+ # @param obj [Object] object to be serialized
32
+ # @param io [IO]
33
+ # @param options [Hash]
34
+ # @return [IO]
35
+ #
36
+ # See Packer#initialize for supported options.
37
+ #
38
+ def self.pack(obj)
39
+ end
40
+
41
+ #
42
+ # Deserializes an object from an IO or String.
43
+ #
44
+ # @overload load(string, options={})
45
+ # @param string [String] data to deserialize
46
+ # @param options [Hash]
47
+ #
48
+ # @overload load(io, options={})
49
+ # @param io [IO]
50
+ # @param options [Hash]
51
+ #
52
+ # @return [Object] deserialized object
53
+ #
54
+ # See Unpacker#initialize for supported options.
55
+ #
56
+ def self.load(src, options={})
57
+ end
58
+
59
+ #
60
+ # Deserializes an object from an IO or String. Alias of load.
61
+ #
62
+ # @overload unpack(string, options={})
63
+ # @param string [String] data to deserialize
64
+ # @param options [Hash]
65
+ #
66
+ # @overload unpack(io, options={})
67
+ # @param io [IO]
68
+ # @param options [Hash]
69
+ #
70
+ # @return [Object] deserialized object
71
+ #
72
+ # See Unpacker#initialize for supported options.
73
+ #
74
+ def self.unpack(src, options={})
75
+ end
76
+ end
77
+