Skip to content
Browse files

Added elementary graphing support

  • Loading branch information...
1 parent e8a8103 commit dea9938892dc89c7df2cb58b1efaf0da51105ad5 @wildfalcon wildfalcon committed Jul 15, 2008
Showing with 66 additions and 3 deletions.
  1. +13 −0 Graphs.txt
  2. +12 −3 bin/bong
  3. +41 −0 lib/bong.rb
View
13 Graphs.txt
@@ -0,0 +1,13 @@
+Extension to Bong for providing visual output
+---------------------------------------------
+
+After running bong a number of times, provide a visual output with time on the x axis and req/second on the y axis
+Intended to show the change in performance throughout the development of a project
+
+Assumptions
+* Each run will be named "benchmark-1216122887" where the second part can be converted to a Time class using Time.at(..)
+* Runs will be displayed at equal intervals along the x axis regardless of if the time between them is uniform
+* Several URLs may be incldued. rps for each one will be of a similar order of magnitude, so it makes sense to graph them together
+* Not all URLs will have data in all runs. However once a url is added it will be in ALL subsequent runs
+
+
View
15 bin/bong
@@ -25,7 +25,9 @@
begin
require "rubygems"
- require "bong"
+ require "gruff"
+ require File.dirname(__FILE__) + "/../lib/bong"
+# require "bong"
rescue LoadError
require File.dirname(__FILE__) + "/../lib/bong"
end
@@ -61,14 +63,18 @@ parser = OptionParser.new do |opts|
Bong.generate(v || OPTIONS[:generate]); exit
end
- opts.on("-o", "--out [PATH]", String, "Write output to a file.", "Default: log/httperf-report.yml") do |v|
+ opts.on("-o", "--out [PATH]", String, "Write output to a file.") do |v|
OPTIONS[:out] = v || OPTIONS[:out]
end
opts.on("-r", "--report PATH", String, "Display the report for a data file.") do |v|
OPTIONS[:report] = v
end
+ opts.on("-t", "--time-report PATH", String, "Create a time graph showing performance over time", "Only works when run in combination with -r") do |v|
+ OPTIONS[:graph] = v
+ end
+
opts.on("-h", "--help", "Show this help message.") { puts opts; exit }
opts.parse!(ARGV)
@@ -85,7 +91,10 @@ end
bong = Bong.new(OPTIONS[:config], OPTIONS[:label])
-if OPTIONS[:report]
+if OPTIONS[:graph] && OPTIONS[:report]
+ bong.graph_report(OPTIONS[:graph], OPTIONS[:report])
+ exit
+elsif OPTIONS[:report]
bong.load_report(OPTIONS[:report])
else
bong.run
View
41 lib/bong.rb
@@ -1,5 +1,7 @@
require 'yaml'
require 'logger'
+require 'gruff'
+
##
# A tool for running httperf against a website. Documentation coming soon.
@@ -59,6 +61,45 @@ def run
end
end
+
+ def graph_report(graph_path, report_yml_path)
+ @report = YAML.load(File.read(report_yml_path))
+
+ #remove any with no date
+ @report.reject!{ |name, data| name.split("-").size!=2}
+
+ number_of_times = @report.size
+
+ inverted_report = { }
+
+ @report.each do |name, data|
+ report_time = Time.at(name.split("-").last.to_i)
+ date_time = report_time.strftime("%d/%m %H:%M")
+
+ data.each do |host, urls|
+ urls.each do |url, payload|
+ inverted_report[url] ||= { }
+ inverted_report[url][date_time] = payload['avg'] || nil
+ end
+ end
+ end
+
+ inverted_report.each do |url, payload|
+ inverted_report[url][:array] = inverted_report[url].to_a.sort.map{|ele| ele.last}
+ missing_times = number_of_times - inverted_report[url][:array].size
+ inverted_report[url][:array] = Array.new(missing_times) + inverted_report[url][:array]
+ end
+
+ g = Gruff::Line.new
+ g.title = "Requests per second"
+
+ inverted_report.each do |url, payload|
+ g.data(url, inverted_report[url][:array])
+ end
+
+ g.write(graph_path)
+ end
+
def load_report(report_yml_path, label=nil)
@report = YAML.load(File.read(report_yml_path))
label = label || @label || @report.keys.first

0 comments on commit dea9938

Please sign in to comment.
Something went wrong with that request. Please try again.