File tree Expand file tree Collapse file tree 3 files changed +42
-4
lines changed Expand file tree Collapse file tree 3 files changed +42
-4
lines changed Original file line number Diff line number Diff line change 7
7
8
8
name : Ruby
9
9
10
- on : [push, pull_request]
10
+ on :
11
+ push :
12
+ branches :
13
+ - main
14
+ paths-ignore :
15
+ - ' README.md'
16
+ pull_request :
17
+
18
+ concurrency :
19
+ group : ${{ github.workflow }}-${{ github.ref }}
20
+ cancel-in-progress : true
11
21
12
22
jobs :
13
23
test :
14
-
15
24
runs-on : ubuntu-latest
16
25
strategy :
17
26
matrix :
Original file line number Diff line number Diff line change 4
4
require 'objspace'
5
5
require 'zstd-ruby'
6
6
require 'thread'
7
- require "zstds"
8
7
9
8
GUESSES = ( ENV [ 'GUESSES' ] || 1000 ) . to_i
10
9
THREADS = ( ENV [ 'THREADS' ] || 1 ) . to_i
22
21
while str = queue . pop
23
22
stream = Zstd ::StreamingCompress . new
24
23
stream << str
25
- stream . finish
24
+ res = stream . flush
25
+ stream << str
26
+ res << stream . finish
26
27
end
27
28
}
28
29
} . each ( &:join )
Original file line number Diff line number Diff line change
1
+ require 'benchmark/ips'
2
+ $LOAD_PATH. unshift '../lib'
3
+ require 'json'
4
+ require 'objspace'
5
+ require 'zstd-ruby'
6
+ require 'thread'
7
+
8
+ GUESSES = ( ENV [ 'GUESSES' ] || 1000 ) . to_i
9
+ THREADS = ( ENV [ 'THREADS' ] || 1 ) . to_i
10
+
11
+ p GUESSES : GUESSES , THREADS : THREADS
12
+
13
+ sample_file_name = ARGV [ 0 ]
14
+ json_string = File . read ( "./samples/#{ sample_file_name } " )
15
+ target = Zstd . compress ( json_string )
16
+
17
+ queue = Queue . new
18
+ GUESSES . times { queue << target }
19
+ THREADS . times { queue << nil }
20
+ THREADS . times . map {
21
+ Thread . new {
22
+ while str = queue . pop
23
+ stream = Zstd ::StreamingDecompress . new
24
+ stream . decompress ( str )
25
+ stream . decompress ( str )
26
+ end
27
+ }
28
+ } . each ( &:join )
You can’t perform that action at this time.
0 commit comments