Benchmark.bm do |performance| performance.report('thing1') { # your code here } performance.report('thing2') { # your code here } ... end
The times may vary dramatically between running Benchmark.bm. In an attempt to standardize benchmark times, Benchmark.bmbm runs a "rehearsal", then runs GC.start, then runs the real thing.
Benchmark.bmbm do |performance| performance.report('thing1') { # your code here } performance.report('thing2') { # your code here } ... end
ruby -rprofile filename.rb
gem install ruby-prof ruby-prof filename.rb