* properties.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32060 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2011-06-13 14:05:56 +00:00
parent e3672626bf
commit a72f033447
4 changed files with 70 additions and 70 deletions

View File

@ -1,8 +1,8 @@
i=0 i=0
while i<200_000 while i<200_000
i+=1 i+=1
Class.new{ Class.new{
def m; end def m; end
} }
end end

View File

@ -1,21 +1,21 @@
# one thread, one mutex (no contention) # one thread, one mutex (no contention)
require 'thread' require 'thread'
m = Mutex.new m = Mutex.new
r = 0 r = 0
max = 1000 max = 1000
lmax = max * max lmax = max * max
(1..1).map{ (1..1).map{
Thread.new{ Thread.new{
i=0 i=0
while i<lmax while i<lmax
i+=1 i+=1
m.synchronize{ m.synchronize{
r += 1 r += 1
} }
end end
} }
}.each{|e| }.each{|e|
e.join e.join
} }
raise r.to_s if r != max * max raise r.to_s if r != max * max

View File

@ -1,21 +1,21 @@
# two threads, one mutex # two threads, one mutex
require 'thread' require 'thread'
m = Mutex.new m = Mutex.new
r = 0 r = 0
max = 1000 max = 1000
lmax = (max * max)/2 lmax = (max * max)/2
(1..2).map{ (1..2).map{
Thread.new{ Thread.new{
i=0 i=0
while i<lmax while i<lmax
i+=1 i+=1
m.synchronize{ m.synchronize{
r += 1 r += 1
} }
end end
} }
}.each{|e| }.each{|e|
e.join e.join
} }
raise r.to_s if r != max * max raise r.to_s if r != max * max

View File

@ -1,20 +1,20 @@
# 1000 threads, one mutex # 1000 threads, one mutex
require 'thread' require 'thread'
m = Mutex.new m = Mutex.new
r = 0 r = 0
max = 1000 max = 1000
(1..max).map{ (1..max).map{
Thread.new{ Thread.new{
i=0 i=0
while i<max while i<max
i+=1 i+=1
m.synchronize{ m.synchronize{
r += 1 r += 1
} }
end end
} }
}.each{|e| }.each{|e|
e.join e.join
} }
raise r.to_s if r != max * max raise r.to_s if r != max * max