https://github.com/am-kantox/kantox-chronoscope
Handy [semi-]automated profiler for ruby. Allows to easy and quick profile method calls during rspec execution. Supports profiling by “newly committed to git,” “last two month,” etc.
https://github.com/am-kantox/kantox-chronoscope
Last synced: 27 days ago
JSON representation
Handy [semi-]automated profiler for ruby. Allows to easy and quick profile method calls during rspec execution. Supports profiling by “newly committed to git,” “last two month,” etc.
- Host: GitHub
- URL: https://github.com/am-kantox/kantox-chronoscope
- Owner: am-kantox
- License: mit
- Created: 2016-03-21T16:02:26.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2017-09-18T09:00:42.000Z (over 7 years ago)
- Last Synced: 2025-02-09T19:53:07.770Z (3 months ago)
- Language: Ruby
- Size: 114 KB
- Stars: 0
- Watchers: 6
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# Kantox::Chronoscope
[](https://travis-ci.org/am-kantox/kantox-chronoscope)
[](https://codeclimate.com/github/am-kantox/kantox-chronoscope)
[](https://codeclimate.com/github/am-kantox/kantox-chronoscope/coverage)
[](https://codeclimate.com/github/am-kantox/kantox-chronoscope)`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:
```ruby
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`:
```yaml
general:
handler: 'Kantox::Chronoscope::Generic'
enable: trueoptions:
silent: truei18n:
name: метод
times: раз
average: среднее
total: всего
```2. Attach `Chronoscope` to one or more targets:
```ruby
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`):```ruby
config.after(:suite) do
benchmarks = ⌛(cleanup: true)
end
```3. Get the following output:

Here `silent` options is set to `false`, that’s why we see logs from each subsequent
call to monitored function.4. After execution, the result tree (with call hierarchy) is returned as:
```ruby
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](https://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](contributor-covenant.org) code of conduct.
## License
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).