How to measure your Ruby method performance ? [Ruby, Benchmark]
Hey Guys,  Today, we will use our reverse methods that we have
built in the previous post and measure how good they are
comparing to the Ruby built in reverse method. For this purpose
we will use Ruby Benchmark Module.  All we need to do is wrap
everything in Benchmark block, and every single method we want
to examine in the report block. As you can see from the code
below, I am also passing custom headers to differentiate
methods.  def time_required_comparison do |bm|'c-rev-string') do
reverse_whole_string('Welcome to myprogrammingblog')
end's-rev-string') do                 'Welcome to
myprogrammingblog'.reverse         end'c-rev-words') do
reverse_each_word_in_a_string('Welcome to myprogrammingblog')
end's-rev-words') do                 'Welcome to
myprogrammingblog'.split(" ").each {|word| word.reverse!}.join("
")         end'c-rev-word-order') do
reverse_word_order_in_a_sentence('Welcome to myprogrammingblog')
end's-rev-word-rder') do                 'Welcome to
myprogrammingblog'.split