Here I present an introduction to benchmark-plot, a gem that I've developed for easily creating plots of benchmarks. Presented at Pune Ruby Users Group at the July Meetup.
|x| x.report("map.flat") do |size| (1..size).to_a.map { |e| [e,e] }.flatten end x.report("flat_map") do |size| (1..size).to_a.flat_map { |e| [e,e] } end end
|size| (1..size).to_a } Benchmark.plot(arr) do |x| x.report("map.flat") do |a| a.map { |e| [e,e] }.flatten end x.report("flat_map") do |a| a.flat_map { |e| [e,e] } end end
|size| (1..size).to_a } Benchmark.plot(arr) do |x| x.report("map.flat") do |a| a.map { |e| [e,e] }.flatten end x.report("flat_map") do |a| a.flat_map { |e| [e,e] } end end
|size| TestArray.new (1..size).to_a } Benchmark.plot(arr) do |x| x.report("map.flat") do |a| a.data.map { |e| [e,e] }.flatten end x.report("flat_map") do |a| a.data.flat_map { |e| [e,e] } end end
graph. • :x_labels – Toggle whether X axis labels should be displayed. • :x_axis_label – A string for the label of the X axis. • :time – The kind of time that you want plotted (real time or system CPU time or user CPU time). • :file_name – The file name of the graph.