brotli 0.2.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (111) hide show
  1. checksums.yaml +5 -5
  2. data/.github/workflows/main.yml +34 -0
  3. data/.github/workflows/publish.yml +34 -0
  4. data/Gemfile +6 -2
  5. data/Rakefile +18 -6
  6. data/bin/before_install.sh +9 -0
  7. data/brotli.gemspec +7 -13
  8. data/ext/brotli/brotli.c +209 -11
  9. data/ext/brotli/buffer.c +1 -7
  10. data/ext/brotli/buffer.h +1 -1
  11. data/ext/brotli/extconf.rb +45 -26
  12. data/lib/brotli/version.rb +1 -1
  13. data/smoke.sh +1 -1
  14. data/test/brotli_test.rb +104 -0
  15. data/test/brotli_writer_test.rb +36 -0
  16. data/test/test_helper.rb +8 -0
  17. data/vendor/brotli/c/common/constants.c +15 -0
  18. data/vendor/brotli/c/common/constants.h +149 -6
  19. data/vendor/brotli/c/{dec/context.h → common/context.c} +91 -186
  20. data/vendor/brotli/c/common/context.h +113 -0
  21. data/vendor/brotli/c/common/dictionary.bin +0 -0
  22. data/vendor/brotli/c/common/dictionary.bin.br +0 -0
  23. data/vendor/brotli/c/common/dictionary.c +11 -2
  24. data/vendor/brotli/c/common/dictionary.h +4 -4
  25. data/vendor/brotli/c/common/platform.c +22 -0
  26. data/vendor/brotli/c/common/platform.h +594 -0
  27. data/vendor/brotli/c/common/transform.c +291 -0
  28. data/vendor/brotli/c/common/transform.h +85 -0
  29. data/vendor/brotli/c/common/version.h +8 -1
  30. data/vendor/brotli/c/dec/bit_reader.c +29 -1
  31. data/vendor/brotli/c/dec/bit_reader.h +91 -100
  32. data/vendor/brotli/c/dec/decode.c +665 -437
  33. data/vendor/brotli/c/dec/huffman.c +65 -84
  34. data/vendor/brotli/c/dec/huffman.h +67 -14
  35. data/vendor/brotli/c/dec/prefix.h +1 -20
  36. data/vendor/brotli/c/dec/state.c +32 -45
  37. data/vendor/brotli/c/dec/state.h +173 -55
  38. data/vendor/brotli/c/enc/backward_references.c +27 -16
  39. data/vendor/brotli/c/enc/backward_references.h +7 -7
  40. data/vendor/brotli/c/enc/backward_references_hq.c +155 -116
  41. data/vendor/brotli/c/enc/backward_references_hq.h +22 -23
  42. data/vendor/brotli/c/enc/backward_references_inc.h +32 -22
  43. data/vendor/brotli/c/enc/bit_cost.c +1 -1
  44. data/vendor/brotli/c/enc/bit_cost.h +5 -5
  45. data/vendor/brotli/c/enc/block_encoder_inc.h +7 -6
  46. data/vendor/brotli/c/enc/block_splitter.c +5 -6
  47. data/vendor/brotli/c/enc/block_splitter.h +1 -1
  48. data/vendor/brotli/c/enc/block_splitter_inc.h +26 -17
  49. data/vendor/brotli/c/enc/brotli_bit_stream.c +107 -123
  50. data/vendor/brotli/c/enc/brotli_bit_stream.h +19 -38
  51. data/vendor/brotli/c/enc/cluster.c +1 -1
  52. data/vendor/brotli/c/enc/cluster.h +1 -1
  53. data/vendor/brotli/c/enc/cluster_inc.h +6 -3
  54. data/vendor/brotli/c/enc/command.c +28 -0
  55. data/vendor/brotli/c/enc/command.h +52 -42
  56. data/vendor/brotli/c/enc/compress_fragment.c +21 -22
  57. data/vendor/brotli/c/enc/compress_fragment.h +1 -1
  58. data/vendor/brotli/c/enc/compress_fragment_two_pass.c +102 -69
  59. data/vendor/brotli/c/enc/compress_fragment_two_pass.h +1 -1
  60. data/vendor/brotli/c/enc/dictionary_hash.c +1827 -1101
  61. data/vendor/brotli/c/enc/dictionary_hash.h +2 -1
  62. data/vendor/brotli/c/enc/encode.c +358 -195
  63. data/vendor/brotli/c/enc/encoder_dict.c +33 -0
  64. data/vendor/brotli/c/enc/encoder_dict.h +43 -0
  65. data/vendor/brotli/c/enc/entropy_encode.c +16 -14
  66. data/vendor/brotli/c/enc/entropy_encode.h +7 -7
  67. data/vendor/brotli/c/enc/entropy_encode_static.h +3 -3
  68. data/vendor/brotli/c/enc/fast_log.c +105 -0
  69. data/vendor/brotli/c/enc/fast_log.h +20 -99
  70. data/vendor/brotli/c/enc/find_match_length.h +5 -6
  71. data/vendor/brotli/c/enc/hash.h +145 -103
  72. data/vendor/brotli/c/enc/hash_composite_inc.h +125 -0
  73. data/vendor/brotli/c/enc/hash_forgetful_chain_inc.h +93 -53
  74. data/vendor/brotli/c/enc/hash_longest_match64_inc.h +54 -53
  75. data/vendor/brotli/c/enc/hash_longest_match_inc.h +58 -54
  76. data/vendor/brotli/c/enc/hash_longest_match_quickly_inc.h +95 -63
  77. data/vendor/brotli/c/enc/hash_rolling_inc.h +212 -0
  78. data/vendor/brotli/c/enc/hash_to_binary_tree_inc.h +46 -43
  79. data/vendor/brotli/c/enc/histogram.c +9 -6
  80. data/vendor/brotli/c/enc/histogram.h +6 -3
  81. data/vendor/brotli/c/enc/histogram_inc.h +1 -1
  82. data/vendor/brotli/c/enc/literal_cost.c +5 -5
  83. data/vendor/brotli/c/enc/literal_cost.h +2 -2
  84. data/vendor/brotli/c/enc/memory.c +5 -16
  85. data/vendor/brotli/c/enc/memory.h +52 -1
  86. data/vendor/brotli/c/enc/metablock.c +171 -36
  87. data/vendor/brotli/c/enc/metablock.h +13 -8
  88. data/vendor/brotli/c/enc/metablock_inc.h +2 -2
  89. data/vendor/brotli/c/enc/params.h +46 -0
  90. data/vendor/brotli/c/enc/prefix.h +3 -4
  91. data/vendor/brotli/c/enc/quality.h +29 -24
  92. data/vendor/brotli/c/enc/ringbuffer.h +19 -12
  93. data/vendor/brotli/c/enc/static_dict.c +49 -45
  94. data/vendor/brotli/c/enc/static_dict.h +4 -3
  95. data/vendor/brotli/c/enc/static_dict_lut.h +1 -1
  96. data/vendor/brotli/c/enc/utf8_util.c +21 -21
  97. data/vendor/brotli/c/enc/utf8_util.h +1 -1
  98. data/vendor/brotli/c/enc/write_bits.h +35 -38
  99. data/vendor/brotli/c/include/brotli/decode.h +13 -8
  100. data/vendor/brotli/c/include/brotli/encode.h +54 -8
  101. data/vendor/brotli/c/include/brotli/port.h +225 -83
  102. data/vendor/brotli/c/include/brotli/types.h +0 -7
  103. metadata +28 -87
  104. data/.travis.yml +0 -30
  105. data/spec/brotli_spec.rb +0 -88
  106. data/spec/inflate_spec.rb +0 -75
  107. data/spec/spec_helper.rb +0 -4
  108. data/vendor/brotli/c/dec/port.h +0 -168
  109. data/vendor/brotli/c/dec/transform.h +0 -300
  110. data/vendor/brotli/c/enc/context.h +0 -184
  111. data/vendor/brotli/c/enc/port.h +0 -184
