0.0
The project is in a healthy, maintained state
Create accurate timings of excution in Ruby reliably, er with monotony!
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
 Dependencies
 Project Readme

monotony.rb

Description

Create accurate timings of excution in Ruby reliably, er with monotony!

Installation

Add this line to your application's Gemfile:

  gem 'monotony.rb'

And then execute:

  $ bundle

Or install it yourself as:

$ gem install monotony.rb

Usage

Monotony::MonotonicTime

  require 'monotony.rb'
  include Monotony
  monotonic_time = MonotonicTime.new
  monotonic_time.seconds_since_boot
  # => 1208799.325906
  monotonic_time + MonotonicTime.now
  # => 2417598.681896
  monotonic_time - MonotonicTime.now
  # => -0.044104999862611294
  monotonic_time.to_s
  # => "1164320.268127 seconds since boot."
  monotonic_time.to_time
  # => 2021-06-07 09:27:08 8249692651179/8388608000000 +1000

Monotony::MonotonicTimer with a block

require 'monotony.rb'
include Monotony
time = MonotonicTimer.time do |timer|
  i = 0
  1_000_000.times{puts i += 1}
end
time
# => 6.975823000073433

Monotony::MonotonicTimer without a block

require 'monotony.rb'
include Monotony
timer = MonotonicTimer.new
timer.start
i = 0
1_000_000.times{puts i += 1}
timer.stop
timer.total_time
# => 7.166559999808669

Monotony::MonotonicTimer with a block on a timer instance

require 'monotony.rb'
include Monotony
timer = MonotonicTimer.new
time = timer do |timer|
  i = 0
  1_000_000.times{puts i += 1}
end
time
# => 7.033131000120193

Contributing

  1. Fork it ( https://github.com/thoran/monotony.rb/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new pull request