Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
The super easy way to benchmark methods in a live application
Ruby
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
lib
test
.gitignore
Gemfile
LICENSE.txt
README.md
Rakefile
benchmeth.gemspec

README.md

Benchmeth

The super easy way to benchmark methods in a live application

class Person

  def work(seconds)
    sleep(seconds)
  end
  benchmark :work

end

Works with class methods, too

class Person

  def self.find(id)
    sleep(2)
  end
  class << self
    benchmark :find
  end

end

By default, benchmark data is written to STDOUT in the following format:

compute : 1000 ms

but you can easily do whatever you want with it.

Benchmeth.on_benchmark do |method, realtime|
  # Log to a file
  logger.info "#{method} took #{realtime} seconds!"

  # Record a random sample of 1% of calls
  puts realtime if rand < 0.01

  # The default is
  puts "%s : %d ms" % [method, realtime * 1000]
end

To call a method without benchmarking, use:

compute_without_benchmark

Installation

Add this line to your application’s Gemfile:

gem 'benchmeth'

And then execute:

bundle

Contributing

Everyone is encouraged to help improve this project. Here are a few ways you can help:

Something went wrong with that request. Please try again.