Skip to content

Instantly share code, notes, and snippets.

@mykoweb
Created December 20, 2016 00:32
Show Gist options
  • Save mykoweb/1e9985ba7bdf3d908a4cf15058207a02 to your computer and use it in GitHub Desktop.
Save mykoweb/1e9985ba7bdf3d908a4cf15058207a02 to your computer and use it in GitHub Desktop.
require 'benchmark'
@threads = []
Benchmark.bm(14) do |x|
x.report('no-threads') do
8.times do
tmp_array = []
10_000_000.times { |n| tmp_array << n }
end
end
x.report('with-threads') do
8.times do
@threads << Thread.new do
tmp_array = []
10_000_000.times { |n| tmp_array << n }
end
end
@threads.each(&:join)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment