0.0
Repository is archived
No commit activity in last 3 years
No release in over 3 years
Benchmarks methods
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.16
>= 0
~> 10.0
~> 3.0
 Project Readme

Benchmarked

This gem allows you to benchmark the running time of methods in ruby.

Installation

Add this line to your application's Gemfile:

gem 'benchmarked'

And then execute:

$ bundle

Or install it yourself as:

$ gem install benchmarked

Create a notifier in your application

class BenchmarkedNotifier
  def self.benchmark_taken(measurement, obj, method_name, args, result)
    # Log measurement to your logging service
  end
end
  • measurement: The result of Benchmark.measure
  • obj: The object that received the method_name call
  • method_name: The name of the method executed on obj
  • args: The arguments passed to the method invocation
  • result: The return value of the method invocation

Configure Benchmarked so that it uses the notifier. If you're using rails, this would live in config/initializers/benchmarked.rb

Benchmarked.configure do |config|
  config.notifier = BenchmarkedNotifier
end

Usage

Add handle_with_benchmark after your method definitions so that every call to them triggers a call to benchmark_taken on the notifier configured in Benchmarked.

For example, let's say that you have this class:

class SomeBusinessClass
  def business_method(arg1)
    # perform business logic
  end
  handle_with_benchmark :business_method
end

Because handle_with_benchmark :business_method is specified, a call like this:

SomeBusinessClass.new.business_method

Will trigger a call to BenchmarkedNotifier.benchmark_taken

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/bodyshopbidsdotcom/benchmarked-gem. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.

License

The gem is available as open source under the terms of the MIT License.

Code of Conduct

Everyone interacting in the Benchmarked project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.