Skip to content

Instantly share code, notes, and snippets.

@inkel
Created December 1, 2012 12:08
Show Gist options
  • Save inkel/4181899 to your computer and use it in GitHub Desktop.
Save inkel/4181899 to your computer and use it in GitHub Desktop.
Benchmark for comparison of homebrew's ruby with and without CFLAGS="-march=native -O3"
>> /usr/bin/time -l ruby thebench.rb 30 1000
Rehearsal --------------------------------------------------------
fib(30) 0.260000 0.000000 0.260000 ( 0.255475)
1000 tempfiles 0.120000 0.250000 0.370000 ( 0.429621)
----------------------------------------------- total: 0.630000sec
user system total real
fib(30) 0.260000 0.000000 0.260000 ( 0.259108)
1000 tempfiles 0.130000 0.270000 0.400000 ( 0.848950)
1.85 real 0.79 user 0.52 sys
7073792 maximum resident set size
0 average shared memory size
0 average unshared data size
0 average unshared stack size
1743 page reclaims
0 page faults
0 swaps
42 block input operations
85 block output operations
0 messages sent
0 messages received
0 signals received
65 voluntary context switches
1893 involuntary context switches
>> /usr/bin/time -l rake test
280 tests, 994 assertions (280 passed, 0 pending, 0 failed, 0 errored)
Ran in 11.013013 seconds
13.89 real 10.85 user 0.81 sys
51933184 maximum resident set size
0 average shared memory size
0 average unshared data size
0 average unshared stack size
12864 page reclaims
78 page faults
0 swaps
11 block input operations
107 block output operations
39957 messages sent
28111 messages received
0 signals received
1193 voluntary context switches
242 involuntary context switches
>> /usr/bin/time -l bin/ruby thebench.rb 30 1000
Rehearsal --------------------------------------------------------
fib(30) 0.260000 0.000000 0.260000 ( 0.255356)
1000 tempfiles 0.120000 0.250000 0.370000 ( 0.457608)
----------------------------------------------- total: 0.630000sec
user system total real
fib(30) 0.260000 0.000000 0.260000 ( 0.256357)
1000 tempfiles 0.120000 0.250000 0.370000 ( 0.433369)
1.44 real 0.79 user 0.50 sys
7438336 maximum resident set size
0 average shared memory size
0 average unshared data size
0 average unshared stack size
1832 page reclaims
0 page faults
0 swaps
3 block input operations
71 block output operations
0 messages sent
0 messages received
0 signals received
33 voluntary context switches
1892 involuntary context switches
>> /usr/bin/time -l ~/dev/tmp/homebrew/bin/rake test
280 tests, 994 assertions (280 passed, 0 pending, 0 failed, 0 errored)
Ran in 10.628247 seconds
Coverage report generated for Protest to /Users/inkel/dev/citrusbyte/bleuacre/coverage. 1278 / 1686 LOC (75.8%) covered.
11.89 real 10.73 user 0.79 sys
49840128 maximum resident set size
0 average shared memory size
0 average unshared data size
0 average unshared stack size
12267 page reclaims
154 page faults
0 swaps
2 block input operations
31 block output operations
39955 messages sent
28099 messages received
0 signals received
1090 voluntary context switches
203 involuntary context switches
require "benchmark"
require "tempfile"
def fib n
case n
when 0 then 0
when 1 then 1
else
fib(n-1) + fib(n-2)
end
end
n = (ARGV[0] || 10).to_i
t = (ARGV[1] || 1000).to_i
Benchmark.bmbm(20) do |r|
r.report("fib(#{n})") { fib(n) }
r.report("#{t} tempfiles") do
t.times do |i|
tmp = Tempfile.new("bench")
begin
tmp.write i
rescue
ensure
tmp.close
tmp.unlink
end
end
end
end
puts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment