No commit activity in last 3 years
No release in over 3 years
Allows to easy and quick profile method calls during rspec execution.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.10
~> 0.10
~> 10.0
>= 0

Runtime

~> 0.7
 Project Readme

Kantox::Chronoscope

Build Status Code Climate Test Coverage Issue Count

Chronoscope is designed for those, who has not enough foresight and starts benchmarking/profiling their applications when everything already is terrible.

On the other hand, Chronoscope is a lightweight solution, that permits to plug in benchmarks for virtually everything in a matter of seconds.

It just works out of the box: no modifications of application code is required. It permits benchmarking in production as well, though it is not recommended. The total impact on productivity is proven to be less that 1%.

Installation

Add this line to your application's Gemfile:

gem 'kantox-chronoscope'

And then execute:

$ bundle

Or install it yourself as:

$ gem install kantox-chronoscope

Usage

  1. Create the configuration file in config/chronoscope.yml:
general:
  handler: 'Kantox::Chronoscope::Generic'
  enable: true

options:
  silent: true

i18n:
  name: метод
  times: раз
  average: среднее
  total: всего
  1. Attach Chronoscope to one or more targets:
Kantox::Chronoscope.attach(Order) # all methods of Order
Kantox::Chronoscope.attach(User, :login) #    User#login

And somewhere in the execution end (e. g. when used with Rails, this goes into spec/spec_helper.rb):

config.after(:suite) do
  benchmarks = (cleanup: true)
end
  1. Get the following output:

Chronoscope log

Here silent options is set to false, that’s why we see logs from each subsequent call to monitored function.

  1. After execution, the result tree (with call hierarchy) is returned as:
puts '—'*($stdin.winsize.last rescue 80)
puts benchmarks[:data].inspect
puts '—'*($stdin.winsize.last rescue 80)
#⇒ {"Hedge#send_email_on_create"=>{:count=>26, :total=>0.00013026800000000003, :stack=>[]},
#   "Hedge#send_email_on_create="=>{:count=>11, :total=>4.066e-05, :stack=>[]},
#   "Hedge#hedge_type"=>{:count=>188, :total=>0.0024204860000000003, :stack=>[]} ...

Development

After checking out the repo, run bin/setup to install dependencies. Then, run rake spec to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and tags, and push the .gem file to rubygems.org.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/kantox-chronoscope. 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.