For this we can use the `Benchmark` library available in Rails like below.
puts '====== Start benchmark ========'
time = Benchmark.realtime {
... Code being tested goes here ...
}
puts time
puts '====== End benchmark =========='
}
puts time
puts '====== End benchmark =========='