зеркало из https://github.com/github/ruby.git
Improve benchmarks and tests for threads.
This commit is contained in:
Родитель
a6a4e86029
Коммит
3fd83cb6fc
|
@ -0,0 +1,8 @@
|
|||
benchmark:
|
||||
vm_thread_alive_check: |
|
||||
t = Thread.new{}
|
||||
while t.alive?
|
||||
Thread.pass
|
||||
end
|
||||
loop_count: 50_000
|
||||
|
|
@ -1,6 +0,0 @@
|
|||
5_000.times{
|
||||
t = Thread.new{}
|
||||
while t.alive?
|
||||
Thread.pass
|
||||
end
|
||||
}
|
|
@ -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{
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
require 'thread'
|
||||
|
||||
n = 1_000_000
|
||||
n = 10_000_000
|
||||
q = Thread::Queue.new
|
||||
consumer = Thread.new{
|
||||
while q.pop
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
benchmark:
|
||||
vm_thread_sleep: |
|
||||
Thread.new { sleep }
|
||||
loop_count: 10_000
|
|
@ -10,6 +10,9 @@ assert_equal %q{ok}, %q{
|
|||
:ok
|
||||
}.value
|
||||
}
|
||||
assert_equal %q{ok}, %q{
|
||||
:ok if Thread.new{sleep}.backtrace == []
|
||||
}
|
||||
assert_equal %q{ok}, %q{
|
||||
begin
|
||||
v = 0
|
||||
|
|
Загрузка…
Ссылка в новой задаче