Last active
February 1, 2016 22:28
-
-
Save RunsFor/278bb83f18d6e85c1d67 to your computer and use it in GitHub Desktop.
Multithreaded script performs slower than singlethreaded
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'benchmark' | |
| puts(Benchmark.measure do | |
| count = 0 | |
| 400_000_000.times do | |
| count += 1 | |
| end | |
| end) | |
| puts(Benchmark.measure do | |
| (1..4).map do | |
| Thread.new do | |
| count = 0 | |
| 100_000_000.times do | |
| count += 1 | |
| end | |
| end | |
| end.each(&:join) | |
| end) |
RunsFor
commented
Feb 1, 2016
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment