httperfrb 0.2.1 → 0.3.0pre1
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +2 -0
- data/README.md +13 -0
- data/lib/httperf/grapher.rb +58 -0
- data/lib/httperf/parser.rb +12 -10
- data/lib/httperf/version.rb +2 -1
- data/lib/httperf.rb +1 -0
- metadata +16 -13
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -68,6 +68,19 @@ Some basic usage examples.
|
|
68
68
|
|
69
69
|
# or verbose output
|
70
70
|
puts HTTPerf.parse( File.open("httperf_verbose.out", "r").read, true )
|
71
|
+
|
72
|
+
#### From the command line:
|
73
|
+
|
74
|
+
Something I've been playing around with, it's more of hack really. But it works well for seralizing output to YAML or JSON:
|
75
|
+
|
76
|
+
##### To JSON file:
|
77
|
+
|
78
|
+
httperf --num-conns=10 --verbose | ruby -e 'require "httperf/parser"; require "json"; puts HTTPerf::Parser.parse(ARGF.read).to_json' > httperf.json
|
79
|
+
|
80
|
+
##### To YAML file:
|
81
|
+
|
82
|
+
httperf --num-conns=10 --verbose | ruby -e 'require "httperf/parser"; require "yaml"; puts HTTPerf::Parser.parse(ARGF.read).to_yaml' > httperf.yml
|
83
|
+
|
71
84
|
|
72
85
|
|
73
86
|
##### Parser Keys:
|
@@ -0,0 +1,58 @@
|
|
1
|
+
class HTTPerf
|
2
|
+
class Grapher
|
3
|
+
attr_accessor :output_file
|
4
|
+
attr_reader :graph_settings
|
5
|
+
|
6
|
+
def initialize gs={}
|
7
|
+
begin
|
8
|
+
require 'gruff'
|
9
|
+
@output_file = "httperf_graph.png"
|
10
|
+
@graph_settings = default_graph_settings.merge(gs)
|
11
|
+
rescue LoadError
|
12
|
+
puts "WARNING: HTTPerf::Grapher not available -- please install 'gruff'."
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def graph_settings=(s)
|
17
|
+
@graph_settings = graph_settings.merge(s)
|
18
|
+
end
|
19
|
+
|
20
|
+
def graph results
|
21
|
+
raise "missing connection times" unless results.has_key?(:connection_times)
|
22
|
+
graph = Gruff::Line.new
|
23
|
+
|
24
|
+
conn_times = results[:connection_times].map { |i| i.to_f }
|
25
|
+
|
26
|
+
graph_settings.each do |key,val|
|
27
|
+
graph.send("#{key}=".to_sym, val)
|
28
|
+
end
|
29
|
+
|
30
|
+
graph.data("Connection Times", conn_times)
|
31
|
+
graph.data("Average [#{results[:connection_time_avg].to_f}]", draw_line(results[:connection_time_avg].to_f, conn_times.count))
|
32
|
+
graph.data("85th [#{results[:connection_time_85_pct].to_f}]", draw_line(results[:connection_time_85_pct].to_f, conn_times.count))
|
33
|
+
graph.data("95th [#{results[:connection_time_95_pct].to_f}]", draw_line(results[:connection_time_95_pct].to_f, conn_times.count))
|
34
|
+
graph.data("99th [#{results[:connection_time_99_pct].to_f}]", draw_line(results[:connection_time_99_pct].to_f, conn_times.count))
|
35
|
+
|
36
|
+
graph.labels = {}
|
37
|
+
(1..(conn_times.count/10)).each do |i|
|
38
|
+
graph.labels[i*10] = (i*10).to_s
|
39
|
+
end
|
40
|
+
|
41
|
+
graph.write(output_file)
|
42
|
+
end
|
43
|
+
|
44
|
+
private
|
45
|
+
def default_graph_settings
|
46
|
+
{
|
47
|
+
hide_dots: true,
|
48
|
+
legend_font_size: 14,
|
49
|
+
marker_font_size: 14,
|
50
|
+
title: "HTTPerf Results"
|
51
|
+
}
|
52
|
+
end
|
53
|
+
def draw_line value, length
|
54
|
+
(1..length).collect { value }
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
data/lib/httperf/parser.rb
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
#require 'parser/verbose'
|
2
1
|
class HTTPerf
|
3
2
|
|
4
3
|
# Parse httperf output to a [Hash]
|
@@ -6,22 +5,20 @@ class HTTPerf
|
|
6
5
|
# This can be used standalone or with HTTPerf results.
|
7
6
|
class Parser
|
8
7
|
|
9
|
-
attr_accessor :verbose
|
10
|
-
|
11
8
|
# @return [Hash] returns hash of parsed httperf output
|
12
9
|
# @param [String] raw httperf output
|
13
|
-
def self.parse raw, verbose=false
|
10
|
+
def self.parse raw, verbose=false, grapher=false
|
14
11
|
|
15
12
|
lines = raw.split("\n")
|
16
13
|
matches = {}
|
17
14
|
|
18
15
|
# for verbose matching
|
19
|
-
|
16
|
+
verbose_connection_times = []
|
20
17
|
|
21
18
|
lines.each do |line|
|
22
19
|
|
23
20
|
if verbose and verbose_expression.match(line)
|
24
|
-
|
21
|
+
verbose_connection_times.push($1)
|
25
22
|
next
|
26
23
|
end
|
27
24
|
|
@@ -37,9 +34,9 @@ class HTTPerf
|
|
37
34
|
end
|
38
35
|
end
|
39
36
|
|
40
|
-
unless
|
37
|
+
unless verbose_connection_times.empty?
|
41
38
|
percentiles.each do |percentile|
|
42
|
-
matches["connection_time_#{percentile}_pct".to_sym] = calculate_percentile(percentile,
|
39
|
+
matches["connection_time_#{percentile}_pct".to_sym] = calculate_percentile(percentile, verbose_connection_times)
|
43
40
|
end
|
44
41
|
end
|
45
42
|
|
@@ -48,6 +45,11 @@ class HTTPerf
|
|
48
45
|
else
|
49
46
|
raise "mismatch error occurred" unless expressions.keys.count == matches.keys.count
|
50
47
|
end
|
48
|
+
|
49
|
+
if grapher
|
50
|
+
matches[:connection_times] = verbose_connection_times
|
51
|
+
end
|
52
|
+
|
51
53
|
return matches
|
52
54
|
end
|
53
55
|
|
@@ -147,8 +149,8 @@ class HTTPerf
|
|
147
149
|
|
148
150
|
private
|
149
151
|
def self.calculate_percentile percentile, values
|
150
|
-
values.sort
|
151
|
-
|
152
|
+
v = values.sort
|
153
|
+
v[percentile_index(percentile, values.count)]
|
152
154
|
end
|
153
155
|
|
154
156
|
def self.percentile_index percentile, count
|
data/lib/httperf/version.rb
CHANGED
data/lib/httperf.rb
CHANGED
metadata
CHANGED
@@ -1,19 +1,19 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: httperfrb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
5
|
-
prerelease:
|
4
|
+
version: 0.3.0pre1
|
5
|
+
prerelease: 5
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Joshua Mervine
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-08-
|
12
|
+
date: 2012-08-13 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
16
|
-
requirement: &
|
16
|
+
requirement: &13531760 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *13531760
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: simplecov
|
27
|
-
requirement: &
|
27
|
+
requirement: &13530720 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *13530720
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: yard
|
38
|
-
requirement: &
|
38
|
+
requirement: &13529960 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *13529960
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: open4
|
49
|
-
requirement: &
|
49
|
+
requirement: &13528560 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,7 +54,7 @@ dependencies:
|
|
54
54
|
version: '0'
|
55
55
|
type: :runtime
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *13528560
|
58
58
|
description: Simple interface for calling httperf via ruby.
|
59
59
|
email:
|
60
60
|
- joshua@mervine.net
|
@@ -64,6 +64,7 @@ extra_rdoc_files: []
|
|
64
64
|
files:
|
65
65
|
- lib/httperf/version.rb
|
66
66
|
- lib/httperf/parser.rb
|
67
|
+
- lib/httperf/grapher.rb
|
67
68
|
- lib/httperf.rb
|
68
69
|
- README.md
|
69
70
|
- HISTORY.md
|
@@ -82,14 +83,16 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
82
83
|
version: '0'
|
83
84
|
segments:
|
84
85
|
- 0
|
85
|
-
hash:
|
86
|
+
hash: 3299317405384709120
|
86
87
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
87
88
|
none: false
|
88
89
|
requirements:
|
89
90
|
- - ! '>='
|
90
91
|
- !ruby/object:Gem::Version
|
91
92
|
version: 1.3.6
|
92
|
-
requirements:
|
93
|
+
requirements:
|
94
|
+
- rmagick version ~>2.13.1
|
95
|
+
- gruff version ~>0.3.6
|
93
96
|
rubyforge_project:
|
94
97
|
rubygems_version: 1.7.2
|
95
98
|
signing_key:
|