Skip to content

Commit 377ed08

Browse files
authored
Merge pull request #2 from SpringMT/add-decompress-benchmarks
Add decompress benchmarks
2 parents d8d383e + aad6b0d commit 377ed08

File tree

9 files changed

+41
-13
lines changed

9 files changed

+41
-13
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
*.a
1414
mkmf.log
1515
vendor/
16+
*.gem
1617

1718
# rspec failure tracking
1819
.rspec_status

LICENSE-zstd

Lines changed: 0 additions & 1 deletion
This file was deleted.

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ Ruby binding for zstd(Zstandard - Fast real-time compression algorithm)
66

77
See https://github.com/facebook/zstd
88

9+
Fork from https://github.com/jarredholman/ruby-zstd.
10+
911
## Zstd version
1012
v1.1.2 (https://github.com/facebook/zstd/releases/tag/v1.1.2)
1113

Rakefile

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
require "bundler/gem_tasks"
22
require "rspec/core/rake_task"
3+
require 'fileutils'
34

45
RSpec::Core::RakeTask.new(:spec)
56

@@ -14,5 +15,8 @@ end
1415

1516
task :default => [:clobber, :compile, :spec]
1617

17-
#task :sync
18-
18+
desc 'Sync zstd libs dirs to ext/zstdruby/libzstd'
19+
task :zstd_update do
20+
FileUtils.rm_r('ext/zstdruby/libzstd')
21+
FileUtils.cp_r('zstd/lib', 'ext/zstdruby/libzstd')
22+
end

benchmarks/Gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ gem 'benchmark-ips'
44
gem 'snappy'
55
gem 'ruby-xz'
66
gem 'lz4-ruby'
7-
7+
#gem 'zstd', github: 'jarredholman/ruby-zstd', branch: 'master'

benchmarks/README.md

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1+
12
# sample data
23
FROM http://www.cl.ecei.tohoku.ac.jp/~matsuda/LRE_corpus/
34

45
# usage
56

6-
77
```
8-
bundle exec ruby compress.rb city
8+
bundle exec ruby compress.rb city.json
9+
bundle exec ruby decompress.rb city.json
910
```
1011

1112

@@ -53,3 +54,22 @@ total 2712
5354
-rw-r--r-- 1 makoto staff 238K 2 5 16:08 city.json.zstd
5455
```
5556

57+
## Decompression
58+
### Performance
59+
60+
```
61+
Warming up --------------------------------------
62+
snappy 59.000 i/100ms
63+
gzip 19.000 i/100ms
64+
xz 5.000 i/100ms
65+
lz4 51.000 i/100ms
66+
zstd 31.000 i/100ms
67+
Calculating -------------------------------------
68+
snappy 583.211 (± 9.1%) i/s - 2.891k in 5.002226s
69+
gzip 195.468 (±10.7%) i/s - 969.000 in 5.028082s
70+
xz 53.501 (± 7.5%) i/s - 270.000 in 5.083982s
71+
lz4 511.275 (± 9.4%) i/s - 2.550k in 5.036539s
72+
zstd 302.455 (±16.5%) i/s - 1.488k in 5.070354s
73+
```
74+
75+

benchmarks/compress.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
require 'benchmark/ips'
22

3-
$LOAD_PATH.unshift "../lib"
3+
$LOAD_PATH.unshift '../lib'
44

55
require 'json'
66
require 'snappy'

benchmarks/decompress.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
require 'benchmark/ips'
22

3+
$LOAD_PATH.unshift '../lib'
4+
35
require 'json'
46
require 'snappy'
57
require 'zlib'
68
require 'xz'
79
require 'lz4-ruby'
10+
require 'zstd-ruby'
811

912
sample_file_name = ARGV[0]
1013

@@ -30,5 +33,4 @@
3033
x.report("zstd") do
3134
Zstd.decompress IO.read("./results/#{sample_file_name}.zstd")
3235
end
33-
3436
end

zstd-ruby.gemspec

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,29 +9,29 @@ Gem::Specification.new do |spec|
99
spec.authors = ["SpringMT"]
1010
spec.email = ["[email protected]"]
1111

12-
spec.summary = %q{Write a short summary, because Rubygems requires one.}
13-
spec.description = %q{ Write a longer description or delete this line.}
12+
spec.summary = %q{Ruby binding for zstd(Zstandard - Fast real-time compression algorithm)}
13+
spec.description = %q{Ruby binding for zstd(Zstandard - Fast real-time compression algorithm). See https://github.com/facebook/zstd}
1414
spec.homepage = "https://github.com/SpringMT/zstd-ruby"
1515
spec.license = "MIT"
1616

1717
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
1818
# to allow pushing to a single host or delete this section to allow pushing to any host.
1919
if spec.respond_to?(:metadata)
20-
spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com'"
20+
spec.metadata['allowed_push_host'] = "Set to 'http://mygemserver.com'"
2121
else
2222
raise "RubyGems 2.0 or newer is required to protect against " \
2323
"public gem pushes."
2424
end
2525

2626
spec.files = `git ls-files -z`.split("\x0").reject do |f|
27-
f.match(%r{^(test|spec|features)/})
27+
f.match(%r{^(test|spec|features|benchmarks|zstd)/})
2828
end
2929
spec.bindir = "exe"
3030
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
3131
spec.require_paths = ["lib"]
3232

3333
spec.add_development_dependency "bundler", "~> 1.14"
3434
spec.add_development_dependency "rake", "~> 10.0"
35-
spec.add_development_dependency "rake-compiler"
35+
spec.add_development_dependency "rake-compiler", '~> 1'
3636
spec.add_development_dependency "rspec", "~> 3.0"
3737
end

0 commit comments

Comments
 (0)