You can investigate how long something is taking using the Benchmark
library.
require 'benchmark'
Benchmark.measure { some_code_I_want_to_profile }
For more detailed profiling (e.g. to tell you how much time is spent in which part of the call stack, use ruby-prof.
require 'ruby-prof'
result = RubyProf.profile { some_code_I_want_to_profile }
# To view the results you need to use a "Printer". For example, to view in a web browser:
File.open('results-stack.html', 'w') {|f| RubyProf::CallStackPrinter.new(result).print(f) }
File.open('results.html', 'w') {|f| RubyProf::GraphHtmlPrinter.new(result).print(f) }