public
Rubygem
Description: A benchmarking helper for httperf.
Homepage: http://bong.rubyforge.org/
Clone URL: git://github.com/topfunky/bong.git
Added elementary graphing support
wildfalcon (author)
Tue Jul 15 07:58:10 -0700 2008
commit  dea9938892dc89c7df2cb58b1efaf0da51105ad5
tree    d43491991eaace9ab7c38dd0254182505f4a92cc
parent  e8a8103e60d62e19d62a0f14e260e322512b122b
...
25
26
27
28
 
 
 
29
30
31
...
61
62
63
64
 
65
66
67
...
69
70
71
 
 
 
 
72
73
74
...
85
86
87
88
 
 
 
 
89
90
91
...
25
26
27
 
28
29
30
31
32
33
...
63
64
65
 
66
67
68
69
...
71
72
73
74
75
76
77
78
79
80
...
91
92
93
 
94
95
96
97
98
99
100
0
@@ -25,7 +25,9 @@
0
 
0
 begin
0
   require "rubygems"
0
- require "bong"
0
+ require "gruff"
0
+ require File.dirname(__FILE__) + "/../lib/bong"
0
+# require "bong"
0
 rescue LoadError
0
   require File.dirname(__FILE__) + "/../lib/bong"
0
 end
0
@@ -61,7 +63,7 @@ parser = OptionParser.new do |opts|
0
     Bong.generate(v || OPTIONS[:generate]); exit
0
   end
0
 
0
- opts.on("-o", "--out [PATH]", String, "Write output to a file.", "Default: log/httperf-report.yml") do |v|
0
+ opts.on("-o", "--out [PATH]", String, "Write output to a file.") do |v|
0
     OPTIONS[:out] = v || OPTIONS[:out]
0
   end
0
 
0
@@ -69,6 +71,10 @@ parser = OptionParser.new do |opts|
0
     OPTIONS[:report] = v
0
   end
0
 
0
+ 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|
0
+ OPTIONS[:graph] = v
0
+ end
0
+
0
   opts.on("-h", "--help", "Show this help message.") { puts opts; exit }
0
 
0
   opts.parse!(ARGV)
0
@@ -85,7 +91,10 @@ end
0
 
0
 bong = Bong.new(OPTIONS[:config], OPTIONS[:label])
0
 
0
-if OPTIONS[:report]
0
+if OPTIONS[:graph] && OPTIONS[:report]
0
+ bong.graph_report(OPTIONS[:graph], OPTIONS[:report])
0
+ exit
0
+elsif OPTIONS[:report]
0
   bong.load_report(OPTIONS[:report])
0
 else
0
   bong.run
...
1
2
 
 
3
4
5
...
59
60
61
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
62
63
64
...
1
2
3
4
5
6
7
...
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
0
@@ -1,5 +1,7 @@
0
 require 'yaml'
0
 require 'logger'
0
+require 'gruff'
0
+
0
 
0
 ##
0
 # A tool for running httperf against a website. Documentation coming soon.
0
@@ -59,6 +61,45 @@ class Bong
0
     end
0
   end
0
 
0
+
0
+ def graph_report(graph_path, report_yml_path)
0
+ @report = YAML.load(File.read(report_yml_path))
0
+
0
+ #remove any with no date
0
+ @report.reject!{ |name, data| name.split("-").size!=2}
0
+
0
+ number_of_times = @report.size
0
+
0
+ inverted_report = { }
0
+
0
+ @report.each do |name, data|
0
+ report_time = Time.at(name.split("-").last.to_i)
0
+ date_time = report_time.strftime("%d/%m %H:%M")
0
+
0
+ data.each do |host, urls|
0
+ urls.each do |url, payload|
0
+ inverted_report[url] ||= { }
0
+ inverted_report[url][date_time] = payload['avg'] || nil
0
+ end
0
+ end
0
+ end
0
+
0
+ inverted_report.each do |url, payload|
0
+ inverted_report[url][:array] = inverted_report[url].to_a.sort.map{|ele| ele.last}
0
+ missing_times = number_of_times - inverted_report[url][:array].size
0
+ inverted_report[url][:array] = Array.new(missing_times) + inverted_report[url][:array]
0
+ end
0
+
0
+ g = Gruff::Line.new
0
+ g.title = "Requests per second"
0
+
0
+ inverted_report.each do |url, payload|
0
+ g.data(url, inverted_report[url][:array])
0
+ end
0
+
0
+ g.write(graph_path)
0
+ end
0
+
0
   def load_report(report_yml_path, label=nil)
0
     @report = YAML.load(File.read(report_yml_path))
0
     label = label || @label || @report.keys.first

Comments

    No one has commented yet.