mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
new benchmark for SizedQueue
The performance of SizedQueue is a bit more complex than regular Queue, so it deserves a separate benchmark. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58509 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
5a2c1ee353
commit
8e147f1b0d
1 changed files with 19 additions and 0 deletions
19
benchmark/bm_vm_thread_sized_queue.rb
Normal file
19
benchmark/bm_vm_thread_sized_queue.rb
Normal file
|
@ -0,0 +1,19 @@
|
|||
require 'thread'
|
||||
|
||||
n = 1_000_000
|
||||
q = Thread::SizedQueue.new(100)
|
||||
consumer = Thread.new{
|
||||
while q.pop
|
||||
# consuming
|
||||
end
|
||||
}
|
||||
|
||||
producer = Thread.new{
|
||||
while n > 0
|
||||
q.push true
|
||||
n -= 1
|
||||
end
|
||||
q.push nil
|
||||
}
|
||||
|
||||
consumer.join
|
Loading…
Add table
Reference in a new issue