Created
October 13, 2010 18:18
-
-
Save ngauthier/624566 to your computer and use it in GitHub Desktop.
This file contains 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
$ ruby parallel_bench.rb | |
== Many Small Jobs Benchmark == | |
Forque Benchmark: 0.097953 | |
Parallel Benchmark: 10.233478 | |
Serial Benchmark: 0.000956 | |
== Few Large Jobs Benchmark == | |
Forque Benchmark: 25.104783 | |
Parallel Benchmark: 26.984219 |
This file contains 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 'rubygems' | |
require 'parallel' | |
require 'forque/forque' | |
set = (1..500).collect | |
puts "== Many Small Jobs Benchmark ==" | |
start = Time.now | |
f_result = Forque.new(*set).collect{|x| x**2} | |
finish = Time.now | |
puts "Forque Benchmark: #{finish-start}" | |
start = Time.now | |
p_result = Parallel.map(set, :in_processes => 4){|x| x**2} | |
finish = Time.now | |
puts "Parallel Benchmark: #{finish-start}" | |
start = Time.now | |
s_result = set.map{|x| x**2} | |
finish = Time.now | |
puts "Serial Benchmark: #{finish-start}" | |
f_result.sort! | |
p_result.sort! | |
s_result.sort! | |
unless f_result == p_result and f_result == s_result | |
puts "Results not equal!" | |
end | |
puts "== Few Large Jobs Benchmark ==" | |
set = [1]*100 | |
start = Time.now | |
Forque.new(*set).collect{|x| sleep(x) } | |
finish = Time.now | |
puts "Forque Benchmark: #{finish-start}" | |
start = Time.now | |
Parallel.map(set, :in_processes => 4){|x| sleep(x) } | |
finish = Time.now | |
puts "Parallel Benchmark: #{finish-start}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment