https://github.com/davydovanton/bruevich
https://github.com/davydovanton/bruevich
Last synced: 4 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/davydovanton/bruevich
- Owner: davydovanton
- License: mit
- Created: 2016-07-26T20:04:28.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2019-07-15T15:50:21.000Z (almost 6 years ago)
- Last Synced: 2025-01-21T22:08:53.946Z (5 months ago)
- Language: Ruby
- Size: 20.5 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
**This repository is no longer maintain**
# Bruevich
[](https://travis-ci.org/davydovanton/bruevich)Simple library for benching your code.
## Installation
Add this line to your application's Gemfile:
```ruby
gem 'bruevich'
```And then execute:
$ bundle
Or install it yourself as:
$ gem install bruevich
## Usage
```ruby
require 'pp'bruevich = Bruevich.new
bruevich.bench do
(1..1_000_000).to_a
endbruevich.result
```Also you can change iterations ( by default - `[1, 10, 50, 100, 150]`).
```ruby
bruevich = Bruevich.new(iterations: [1, 2, 3, 4, 5])# or
bruevich = Bruevich.new
bruevich.iterations = [1, 2, 3, 4, 5]
```## After callback
``` ruby
bruevich = Bruevich.newbruevich.after { puts 'done' }
bruevich.bench do
(1..1_000_000).to_a
endbruevich.result
```### Returned values
`Bench` class returns hash with values. **Please notice that all memory values in kb**.```
{
title: String
iteration_count(Integer) => {
time: {
per_iteration: Array,
total: Float,
average: Float
},
mem: {
per_iteration: Array,
total: Integer,
average: Integer
}
},...
}
```### Plotters
You can use custom plotter classes. For this you need to create class with `plot` method:
```ruby
class MyPlotter
def plot(result, iterations)
# your code here
end
end
```And initialize bruevich class with it:
```ruby
bruevich = Bruevich.new(plotter: MyPlotter.new)
bruevich.bench do
(1..1_000_000).to_a
endbruevich.result # => your custom output
```### Disabled benchmarks
You can use `:disable_memory` option for switch off memory benchmark.## Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/davydovanton/bruevich. 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).