How to get execution time in rails console?

Bohdan picture Bohdan · Aug 19, 2010 · Viewed 34.9k times · Source

I want compare time of execution Post.all and SELECT * FROM posts (or some other statements) How can i get execution time of Post.all ?

Answer

Shadwell picture Shadwell · Aug 19, 2010
timing = Benchmark.measure { Post.all }

The various attributes of the object returned (Benchmark::Tms) are provided here.