Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/vasilakisfil/class_profiler
Simple performance profiler with some strong metaprogramming alcohol
https://github.com/vasilakisfil/class_profiler
Last synced: about 2 months ago
JSON representation
Simple performance profiler with some strong metaprogramming alcohol
- Host: GitHub
- URL: https://github.com/vasilakisfil/class_profiler
- Owner: vasilakisfil
- License: mit
- Created: 2016-11-28T20:34:54.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2018-07-05T16:21:14.000Z (over 6 years ago)
- Last Synced: 2024-04-25T22:22:18.125Z (8 months ago)
- Language: Ruby
- Size: 18.6 KB
- Stars: 8
- Watchers: 2
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# ClassProfiler
Simple performance analyzer for Ruby classes. Just include it in the bottom of
your class and let it analyze your Ruby class performance.
Motivation and detailed explanation can be found in [this blog post](https://blog.kollegorna.se/ruby-performance-profiling-an-unorthodox-approach-69c549e3293b).## Installation
Add this line to your application's Gemfile:
```ruby
gem 'class_profiler'
```And then execute:
$ bundle
Or install it yourself as:
$ gem install class_profiler
## Usage
It can be used only for classes. You need to include it in the **bottom** of your class:```ruby
class Foobar
#includes/extend definitions#methods
def hard_working_method
end
#more methodsinclude ClassProfiler #include it just before closing the class
end
```Or if you want something more configurable, to measure only specific methods and/or
modules you can use this little API:
```ruby
include ClassProfiler.for(instance_methods: [
:on_correct_scale, :on_correct_currency, :as_financial_value
], modules: [Financial, Company])
```It comes with a built-in rack middleware to report you the whole request-response cycle
(but you still have to `include ClassProfiler` in the classes of your interest)```ruby
config.middleware.use ClassProfiler::Rack
```If you want something more specific, then you only need to wrap the code of your
interest under `start` block:```ruby
ClassProfiler::Benchmark.instance.start 'MY LABEL' do
#code I want to benchmark
end
```Note that `ClassProfiler::Benchmark` class is a singleton.
## How does it work?
You can find details on the motivation and implementation in [this blog post](https://blog.kollegorna.se/ruby-performance-profiling-an-unorthodox-approach-69c549e3293b).## Development
After checking out the repo, run `bin/setup` to install dependencies. 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/vasilakisfil/class_profiler. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://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).