For 0.2.0 you must call #finish to calculate results
execution time is saved with #call, and calculated later with #finish
documentation will be added ...
Benchify

Benchmark measures for different languages. Compare scripts created in Ruby, Python, Bash... or check different methods execution time in Ruby source code.
Benchify count only a real execution time, in seconds. You can set a default count-type, but anyway you'll be able to access values in seconds, milliseconds, minutes and hours. You can also get a time when operation started/ended. Purpose of this is to get an easy way to count anything you do in terminal, including shell commands like sudo apt update
.
How to install
Install from rubygems:
gem install benchify
gem 'benchify', '~> 0.1.1'
Install from source:
git clone https://github.com/decentralizuj/benchify
cd benchify
# no dependecies needed for production, only bundler and rake for development
bundle install
How to use
Benchmark Ruby Source-Code:
Initialize new object with type and message (both are optional). Default type is :sec
, and message is processed time
. Here's a list of available symbols for type, anything else would lead to counting in seconds.
hours => :h, :hour, :hours
minutes => :m, :min, :minute, :minutes
milliseconds => :ms, :milli, :milliseconds
benchmark = Benchify.new(:ms)
You can override default message constant, if you want to
Benchify::MESSAGE = 'Your Message Here'
benchmark = Benchify.new( :ms, 'Your Message Here' )
Now you can call method #call
or it's alias #measure
benchmark.call { YOUR CODE HERE }
benchmark.measure do
end
benchmark.measure('counting seconds:') do
end
Benchmark Terminal:
Make sure your script has shebang (environment defined)
#!/usr/bin/env ruby
benchify script_1.rb script_2.py script_3.sh
Use -e
to benchmark shell commands (use this if you don't have shebang in script)
benchify -e 'sudo apt update' 'gem install moriarty' 'python3 somefile.py'
Example
If you don't like name Benchify
, you can also use Benchmark
benchmark = Benchmark.new :sec, ' counted seconds:'
benchmark.call { ... }
benchmark.measure('change_message:') { ... }
Attributes:
benchmark.message => 'processed time:'
benchmark.type => :sec
benchmark.start => Time.now (when started)
benchmark.end => Time.now (when ended)
benchmark.total => Total seconds (float)
benchmark.time => counted time by type (in_seconds)
benchmark.result => message + time + type (processed time: 22.124 sec)
benchmark.in_seconds => access time in seconds
benchmark.in_minutes => access time in minutes
benchmark.in_hours => access time in hours
benchmark.in_ms => access time in milliseconds
TO-DO
- Documentation
- Save output
- Self methods ( ms, seconds, minutes, hours )