Project

etalon

0.0
Low commit activity in last 3 years
No release in over a year
A very simple tool to instrument Ruby code and output basic metrics to a logger or store them in a hash.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 3.8
~> 0.9
~> 2.2
~> 13.0
~> 1.1

Runtime

 Project Readme

Etalon Build Status Gem Version

A simple tool to instrument Ruby code and output basic metrics to a logger or store them in a hash.

From the French noun étalon meaning:

standard: something used as a measure for comparative evaluations

Installation

Add this line to your application's Gemfile:

gem 'etalon'

And then execute:

$ bundle

Or install it yourself as:

$ gem install etalon

In that last case, you'll need to manually require "etalon".

Usage

Assuming the following instrumented code:

  class Cooking
    def self.potato
      Etalon.time("Making taters") do
        peel_potato
        cook_potato
      end
    end
  end

You can do the following:

$ irb
require "cooking"
=> true

Etalon.activate
=> true

Etalon.print_timings
=> {:making_taters=>["count: 1", "min: 0", "max: 400", "mean: 400.0", "deviation: ±0%", "top 5: [400]"]}

If Rails.logger is available, Etalon will also output the following with a call to Rails.logger.debug in the relevant log file:

Making Taters - count: 1 | min: 0 | max: 400 | mean: 400.0 | deviation: ±0.0% | top 5: [400]

If Rails.logger isn't available, Etalon attempts to require syslog/logger from the Ruby standard library as a fallback logging mechanism.

Contributing

Bug reports and pull requests are welcome.

See contribution guidelines.