@@ -80,11 +80,4 @@ typedef void* (*brotli_alloc_func)(void* opaque, size_t size);
80
80
  */
81
81
  typedef void (*brotli_free_func)(void* opaque, void* address);
82
82
 
83
- #if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) && \
84
- !defined(__cplusplus) && !defined(__PGI)
85
- #define BROTLI_ARRAY_PARAM(L) L
86
- #else
87
- #define BROTLI_ARRAY_PARAM(L)
88
- #endif
89
-
90
83
  #endif /* BROTLI_COMMON_TYPES_H_ */
metadata CHANGED
@@ -1,85 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: brotli
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - miyucy
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-10-21 00:00:00.000000000 Z
12
- dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: bundler
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - "~>"
18
- - !ruby/object:Gem::Version
19
- version: '1.10'
20
- type: :development
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - "~>"
25
- - !ruby/object:Gem::Version
26
- version: '1.10'
27
- - !ruby/object:Gem::Dependency
28
- name: rake
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - "~>"
32
- - !ruby/object:Gem::Version
33
- version: '10.0'
34
- type: :development
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - "~>"
39
- - !ruby/object:Gem::Version
40
- version: '10.0'
41
- - !ruby/object:Gem::Dependency
42
- name: rake-compiler
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - ">="
46
- - !ruby/object:Gem::Version
47
- version: '0'
48
- type: :development
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - ">="
53
- - !ruby/object:Gem::Version
54
- version: '0'
55
- - !ruby/object:Gem::Dependency
56
- name: rspec
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - ">="
60
- - !ruby/object:Gem::Version
61
- version: '0'
62
- type: :development
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - ">="
67
- - !ruby/object:Gem::Version
68
- version: '0'
69
- - !ruby/object:Gem::Dependency
70
- name: rantly
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - ">="
74
- - !ruby/object:Gem::Version
75
- version: '0'
76
- type: :development
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - ">="
81
- - !ruby/object:Gem::Version
82
- version: '0'
11
+ date: 2020-12-27 00:00:00.000000000 Z
12
+ dependencies: []
83
13
  description: Brotli compressor/decompressor
