File tree Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Original file line number Diff line number Diff line change
1
+ $LOAD_PATH. unshift '../lib'
2
+ require 'zstd-ruby'
3
+ require 'securerandom'
4
+
5
+ source_data = ""
6
+ 512 . times { source_data += SecureRandom . uuid }
7
+
8
+ puts "source_data.size:#{ source_data . size } "
9
+
10
+ # Test compressing and de-compressing our source data 100,000 times. The cycles
11
+ # are intended to exercise the libary and reproduce a memory leak.
12
+ 100_000 . times do |i |
13
+ compressed_data = Zstd . compress ( source_data )
14
+ expanded_data = Zstd . decompress ( compressed_data )
15
+ unless expanded_data == source_data
16
+ puts "Error: expanded data does not match source data"
17
+ end
18
+ if i % 1000 == 0
19
+ puts " - #{ i } : c:#{ compressed_data . size } e:#{ expanded_data . size } memory:#{ `ps -o rss= -p #{ Process . pid } ` . to_i } "
20
+ end
21
+
22
+ end
You can’t perform that action at this time.
0 commit comments