Skip to content

Instantly share code, notes, and snippets.

@tomas-stefano
Created February 20, 2010 15:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tomas-stefano/309725 to your computer and use it in GitHub Desktop.
Save tomas-stefano/309725 to your computer and use it in GitHub Desktop.
Benchmark Ruby Graphs
user system total real
gruff 0.880000 0.040000 0.920000 (0.849686)
scruffy 2.470000 1.910000 4.380000 (3.361562)
require "rubygems"
require "gruff"
require "scruffy"
require "benchmark"
include Benchmark
def gruff_example
5.times do |number|
gruff = Gruff::Line.new
gruff.theme = {
:background_colors => %w(white white),
:colors => %w(black red purple orange),
:marker_color => '#4a465a'
}
gruff.title = "Gruff Line graph"
gruff.data("Peaches", [9, 9, 10, 8, 7, 9])
gruff.data("Watermelon", [2, 3, 1, 5, 6, 8])
gruff.write("my_fruity_graph#{number}.png")
end
end
def scruffy_example
5.times do |number|
graph = Scruffy::Graph.new
graph.title = "Sample Line Graph"
graph.renderer = Scruffy::Renderers::Standard.new
graph.add :line, 'Peaches', [9, 9, 10, 8, 7, 9]
graph.add :line, 'Watermelon', [2, 3, 1, 5, 6, 8]
graph.render :to => "pie_test.svg"
graph.render :width => 800, :height => 600,
:to => "line_test#{number}.png", :as => 'png'
end
end
Benchmark.benchmark do |x|
x.report('gruff') { gruff_example }
x.report('scruffy') { scruffy_example }
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment