0.0
No commit activity in last 3 years
No release in over 3 years
benchmark-plot is an extension to the Ruby standard benchmarking library. It let's you easily create plots of any code that you want to benchmark over a varied number of inputs. It also supports comparative benchmarking.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

>= 0
 Project Readme

benchmark-plot

A Ruby benchmark extension to allow comparative plotting of benchmarks.

Screencast

Watch a screencast of gem usage here.

Usage

This gem is mainly useful for benchmarking code over a number of inputs. This input should be supplied in the form of an object capable of calling #each.

Sample benchmarking script:

require 'benchmark/plot'

class TestArray
  attr_reader :arr

  def initialize arr
    @arr = arr
  end

  def to_s
    @arr.size.to_s
  end
end

test_data = [5, 25, 50, 75, 100, 125, 150, 175, 200,250,300]
test_data.map! {|e| TestArray.new(Array.new(e) {|i| i}) }

Benchmark.plot(test_data) do |x|
  x.report("map.flatten") do |data|
    data.arr.map { [nil]  }.flatten
  end

  x.report("flat_map") do |data|
    data.arr.flat_map { [nil] }
  end
end

Output:

Benchmarks

Acknowledgements

@tgxworld for providing the co-working space during the Open Source Breakfast Hack during Red Dot Ruby Conference 2016 where this gem was built.