httperfrb 0.3.0pre1 → 0.3.0pre2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,57 +1,7 @@
1
1
  class HTTPerf
2
2
  class Grapher
3
- attr_accessor :output_file
4
- attr_reader :graph_settings
5
-
6
3
  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 }
4
+ puts "WARNING: HTTPerf::Grapher not available -- please install 'httperfrb-grapher'."
55
5
  end
56
6
  end
57
7
  end
@@ -7,8 +7,9 @@ class HTTPerf
7
7
 
8
8
  # @return [Hash] returns hash of parsed httperf output
9
9
  # @param [String] raw httperf output
10
- def self.parse raw, verbose=false, grapher=false
10
+ def self.parse raw
11
11
 
12
+ verbose = false
12
13
  lines = raw.split("\n")
13
14
  matches = {}
14
15
 
@@ -17,7 +18,7 @@ class HTTPerf
17
18
 
18
19
  lines.each do |line|
19
20
 
20
- if verbose and verbose_expression.match(line)
21
+ if verbose_expression.match(line)
21
22
  verbose_connection_times.push($1)
22
23
  next
23
24
  end
@@ -38,18 +39,16 @@ class HTTPerf
38
39
  percentiles.each do |percentile|
39
40
  matches["connection_time_#{percentile}_pct".to_sym] = calculate_percentile(percentile, verbose_connection_times)
40
41
  end
42
+ matches[:connection_times] = verbose_connection_times
43
+ verbose = true
41
44
  end
42
45
 
43
46
  if verbose
44
- raise "mismatch error occurred" unless expressions.keys.count+percentiles.count == matches.keys.count
47
+ raise "mismatch error occurred" unless expressions.keys.count+percentiles.count+1 == matches.keys.count
45
48
  else
46
49
  raise "mismatch error occurred" unless expressions.keys.count == matches.keys.count
47
50
  end
48
51
 
49
- if grapher
50
- matches[:connection_times] = verbose_connection_times
51
- end
52
-
53
52
  return matches
54
53
  end
55
54
 
@@ -1,4 +1,4 @@
1
1
  class HTTPerf
2
- VERSION = "0.3.0pre1"
2
+ VERSION = "0.3.0pre2"
3
3
  end
4
4
 
data/lib/httperf.rb CHANGED
@@ -6,7 +6,7 @@ require 'httperf/version'
6
6
  class HTTPerf
7
7
 
8
8
  # @return [Boolean] parse flag
9
- attr_accessor :parse, :verbose
9
+ attr_accessor :parse
10
10
 
11
11
  # availbe instance methods
12
12
  @fork_out, @fork_err = ''
@@ -58,7 +58,6 @@ class HTTPerf
58
58
  # - wset
59
59
  def initialize options={}, path=nil
60
60
  self.parse = options.delete("parse")
61
- self.verbose = true if options.has_key?("verbose")
62
61
  options.each_key do |k|
63
62
  raise "'#{k}' is an invalid httperf param" unless params.keys.include?(k)
64
63
  end
@@ -91,7 +90,7 @@ class HTTPerf
91
90
  end
92
91
  if status == 0
93
92
  if @parse
94
- return Parser.parse(out.join, self.verbose)
93
+ return Parser.parse(out.join)
95
94
  else
96
95
  return out.join
97
96
  end
@@ -128,10 +127,6 @@ class HTTPerf
128
127
  return "#{@command} #{options}"
129
128
  end
130
129
 
131
- def verbose
132
- @verbose||false
133
- end
134
-
135
130
  private
136
131
  # build commandline options string
137
132
  def options
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: httperfrb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0pre1
4
+ version: 0.3.0pre2
5
5
  prerelease: 5
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2012-08-13 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
16
- requirement: &13531760 !ruby/object:Gem::Requirement
16
+ requirement: &11913560 !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: *13531760
24
+ version_requirements: *11913560
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: simplecov
27
- requirement: &13530720 !ruby/object:Gem::Requirement
27
+ requirement: &11913100 !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: *13530720
35
+ version_requirements: *11913100
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: yard
38
- requirement: &13529960 !ruby/object:Gem::Requirement
38
+ requirement: &11912600 !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: *13529960
46
+ version_requirements: *11912600
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: open4
49
- requirement: &13528560 !ruby/object:Gem::Requirement
49
+ requirement: &11899880 !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: *13528560
57
+ version_requirements: *11899880
58
58
  description: Simple interface for calling httperf via ruby.
59
59
  email:
60
60
  - joshua@mervine.net
@@ -83,16 +83,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
83
83
  version: '0'
84
84
  segments:
85
85
  - 0
86
- hash: 3299317405384709120
86
+ hash: -3739833727762130142
87
87
  required_rubygems_version: !ruby/object:Gem::Requirement
88
88
  none: false
89
89
  requirements:
90
90
  - - ! '>='
91
91
  - !ruby/object:Gem::Version
92
92
  version: 1.3.6
93
- requirements:
94
- - rmagick version ~>2.13.1
95
- - gruff version ~>0.3.6
93
+ requirements: []
96
94
  rubyforge_project:
97
95
  rubygems_version: 1.7.2
98
96
  signing_key: