Last Updated: February 25, 2016
·
4.592K
· ttoni

Simple measure of code execution time in Rails console

Obtained by Mandrakacards blog here. Using the Rails's Benchmark module.

Define method:

def time(&block) puts Benchmark.measure(&block) end

Then simply

time{Article.where('title like ?','Hello')}