[前][次][番号順一覧][スレッド一覧]

ruby-changes:46395

From: normal <ko1@a...>
Date: Sun, 30 Apr 2017 16:24:42 +0900 (JST)
Subject: [ruby-changes:46395] normal:r58509 (trunk): new benchmark for SizedQueue

normal	2017-04-30 16:24:36 +0900 (Sun, 30 Apr 2017)

  New Revision: 58509

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=58509

  Log:
    new benchmark for SizedQueue
    
    The performance of SizedQueue is a bit more complex than
    regular Queue, so it deserves a separate benchmark.

  Added files:
    trunk/benchmark/bm_vm_thread_sized_queue.rb
Index: benchmark/bm_vm_thread_sized_queue.rb
===================================================================
--- benchmark/bm_vm_thread_sized_queue.rb	(nonexistent)
+++ benchmark/bm_vm_thread_sized_queue.rb	(revision 58509)
@@ -0,0 +1,19 @@ https://github.com/ruby/ruby/blob/trunk/benchmark/bm_vm_thread_sized_queue.rb#L1
+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

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]