Read more

Ruby: How to measure code execution time in an IRB or Rails console

Dominik Schöler
December 13, 2013Software engineer at makandra GmbH

Paste this method into your console:

def time(&block) puts Benchmark.measure(&block) end
Illustration UI/UX Design

UI/UX Design by makandra brand

We make sure that your target audience has the best possible experience with your digital product. You get:

  • Design tailored to your audience
  • Proven processes customized to your needs
  • An expert team of experienced designers
Read more Show archive.org snapshot

Now time { Some.lengthy_task } will behave similar to the bash time command. Of course you can do much more with the Benchmark object than just putsing it – adapt to your needs.

Posted by Dominik Schöler to makandra dev (2013-12-13 16:58)