Project

era

0.0
No commit activity in last 3 years
No release in over 3 years
Print the time a block takes but still return its value.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies

Development

~> 1.4
>= 0
 Project Readme

Era

Era is just a pinch of benchmarking sugar in the form of a gem. It prints the time a block takes to execute but still returns its original return value.

Era is inspired by Clojure's time benchmarking function, which very similarly prints the time it took to exectue but returns the expression's value. Era also gives the option to specify the number of times to run the block but still returns the value from the last run.

Era adds the Era.time method to Kernel so you can just time do instead of Era.time do to benchmark your block.

Usage

require 'era'

time do
  sleep 2
  1 + 1
end
#>> Elapsed time: 2000.0369999999998 ms
#=> 2
require 'era'

time(1_000_000) { 1 + 1 }
#>> Elapsed time: 75.89999999999999 ms
#=> 2
require 'era'

time 1000 do
  (99 ** 99) / (88 ** 88)
end
#>> Elapsed time: 3.1510000000000002 ms
#=> 284059367663871701169263886

Installation

gem install era

Contributing

  1. Fork it
  2. Commit changes
  3. Pull request