We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent f3f346a commit 788f4f5Copy full SHA for 788f4f5
benchmarks/multi_thread_comporess.rb
@@ -0,0 +1,25 @@
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
16
+queue = Queue.new
17
+GUESSES.times { queue << json_string }
18
+THREADS.times { queue << nil }
19
+THREADS.times.map {
20
+ Thread.new {
21
+ while str = queue.pop
22
+ Zstd.compress(str)
23
+ end
24
+ }
25
+}.each(&:join)
0 commit comments