Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@radarek
Created June 10, 2011 08:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save radarek/1018457 to your computer and use it in GitHub Desktop.
Save radarek/1018457 to your computer and use it in GitHub Desktop.
$ RUBY=rbx; $RUBY --version && $RUBY -rbenchmark apohllo.rb
rubinius 2.0.0dev (1.8.7 f7440cf0 yyyy-mm-dd JI) [x86_64-apple-darwin10.7.0]
1 runs:
speed-up: threads 1.490/1.430 = 1.042
efficiency: 104.212%
speed-up: procs 1.490/0.980 = 1.520
efficiency: 152.004%
2 runs:
speed-up: threads 1.903/0.989 = 1.924
efficiency: 96.217%
speed-up: procs 1.903/1.031 = 1.845
efficiency: 92.259%
3 runs:
speed-up: threads 2.837/1.531 = 1.853
efficiency: 61.770%
speed-up: procs 2.837/1.568 = 1.809
efficiency: 60.315%
4 runs:
speed-up: threads 3.797/2.040 = 1.861
efficiency: 46.527%
speed-up: procs 3.797/2.085 = 1.821
efficiency: 45.533%
5 runs:
[BUG: Tried to stop but threads still running!]
[BUG: Tried to stop but threads still running!]
2 rbx 0x0000000100027eee rubinius::bug(char const*) + 94
3 rbx 0x00000001000f6c5c rubinius::SharedState::stop_the_world(rubinius::ManagedThread*) + 348
4 rbx 0x00000001000218b6 rubinius::Environment::halt() + 134
5 rbx 0x00000001001de32b main + 667
6 rbx 0x0000000100013788 start + 52
7 ??? 0x0000000000000003 0x0 + 3
2 rbx 0x0000000100027eee rubinius::bug(char const*) + 94
3 rbx 0x00000001000f6c5c rubinius::SharedState::stop_the_world(rubinius::ManagedThread*) + 348
4 rbx 0x00000001000218b6 rubinius::Environment::halt() + 134
5 rbx 0x00000001001de32b main + 667
6 rbx 0x0000000100013788 start + 52
7 ??? 0x0000000000000003 0x0 + 3
[BUG: Tried to stop but threads still running!]
2 rbx 0x0000000100027eee rubinius::bug(char const*) + 94
3 rbx 0x00000001000f6c5c rubinius::SharedState::stop_the_world(rubinius::ManagedThread*) + 348
4 rbx 0x00000001000218b6 rubinius::Environment::halt() + 134
5 rbx 0x00000001001de32b main + 667
6 rbx 0x0000000100013788 start + 52
7 ??? 0x0000000000000003 0x0 + 3
[BUG: Tried to stop but threads still running!]
2 rbx 0x0000000100027eee rubinius::bug(char const*) + 94
3 rbx 0x00000001000f6c5c rubinius::SharedState::stop_the_world(rubinius::ManagedThread*) + 348
4 rbx 0x00000001000218b6 rubinius::Environment::halt() + 134
5 rbx 0x00000001001de32b main + 667
6 rbx 0x0000000100013788 start + 52
7 ??? 0x0000000000000003 0x0 + 3
---------------------------------------------
CRASH: A fatal error has occured.
Backtrace:
0 rbx 0x0000000100021d61 _ZN8rubiniusL12segv_handlerEi + 241
1 libSystem.B.dylib 0x00007fff806df66a _sigtramp + 26
2 ??? 0x700e0ca000000000 0x0 + 8074405063256178688
3 rbx 0x0000000100027ef3 _ZN8rubinius3bugEPKc + 99
4 rbx 0x00000001000f6c5c _ZN8rubinius11SharedState14stop_the_worldEPNS_13ManagedThreadE + 348
5 rbx 0x00000001000218b6 _ZN8rubinius11Environment4haltEv + 134
6 rbx 0x00000001001de32b main + 667
7 rbx 0x0000000100013788 start + 52
8 ??? 0x0000000000000003 0x0 + 3
Wrote full error report to: /Users/radarek/.rubinius_last_error
Run 'rbx report' to submit this crash report!
---------------------------------------------
CRASH: A fatal error has occured.
Backtrace:
0 rbx 0x0000000100021d61 _ZN8rubiniusL12segv_handlerEi + 241
1 libSystem.B.dylib 0x00007fff806df66a _sigtramp + 26
2 ??? 0x700e0ca000000000 0x0 + 8074405063256178688
3 rbx 0x0000000100027ef3 _ZN8rubinius3bugEPKc + 99
4 rbx 0x00000001000f6c5c _ZN8rubinius11SharedState14stop_the_worldEPNS_13ManagedThreadE + 348
5 rbx 0x00000001000218b6 _ZN8rubinius11Environment4haltEv + 134
6 rbx 0x00000001001de32b main + 667
7 rbx 0x0000000100013788 start + 52
8 ??? 0x0000000000000003 0x0 + 3
Wrote full error report to: /Users/radarek/.rubinius_last_error
Run 'rbx report' to submit this crash report!
---------------------------------------------
CRASH: A fatal error has occured.
Backtrace:
0 rbx 0x0000000100021d61 _ZN8rubiniusL12segv_handlerEi + 241
1 libSystem.B.dylib 0x00007fff806df66a _sigtramp + 26
2 ??? 0x700e0ca000000000 0x0 + 8074405063256178688
3 rbx 0x0000000100027ef3 _ZN8rubinius3bugEPKc + 99
4 rbx 0x00000001000f6c5c _ZN8rubinius11SharedState14stop_the_worldEPNS_13ManagedThreadE + 348
5 rbx 0x00000001000218b6 _ZN8rubinius11Environment4haltEv + 134
6 rbx 0x00000001001de32b main + 667
7 rbx 0x0000000100013788 start + 52
8 ??? 0x0000000000000003 0x0 + 3
Wrote full error report to: /Users/radarek/.rubinius_last_error
Run 'rbx report' to submit this crash report!
---------------------------------------------
CRASH: A fatal error has occured.
Backtrace:
0 rbx 0x0000000100021d61 _ZN8rubiniusL12segv_handlerEi + 241
1 libSystem.B.dylib 0x00007fff806df66a _sigtramp + 26
2 ??? 0x700e0ca000000000 0x0 + 8074405063256178688
3 rbx 0x0000000100027ef3 _ZN8rubinius3bugEPKc + 99
4 rbx 0x00000001000f6c5c _ZN8rubinius11SharedState14stop_the_worldEPNS_13ManagedThreadE + 348
5 rbx 0x00000001000218b6 _ZN8rubinius11Environment4haltEv + 134
6 rbx 0x00000001001de32b main + 667
7 rbx 0x0000000100013788 start + 52
8 ??? 0x0000000000000003 0x0 + 3
Wrote full error report to: /Users/radarek/.rubinius_last_error
Run 'rbx report' to submit this crash report!
[BUG: Tried to stop but threads still running!]
2 rbx 0x0000000100027eee rubinius::bug(char const*) + 94
3 rbx 0x00000001000f6c5c rubinius::SharedState::stop_the_world(rubinius::ManagedThread*) + 348
4 rbx 0x00000001000218b6 rubinius::Environment::halt() + 134
5 rbx 0x00000001001de32b main + 667
6 rbx 0x0000000100013788 start + 52
7 ??? 0x0000000000000003 0x0 + 3
---------------------------------------------
CRASH: A fatal error has occured.
Backtrace:
0 rbx 0x0000000100021d61 _ZN8rubiniusL12segv_handlerEi + 241
1 libSystem.B.dylib 0x00007fff806df66a _sigtramp + 26
2 ??? 0x700e0ca000000000 0x0 + 8074405063256178688
3 rbx 0x0000000100027ef3 _ZN8rubinius3bugEPKc + 99
4 rbx 0x00000001000f6c5c _ZN8rubinius11SharedState14stop_the_worldEPNS_13ManagedThreadE + 348
5 rbx 0x00000001000218b6 _ZN8rubinius11Environment4haltEv + 134
6 rbx 0x00000001001de32b main + 667
7 rbx 0x0000000100013788 start + 52
8 ??? 0x0000000000000003 0x0 + 3
Wrote full error report to: /Users/radarek/.rubinius_last_error
Run 'rbx report' to submit this crash report!
speed-up: threads 4.788/2.484 = 1.927
efficiency: 38.550%
speed-up: procs 4.788/2.571 = 1.862
efficiency: 37.244%
require 'benchmark'
def calc()
10000000.times{|i| i * i}
end
MAX_RUNS = ARGV[0] && ARGV[0].to_i || 5
def parallel(runs)
Benchmark.measure {
threads = []
runs.times{ threads << Thread.new{calc()} }
threads.each{|t| t.join}
}
end
def parallel_proc(runs)
Benchmark.measure {
pids = []
runs.times{
pid = fork
if pid
pids << pid
else
calc()
exit
end
}
pids.each{|pid| Process.wait(pid) }
}
end
def serial(runs)
Benchmark.measure {
runs.times{ calc() }
}
end
def print_speed_up(s_time, p_time, message,runs)
puts "speed-up: " + message + " " +
sprintf("%.3f",s_time) + "/" + sprintf("%.3f",p_time) + " = " +
sprintf("%.3f",s_time/p_time)
puts "efficiency: " + sprintf("%.3f",(s_time/p_time)/runs*100) + "%"
end
1.upto(MAX_RUNS) do |runs|
puts "#{runs} runs:"
serial_time = serial(runs).real
parallel_time = parallel(runs).real
parallel_p_time = parallel_proc(runs).real
print_speed_up(serial_time, parallel_time, "threads",runs)
print_speed_up(serial_time, parallel_p_time, "procs",runs)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment