Jason Lillywhite wrote:
> Is there an easy way to display the time it takes to compute any
> function from within IRB?


If I understand correctly, there is the Benchmark module

http://www.ruby-doc.org/stdlib/libdoc/benchmark/rdoc/classes/Benchmark.html


>> require 'benchmark'
=> true
>> Benchmark.bmbm do |x|
?> x.report('concat') {s='t ';(1..10000).step do |x| s.concat(x.to_s) 
end}
?> x.report('<<') {s='t ';(1..10000).step do |x| s << x.to_s end}
>> end
Rehearsal ------------------------------------------
concat   0.010000   0.000000   0.010000 (  0.008603)
<<       0.010000   0.000000   0.010000 (  0.007354)
--------------------------------- total: 0.020000sec

             user     system      total        real
concat   0.000000   0.000000   0.000000 (  0.006930)
<<       0.010000   0.000000   0.010000 (  0.007101)
-- 
Posted via http://www.ruby-forum.com/.