aboutsummaryrefslogtreecommitdiffstats
path: root/benchmark
diff options
context:
space:
mode:
authorSamuel Williams <samuel.williams@oriontransfer.co.nz>2019-06-05 16:32:27 +1200
committerSamuel Williams <samuel.williams@oriontransfer.co.nz>2019-06-19 20:39:10 +1200
commit3fd83cb6fcc483d2eac0795bc139c521a3a59bd2 (patch)
tree775fa3b051fa2a50adbc994aeef82d9b2dc2c482 /benchmark
parenta6a4e86029f16415767b579e62691f09b1fb6075 (diff)
downloadruby-3fd83cb6fcc483d2eac0795bc139c521a3a59bd2.tar.gz
Improve benchmarks and tests for threads.
Diffstat (limited to 'benchmark')
-rw-r--r--benchmark/vm_thread_alive_check.yml8
-rw-r--r--benchmark/vm_thread_alive_check1.rb6
-rw-r--r--benchmark/vm_thread_pass.rb4
-rw-r--r--benchmark/vm_thread_pass_flood.rb4
-rw-r--r--benchmark/vm_thread_queue.rb2
-rw-r--r--benchmark/vm_thread_sleep.yml4
6 files changed, 17 insertions, 11 deletions
diff --git a/benchmark/vm_thread_alive_check.yml b/benchmark/vm_thread_alive_check.yml
new file mode 100644
index 0000000000..d21737d3e8
--- /dev/null
+++ b/benchmark/vm_thread_alive_check.yml
@@ -0,0 +1,8 @@
+benchmark:
+ vm_thread_alive_check: |
+ t = Thread.new{}
+ while t.alive?
+ Thread.pass
+ end
+loop_count: 50_000
+
diff --git a/benchmark/vm_thread_alive_check1.rb b/benchmark/vm_thread_alive_check1.rb
deleted file mode 100644
index c993accdda..0000000000
--- a/benchmark/vm_thread_alive_check1.rb
+++ /dev/null
@@ -1,6 +0,0 @@
-5_000.times{
- t = Thread.new{}
- while t.alive?
- Thread.pass
- end
-}
diff --git a/benchmark/vm_thread_pass.rb b/benchmark/vm_thread_pass.rb
index b5b3c0bc85..e5f2352610 100644
--- a/benchmark/vm_thread_pass.rb
+++ b/benchmark/vm_thread_pass.rb
@@ -1,8 +1,8 @@
# Plenty Thtread.pass
# A performance may depend on GVL implementation.
-tmax = (ARGV.shift || 2).to_i
-lmax = 200_000 / tmax
+tmax = (ARGV.shift || 8).to_i
+lmax = 400_000 / tmax
(1..tmax).map{
Thread.new{
diff --git a/benchmark/vm_thread_pass_flood.rb b/benchmark/vm_thread_pass_flood.rb
index a660aafc18..65df8e6154 100644
--- a/benchmark/vm_thread_pass_flood.rb
+++ b/benchmark/vm_thread_pass_flood.rb
@@ -1,10 +1,10 @@
# n.b. this is a good test for GVL when pinned to a single CPU
-1000.times{
+5_000.times{
Thread.new{loop{Thread.pass}}
}
i = 0
-while i<10000
+while i<10_000
i += 1
end
diff --git a/benchmark/vm_thread_queue.rb b/benchmark/vm_thread_queue.rb
index 274ceda366..1dd3696a3c 100644
--- a/benchmark/vm_thread_queue.rb
+++ b/benchmark/vm_thread_queue.rb
@@ -1,6 +1,6 @@
require 'thread'
-n = 1_000_000
+n = 10_000_000
q = Thread::Queue.new
consumer = Thread.new{
while q.pop
diff --git a/benchmark/vm_thread_sleep.yml b/benchmark/vm_thread_sleep.yml
new file mode 100644
index 0000000000..96901d8466
--- /dev/null
+++ b/benchmark/vm_thread_sleep.yml
@@ -0,0 +1,4 @@
+benchmark:
+ vm_thread_sleep: |
+ Thread.new { sleep }
+loop_count: 10_000