Skip to content

Instantly share code, notes, and snippets.

@deobald
Created September 7, 2009 02:52
Show Gist options
  • Save deobald/182115 to your computer and use it in GitHub Desktop.
Save deobald/182115 to your computer and use it in GitHub Desktop.
class ThreadTest < Test::Unit::TestCase
# ~ 340 microseconds per thread spin-up, regardless of `-J-Djruby.thread.pooling=[true|false]'
def test_some_speeds
@runs = 0
def func
@runs += 1
end
Benchmark.bm do |bm|
bm.report do
100000.times do
t = Thread.new{ func() }
t.join
end
end
end
puts @runs
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment