Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Thread.new is slow
require "rubygems"
require "rbench"
def noop
end
RBench.run(100_000) do
column :one, :title => "Unthreaded"
column :two, :title => "Threaded"
report "Thread.new is slow" do
one{noop}
two{Thread.new{noop}}
end
end
__END__
# Ruby 1.8.7-p302
Unthreaded | Threaded |
--------------------------------------------------
Thread.new is slow 0.022 | 8.644 |
# Ruby 1.9.2
Unthreaded | Threaded |
--------------------------------------------------
Thread.new is slow 0.013 | 13.448 |
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.