84
14
  email:
85
15
  - fistfvck@gmail.com
@@ -88,14 +18,16 @@ extensions:
88
18
  - ext/brotli/extconf.rb
89
19
  extra_rdoc_files: []
90
20
  files:
21
+ - ".github/workflows/main.yml"
22
+ - ".github/workflows/publish.yml"
91
23
  - ".gitignore"
92
24
  - ".gitmodules"
93
25
  - ".rspec"
94
- - ".travis.yml"
95
26
  - Gemfile
96
27
  - LICENSE.txt
97
28
  - README.md
98
29
  - Rakefile
30
+ - bin/before_install.sh
99
31
  - bin/console
100
32
  - bin/setup
101
33
  - brotli.gemspec
@@ -107,26 +39,31 @@ files:
107
39
  - lib/brotli.rb
108
40
  - lib/brotli/version.rb
109
41
  - smoke.sh
110
- - spec/brotli_spec.rb
111
- - spec/inflate_spec.rb
112
- - spec/spec_helper.rb
42
+ - test/brotli_test.rb
43
+ - test/brotli_writer_test.rb
44
+ - test/test_helper.rb
113
45
  - vendor/brotli/LICENSE
46
+ - vendor/brotli/c/common/constants.c
114
47
  - vendor/brotli/c/common/constants.h
48
+ - vendor/brotli/c/common/context.c
49
+ - vendor/brotli/c/common/context.h
115
50
  - vendor/brotli/c/common/dictionary.bin
51
+ - vendor/brotli/c/common/dictionary.bin.br
116
52
  - vendor/brotli/c/common/dictionary.c
117
53
  - vendor/brotli/c/common/dictionary.h
54
+ - vendor/brotli/c/common/platform.c
55
+ - vendor/brotli/c/common/platform.h
56
+ - vendor/brotli/c/common/transform.c
57
+ - vendor/brotli/c/common/transform.h
118
58
  - vendor/brotli/c/common/version.h
119
59
  - vendor/brotli/c/dec/bit_reader.c
120
60
  - vendor/brotli/c/dec/bit_reader.h
121
- - vendor/brotli/c/dec/context.h
122
61
  - vendor/brotli/c/dec/decode.c
123
62
  - vendor/brotli/c/dec/huffman.c
124
63
  - vendor/brotli/c/dec/huffman.h
125
- - vendor/brotli/c/dec/port.h
126
64
  - vendor/brotli/c/dec/prefix.h
127
65
  - vendor/brotli/c/dec/state.c
128
66
  - vendor/brotli/c/dec/state.h
129
- - vendor/brotli/c/dec/transform.h
130
67
  - vendor/brotli/c/enc/backward_references.c
131
68
  - vendor/brotli/c/enc/backward_references.h
132
69
  - vendor/brotli/c/enc/backward_references_hq.c
@@ -144,25 +81,30 @@ files:
144
81
  - vendor/brotli/c/enc/cluster.c
145
82
  - vendor/brotli/c/enc/cluster.h
146
83
  - vendor/brotli/c/enc/cluster_inc.h
84
+ - vendor/brotli/c/enc/command.c
147
85
  - vendor/brotli/c/enc/command.h
148
86
  - vendor/brotli/c/enc/compress_fragment.c
149
87
  - vendor/brotli/c/enc/compress_fragment.h
150
88
  - vendor/brotli/c/enc/compress_fragment_two_pass.c
151
89
  - vendor/brotli/c/enc/compress_fragment_two_pass.h
152
- - vendor/brotli/c/enc/context.h
153
90
  - vendor/brotli/c/enc/dictionary_hash.c
154
91
  - vendor/brotli/c/enc/dictionary_hash.h
155
92
  - vendor/brotli/c/enc/encode.c
93
+ - vendor/brotli/c/enc/encoder_dict.c
94
+ - vendor/brotli/c/enc/encoder_dict.h
156
95
  - vendor/brotli/c/enc/entropy_encode.c
157
96
  - vendor/brotli/c/enc/entropy_encode.h
158
97
  - vendor/brotli/c/enc/entropy_encode_static.h
98
+ - vendor/brotli/c/enc/fast_log.c
159
99
  - vendor/brotli/c/enc/fast_log.h
160
100
  - vendor/brotli/c/enc/find_match_length.h
161
101
  - vendor/brotli/c/enc/hash.h
102
+ - vendor/brotli/c/enc/hash_composite_inc.h
162
103
  - vendor/brotli/c/enc/hash_forgetful_chain_inc.h
163
104
  - vendor/brotli/c/enc/hash_longest_match64_inc.h
164
105
  - vendor/brotli/c/enc/hash_longest_match_inc.h
165
106
  - vendor/brotli/c/enc/hash_longest_match_quickly_inc.h
107
+ - vendor/brotli/c/enc/hash_rolling_inc.h
166
108
  - vendor/brotli/c/enc/hash_to_binary_tree_inc.h
167
109
  - vendor/brotli/c/enc/histogram.c
168
110
  - vendor/brotli/c/enc/histogram.h
@@ -174,7 +116,7 @@ files:
174
116
  - vendor/brotli/c/enc/metablock.c
175
117
  - vendor/brotli/c/enc/metablock.h
176
118
  - vendor/brotli/c/enc/metablock_inc.h
177
- - vendor/brotli/c/enc/port.h
119
+ - vendor/brotli/c/enc/params.h
178
120
  - vendor/brotli/c/enc/prefix.h
179
121
  - vendor/brotli/c/enc/quality.h
180
122
  - vendor/brotli/c/enc/ringbuffer.h
@@ -207,12 +149,11 @@ required_rubygems_version: !ruby/object:Gem::Requirement
207
149
  - !ruby/object:Gem::Version
208
150
  version: '0'
209
151
  requirements: []
210
- rubyforge_project:
211
- rubygems_version: 2.6.14
152
+ rubygems_version: 3.1.4
212
153
  signing_key:
213
154
  specification_version: 4
214
155
  summary: Brotli compressor/decompressor
215
156
  test_files:
