Skip to content

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
$ 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
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
Something went wrong with that request. Please try again.