File tree Expand file tree Collapse file tree 2 files changed +51
-0
lines changed Expand file tree Collapse file tree 2 files changed +51
-0
lines changed Original file line number Diff line number Diff line change
1
+ require 'benchmark/ips'
2
+
3
+ $LOAD_PATH. unshift '../lib'
4
+
5
+ require 'json'
6
+ require 'objspace'
7
+ require 'zstd-ruby'
8
+
9
+ p "#{ ObjectSpace . memsize_of_all /1000 } #{ ObjectSpace . count_objects } #{ `ps -o rss= -p #{ Process . pid } ` . to_i } "
10
+
11
+ sample_file_name = ARGV [ 0 ]
12
+
13
+ json_string = IO . read ( "./samples/#{ sample_file_name } " )
14
+
15
+ i = 0
16
+ while true do
17
+ stream = Zstd ::StreamingCompress . new
18
+ stream << json_string
19
+ res = stream . flush
20
+ res << stream . finish
21
+ if ( ( i % 1000 ) == 0 )
22
+ GC . start
23
+ puts "count:#{ i } \t ruby_memory:#{ ObjectSpace . memsize_of_all /1000 } \t object_count:#{ ObjectSpace . count_objects } \t rss:#{ `ps -o rss= -p #{ Process . pid } ` . to_i } "
24
+ end
25
+ i += 1
26
+ end
Original file line number Diff line number Diff line change
1
+ require 'benchmark/ips'
2
+
3
+ $LOAD_PATH. unshift '../lib'
4
+
5
+ require 'json'
6
+ require 'zstd-ruby'
7
+ require 'objspace'
8
+
9
+ p "#{ ObjectSpace . memsize_of_all /1000 } #{ ObjectSpace . count_objects } #{ `ps -o rss= -p #{ Process . pid } ` . to_i } "
10
+
11
+ sample_file_name = ARGV [ 0 ]
12
+
13
+ cstr = IO . read ( "./results/#{ sample_file_name } .zstd" )
14
+ i = 0
15
+ while true do
16
+ stream = Zstd ::StreamingDecompress . new
17
+ result = ''
18
+ result << stream . decompress ( cstr [ 0 , 10 ] )
19
+ result << stream . decompress ( cstr [ 10 ..-1 ] )
20
+
21
+ if ( ( i % 1000 ) == 0 )
22
+ puts "count:#{ i } \t ruby_memory:#{ ObjectSpace . memsize_of_all /1000 } \t object_count:#{ ObjectSpace . count_objects } \t rss:#{ `ps -o rss= -p #{ Process . pid } ` . to_i } "
23
+ end
24
+ i += 1
25
+ end
You can’t perform that action at this time.
0 commit comments