216
- - spec/brotli_spec.rb
217
- - spec/inflate_spec.rb
218
- - spec/spec_helper.rb
157
+ - test/brotli_test.rb
158
+ - test/brotli_writer_test.rb
159
+ - test/test_helper.rb
@@ -1,30 +0,0 @@
1
- language: ruby
2
- sudo: false
3
- cache:
4
- bundler: true
5
- directories:
6
- - "$HOME/.ccache"
7
- rvm:
8
- - 1.9.3
9
- - 2.2.8
10
- - 2.3.5
11
- - 2.4.2
12
- - 2.5.0-preview1
13
- env:
14
- global:
15
- - RANTLY_COUNT=10000
16
- - PATH="/usr/lib/ccache:$PATH"
17
- before_install:
18
- - gem install bundler
19
- deploy:
20
- provider: rubygems
21
- api_key:
22
- secure: pHMMdI6cthdpQ8XHK4LPMRJK9yndRNRprSpttbK+M2Cq6O8ABIx9YsaiR4U6+kkS4RXwWnnJ6qkglQVLsCd1x+elJA0V8MxhOdzKyQgNC5wbIhtIdEZ9cN0c/hG8e9pKa35K9q9ETJ4M8QWNPxkJTRKw1yM8rIMbzf0oy0Btrcz+pJG8C9cMQwfV3QGJFPdO4Hcb5v2gK9rMDU5v3OD9CgbQqaZN3tbR2G1WTiAkFk86RlwPTyaurIRiUV/AQedPSPHHJ5SYbThjcu5iy1OtlFHkVTy/5QNm8ooJkX3pAVhnexTL/iufP0YI9xmYPq4k4RxK1ywSATbvz13JKyD94Sdlhpblz4kJaA4Fg3td8qQtZnFEICBuiW1yelWwVXbyb+zjeL8K4EizoqZV2WwKq2GR3fmyAgFHWiVXRbu0aNjJi23rpNkAGif41vAbsskgBgOiKYsW5/ZOE2opL7lH5l8GGjiYQ8cOKbiNKpUSFaCfwOwgZt4QBTNsN+GuasLNZkm3Dt4Wj7KhFJ+HtAfTnSpomsSQ5/wGwMUchQKo9mfSE0lmKglFyvRV23+WnEX0ZC2jUIJmaxGn1PajDL5tjnZOd5mZAehrc74r84o5olM39y7DynU6FP9QaVBaXF/vue4kIbL0ePSxxwMIYErOh0pOWbWx7ipMfDn+1jfsmvA=
23
- gem: brotli
24
- on:
25
- tags: true
26
- repo: miyucy/brotli
27
- script: bundle exec rake && ./smoke.sh
28
- matrix:
29
- allow_failures:
30
- - rvm: 2.5.0-preview1
@@ -1,88 +0,0 @@
1
- require 'spec_helper'
2
- require 'zlib'
3
-
4
- describe Brotli do
5
- let!(:data) { File.binread File.expand_path(File.join(File.dirname(__FILE__), '..', 'vendor', 'brotli', 'tests', 'testdata', 'alice29.txt'), __FILE__) }
6
-
7
- context 'deflate/inflate' do
8
- it 'with example data' do
9
- bkup = data.dup
10
- compressed = Brotli.deflate(data)
11
- expect(data).to eq bkup
12
- bkup = compressed.dup
13
- decompressed = Brotli.inflate(compressed)
14
- expect(compressed).to eq bkup
15
- expect(decompressed).to eq data
16
- end
17
-
18
- it 'with random data' do
19
- property_of {
20
- string
21
- }.check { |str|
22
- bkup = str.dup
23
- compressed = Brotli.deflate(str)
24
- expect(str).to eq bkup
25
- bkup = compressed.dup
26
- decompressed = Brotli.inflate(compressed)
27
- expect(compressed).to eq bkup
28
- expect(decompressed).to eq str
29
- }
30
- end
31
- end
32
-
33
- it 'deflate options' do
34
- expect { Brotli.deflate(data, mode: :generic) }.to_not raise_error
35
- expect { Brotli.deflate(data, mode: :text) }.to_not raise_error
36
- expect { Brotli.deflate(data, mode: :font) }.to_not raise_error
37
- expect { Brotli.deflate(data, mode: 'generic') }.to raise_error ArgumentError
38
- expect { Brotli.deflate(data, mode: 'text') }.to raise_error ArgumentError
39
- expect { Brotli.deflate(data, mode: 'font') }.to raise_error ArgumentError
40
-
41
- expect { Brotli.deflate(data, quality: -1) }.to raise_error ArgumentError
42
- expect { Brotli.deflate(data, quality: 0) }.to_not raise_error
43
- expect { Brotli.deflate(data, quality: 11) }.to_not raise_error
44
- expect { Brotli.deflate(data, quality: 12) }.to raise_error ArgumentError
45
-
46
- expect { Brotli.deflate(data, lgwin: 9) }.to raise_error ArgumentError
47
- expect { Brotli.deflate(data, lgwin: 10) }.to_not raise_error
48
- expect { Brotli.deflate(data, lgwin: 24) }.to_not raise_error
49
- expect { Brotli.deflate(data, lgwin: 25) }.to raise_error ArgumentError
50
-
51
- expect { Brotli.deflate(data, lgblock: 15) }.to raise_error ArgumentError
52
- expect { Brotli.deflate(data, lgblock: 16) }.to_not raise_error
53
- expect { Brotli.deflate(data, lgblock: 24) }.to_not raise_error
54
- expect { Brotli.deflate(data, lgblock: 25) }.to raise_error ArgumentError
55
- expect { Brotli.deflate(data, lgblock: -1) }.to raise_error ArgumentError
56
- expect { Brotli.deflate(data, lgblock: 0) }.to_not raise_error
57
- expect { Brotli.deflate(data, lgblock: 1) }.to raise_error ArgumentError
58
- end
59
-
60
- context 'benchmark' do
61
- it 'ratio' do
62
- compressed = Zlib.deflate(data, Zlib::BEST_COMPRESSION)
63
- zlib_compressed_bytesize = compressed.bytesize
64
- zlib_compression_ratio = (compressed.bytesize / data.bytesize.to_f * 100).round(3)
65
- puts "Zlib size: #{zlib_compressed_bytesize}, compress ratio: #{zlib_compression_ratio} %"
66
-
67
- compressed = Brotli.deflate(data)
68
- brotli_compressed_bytesize = compressed.bytesize
69
- brotli_compression_ratio = (compressed.bytesize / data.bytesize.to_f * 100).round(3)
70
- puts "Brotli size: #{brotli_compressed_bytesize}, compress ratio: #{brotli_compression_ratio} %"
71
-
72
- expect(brotli_compressed_bytesize).to be < zlib_compressed_bytesize
73
- expect(brotli_compression_ratio).to be < zlib_compression_ratio
74
-
75
- compressed = Brotli.deflate(data, mode: :text, quality: 11, lgwin: 24, lgblock: 0)
76
- puts "Brotli(text/11/24/0) size: #{compressed.bytesize}, compress ratio: #{(compressed.bytesize / data.bytesize.to_f * 100).round(3)} %"
77
- compressed = Brotli.deflate(data, mode: :generic, quality: 11, lgwin: 24, lgblock: 24)
78
- puts "Brotli(generic/11/24/24) size: #{compressed.bytesize}, compress ratio: #{(compressed.bytesize / data.bytesize.to_f * 100).round(3)} %"
79
- compressed = Brotli.deflate(data, mode: :text, quality: 11, lgwin: 24, lgblock: 24)
80
- puts "Brotli(text/11/24/24) size: #{compressed.bytesize}, compress ratio: #{(compressed.bytesize / data.bytesize.to_f * 100).round(3)} %"
81
- end
82
- end
83
-
84
- it 'inflate' do
85
- compressed = File.binread File.expand_path(File.join(File.dirname(__FILE__), '..', 'vendor', 'brotli', 'tests', 'testdata', 'alice29.txt.compressed'), __FILE__)
86
- expect(Brotli.inflate(compressed)).to eq data
87
- end
88
- end
@@ -1,75 +0,0 @@
1
- require 'spec_helper'
2
- require 'benchmark'
3
- require 'thread'
4
-
5
- describe Brotli do
6
- context 'deflate' do
7
- let(:sample) { 10 }
8
- let(:datum) { File.binread File.expand_path(File.join(File.dirname(__FILE__), '..', 'vendor', 'brotli', 'tests', 'testdata', 'lcet10.txt'), __FILE__) }
9
- let!(:data) { sample.times.map { datum.dup } }
10
-
11
- it 'seq' do
12
- t = Benchmark.realtime do
13
- data.each { |datum| Brotli.deflate datum }
14
- end
15
- puts t
16
- # 7.183561000041664
17
- end
18
-
19
- it '5 threads' do
20
- q = Queue.new
21
- data.each { |datum| q.push datum }
22
- 5.times { q.push nil }
23
-
24
- w = 5.times.map do
25
- Thread.new do
26
- while data = q.pop
27
- Brotli.deflate data
28
- end
29
- end
30
- end
31
-
32
- t = Benchmark.realtime do
33
- w.each(&:join)
34
- end
35
- puts t
36
- # 1.7900010000448674
37
- end
38
- end
39
-
40
- context 'inflate' do
41
- let(:sample) { 1000 }
42
- let(:datum) { File.binread File.expand_path(File.join(File.dirname(__FILE__), '..', 'vendor', 'brotli', 'tests', 'testdata', 'lcet10.txt.compressed'), __FILE__) }
43
- let!(:data) { sample.times.map { datum.dup } }
44
-
45
- it 'seq' do
46
- t = Benchmark.realtime do
47
- data.each { |datum| Brotli.inflate datum }
48
- end
49
- puts t
50
- # w/ gvl 1.6123949999455363
51
- # w/o gvl 1.5788109998684376
52
- end
53
-
54
- it '5 threads' do
55
- q = Queue.new
56
- data.each { |datum| q.push datum }
57
- 5.times { q.push nil }
58
-
59
- w = 5.times.map do
60
- Thread.new do
61
- while data = q.pop
62
- Brotli.inflate data
63
- end
64
- end
65
- end
66
-
67
- t = Benchmark.realtime do
68
- w.each(&:join)
69
- end
70
- puts t
71
- # w/ gvl 1.0620850000996143
72
- # w/o gvl 0.40698900003917515
73
- end
74
- end
75
- end
@@ -1,4 +0,0 @@
1
- $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
2
- require 'brotli'
3
- require 'rantly/rspec_extensions'
4
- require 'rantly/shrinks'
@@ -1,168 +0,0 @@
1
- /* Copyright 2015 Google Inc. All Rights Reserved.
2
-
3
- Distributed under MIT license.
4
- See file LICENSE for detail or copy at https://opensource.org/licenses/MIT
5
- */
6
-
7
- /* Macros for compiler / platform specific features and build options.
8
-
9
- Build options are:
10
- * BROTLI_BUILD_32_BIT disables 64-bit optimizations
11
- * BROTLI_BUILD_64_BIT forces to use 64-bit optimizations
12
- * BROTLI_BUILD_BIG_ENDIAN forces to use big-endian optimizations
13
- * BROTLI_BUILD_ENDIAN_NEUTRAL disables endian-aware optimizations
14
- * BROTLI_BUILD_LITTLE_ENDIAN forces to use little-endian optimizations
15
- * BROTLI_BUILD_MODERN_COMPILER forces to use modern compilers built-ins,
16
- features and attributes
17
- * BROTLI_BUILD_PORTABLE disables dangerous optimizations, like unaligned
18
- read and overlapping memcpy; this reduces decompression speed by 5%
19
- * BROTLI_BUILD_NO_RBIT disables "rbit" optimization for ARM CPUs
20
- * BROTLI_DEBUG dumps file name and line number when decoder detects stream
21
- or memory error
22
- * BROTLI_ENABLE_LOG enables asserts and dumps various state information
23
- */
24
-
25
- #ifndef BROTLI_DEC_PORT_H_
26
- #define BROTLI_DEC_PORT_H_
27
-
28
- #if defined(BROTLI_ENABLE_LOG) || defined(BROTLI_DEBUG)
29
- #include <assert.h>
30
- #include <stdio.h>
31
- #endif
32
-
33
- #include <brotli/port.h>
34
-
35
- #if defined(__arm__) || defined(__thumb__) || \
36
- defined(_M_ARM) || defined(_M_ARMT) || defined(__ARM64_ARCH_8__)
37
- #define BROTLI_TARGET_ARM
38
- #if (defined(__ARM_ARCH) && (__ARM_ARCH == 7)) || \
39
- (defined(M_ARM) && (M_ARM == 7))
40
- #define BROTLI_TARGET_ARMV7
41
- #endif /* ARMv7 */
42
- #if defined(__aarch64__) || defined(__ARM64_ARCH_8__)
43
- #define BROTLI_TARGET_ARMV8
44
- #endif /* ARMv8 */
45
- #endif /* ARM */
46
-
47
- #if defined(__i386) || defined(_M_IX86)
48
- #define BROTLI_TARGET_X86
49
- #endif
50
-
51
- #if defined(__x86_64__) || defined(_M_X64)
52
- #define BROTLI_TARGET_X64
53
- #endif
54
-
55
- #if defined(__PPC64__)
56
- #define BROTLI_TARGET_POWERPC64
57
- #endif
58
-
59
- #ifdef BROTLI_BUILD_PORTABLE
60
- #define BROTLI_ALIGNED_READ (!!1)
61
- #elif defined(BROTLI_TARGET_X86) || defined(BROTLI_TARGET_X64) || \
62
- defined(BROTLI_TARGET_ARMV7) || defined(BROTLI_TARGET_ARMV8)
63
- /* Allow unaligned read only for white-listed CPUs. */
64
- #define BROTLI_ALIGNED_READ (!!0)
65
- #else
66
- #define BROTLI_ALIGNED_READ (!!1)
67
- #endif
68
-
69
- /* IS_CONSTANT macros returns true for compile-time constant expressions. */
70
- #if BROTLI_MODERN_COMPILER || __has_builtin(__builtin_constant_p)
71
- #define IS_CONSTANT(x) (!!__builtin_constant_p(x))
72
- #else
73
- #define IS_CONSTANT(x) (!!0)
74
- #endif
75
-
76
- #ifdef BROTLI_ENABLE_LOG
77
- #define BROTLI_DCHECK(x) assert(x)
78
- #define BROTLI_LOG(x) printf x
79
- #else
80
- #define BROTLI_DCHECK(x)
81
- #define BROTLI_LOG(x)
82
- #endif
83
-
84
- #if defined(BROTLI_DEBUG) || defined(BROTLI_ENABLE_LOG)
85
- static BROTLI_INLINE void BrotliDump(const char* f, int l, const char* fn) {
86
- fprintf(stderr, "%s:%d (%s)\n", f, l, fn);
87
- fflush(stderr);
88
- }
89
- #define BROTLI_DUMP() BrotliDump(__FILE__, __LINE__, __FUNCTION__)
90
- #else
91
- #define BROTLI_DUMP() (void)(0)
92
- #endif
93
-
94
- #if defined(BROTLI_BUILD_64_BIT)
95
- #define BROTLI_64_BITS 1
96
- #elif defined(BROTLI_BUILD_32_BIT)
97
- #define BROTLI_64_BITS 0
98
- #elif defined(BROTLI_TARGET_X64) || defined(BROTLI_TARGET_ARMV8) || \
99
- defined(BROTLI_TARGET_POWERPC64)
100
- #define BROTLI_64_BITS 1
101
- #else
102
- #define BROTLI_64_BITS 0
103
- #endif
104
-
105
- #if (BROTLI_64_BITS)
106
- #define reg_t uint64_t
107
- #else
108
- #define reg_t uint32_t
109
- #endif
110
-
111
- #if defined(BROTLI_BUILD_BIG_ENDIAN)
112
- #define BROTLI_LITTLE_ENDIAN 0
113
- #define BROTLI_BIG_ENDIAN 1
114
- #elif defined(BROTLI_BUILD_LITTLE_ENDIAN)
115
- #define BROTLI_LITTLE_ENDIAN 1
116
- #define BROTLI_BIG_ENDIAN 0
117
- #elif defined(BROTLI_BUILD_ENDIAN_NEUTRAL)
118
- #define BROTLI_LITTLE_ENDIAN 0
119
- #define BROTLI_BIG_ENDIAN 0
120
- #elif defined(__BYTE_ORDER__) && (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__)
121
- #define BROTLI_LITTLE_ENDIAN 1
122
- #define BROTLI_BIG_ENDIAN 0
123
- #elif defined(_WIN32)
124
- /* Win32 can currently always be assumed to be little endian */
125
- #define BROTLI_LITTLE_ENDIAN 1
126
- #define BROTLI_BIG_ENDIAN 0
127
- #else
128
- #if (defined(__BYTE_ORDER__) && (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__))
129
- #define BROTLI_BIG_ENDIAN 1
130
- #else
131
- #define BROTLI_BIG_ENDIAN 0
132
- #endif
133
- #define BROTLI_LITTLE_ENDIAN 0
134
- #endif
135
-
136
- #define BROTLI_REPEAT(N, X) { \
137
- if ((N & 1) != 0) {X;} \
138
- if ((N & 2) != 0) {X; X;} \
139
- if ((N & 4) != 0) {X; X; X; X;} \
140
- }
141
-
142
- #if (BROTLI_MODERN_COMPILER || defined(__llvm__)) && \
143
- !defined(BROTLI_BUILD_NO_RBIT)
144
- #if defined(BROTLI_TARGET_ARMV7) || defined(BROTLI_TARGET_ARMV8)
145
- /* TODO: detect ARMv6T2 and enable this code for it. */
146
- static BROTLI_INLINE reg_t BrotliRBit(reg_t input) {
147
- reg_t output;
148
- __asm__("rbit %0, %1\n" : "=r"(output) : "r"(input));
149
- return output;
150
- }
151
- #define BROTLI_RBIT(x) BrotliRBit(x)
152
- #endif /* armv7 */
153
- #endif /* gcc || clang */
154
-
155
- #if defined(BROTLI_TARGET_ARM)
156
- #define BROTLI_HAS_UBFX (!!1)
157
- #else
158
- #define BROTLI_HAS_UBFX (!!0)
159
- #endif
160
-
161
- #define BROTLI_ALLOC(S, L) S->alloc_func(S->memory_manager_opaque, L)
162
-
163
- #define BROTLI_FREE(S, X) { \
164
- S->free_func(S->memory_manager_opaque, X); \
165
- X = NULL; \
166
- }
167
-
168
- #endif /* BROTLI_DEC_PORT_H_ */