autoperf 1.0.4 → 1.1.0beta1

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -2,8 +2,13 @@ source "https://rubygems.org"
2
2
 
3
3
  gemspec
4
4
 
5
+ if RUBY_VERSION < "1.9.0"
6
+ gem 'json'
7
+ end
8
+
5
9
  group :development do
6
- gem 'rake'
7
10
  gem 'pry'
8
11
  gem 'pry-doc'
9
12
  end
13
+
14
+ # vim: filetype=ruby:
data/lib/autoperf.rb CHANGED
@@ -6,22 +6,26 @@ require 'autoperf/display'
6
6
 
7
7
  class Autoperf
8
8
  def initialize(config_file, opts = {})
9
- @conf = parse_config(config_file).merge(opts)
10
- @perf = HTTPerf.new(@conf)
9
+ @conf = parse_config(config_file).merge(opts)
10
+ @perf = HTTPerf.new(@conf)
11
11
  @perf.parse = true
12
- @perf.tee = true if @tee
12
+ @perf.tee = true if @tee
13
13
  end
14
14
 
15
15
  def parse_config(config_file)
16
16
  raise Errno::EACCES, "#{config_file} is not readable" unless File.readable?(config_file)
17
17
  config = YAML::load(File.open(config_file, 'r'))
18
- @rates = {
18
+
19
+ @rates = {
19
20
  :low_rate => config.delete('low_rate'),
20
21
  :high_rate => config.delete('high_rate'),
21
22
  :rate_step => config.delete('rate_step')
22
23
  }
23
- @cols = config.delete('display_columns') if config.has_key?('display_columns')
24
- @tee = config.delete('tee')||false
24
+
25
+ @cols = config.delete('display_columns') if config.has_key?('display_columns')
26
+ @tee = config.delete('tee')||false
27
+ @format = config.delete('display_format').to_sym if config.has_key?('display_format')
28
+
25
29
  return config
26
30
  end
27
31
 
@@ -34,21 +38,28 @@ class Autoperf
34
38
  return @results
35
39
  end
36
40
 
37
- def display
41
+ def display(type=@format)
38
42
  @results ||= {}
39
- if @cols
40
- Autoperf::Display.new(@results, @cols)
43
+ @cols ||= nil
44
+ case type
45
+ when :csv
46
+ Autoperf::Display::CSV.new(@results, @cols)
47
+ when :json
48
+ Autoperf::Display::JSON.new(@results, @cols)
41
49
  else
42
- Autoperf::Display.new(@results)
50
+ Autoperf::Display::Console.new(@results, @cols)
43
51
  end
44
52
  end
45
53
 
46
54
  def to_s
47
- display.to_s
55
+ display(:console).to_s
56
+ end
57
+
58
+ def to_csv
59
+ display(:csv).to_csv
48
60
  end
49
61
 
50
62
  def to_json
51
- @results ||= {}
52
- @results.to_json
63
+ display(:json).to_json
53
64
  end
54
65
  end
@@ -1,40 +1,22 @@
1
1
  require 'ruport'
2
+ require 'json'
3
+ require 'autoperf/display/console'
4
+ require 'autoperf/display/csv'
5
+ require 'autoperf/display/json'
2
6
  class Autoperf
3
7
  class Display
4
- def initialize results, report=nil
5
- @table = if report.kind_of?(Array)
6
- table_from_array(report)
7
- elsif report.kind_of?(Ruport::Data::Table)
8
- report
9
- else
10
- # ignore input and use defaults
11
- table_from_array([
12
- :rate,
13
- :connection_rate_per_sec,
14
- :request_rate_per_sec,
15
- :connection_time_avg,
16
- :errors_total,
17
- :reply_status_5xx,
18
- :net_io_kb_sec
19
- ])
20
- end
21
- results.each do |rate, result|
22
- result.merge!(:rate => rate) if @table.column_names.include?(:rate)
23
- @table << result
24
- end
25
- end
8
+ DEFAULT_FIELDS = [
9
+ :rate,
10
+ :connection_rate_per_sec,
11
+ :request_rate_per_sec,
12
+ :connection_time_avg,
13
+ :errors_total,
14
+ :reply_status_5xx,
15
+ :net_io_kb_sec
16
+ ]
26
17
 
27
- def to_s
28
- @table.to_s
29
- end
30
-
31
- def print
32
- puts to_s
33
- end
34
-
35
- def table_from_array report
36
- Table(:column_names => report)
37
- end
18
+ # class Console # display/console
19
+ # class CSV # display/csv
20
+ # class JSON # display/json
38
21
  end
39
22
  end
40
-
@@ -0,0 +1,35 @@
1
+ class Autoperf::Display
2
+ class Console
3
+ def initialize results, report=nil
4
+ @table = if report.kind_of?(Array)
5
+ table_from_array(report)
6
+ elsif report.kind_of?(Ruport::Data::Table)
7
+ report
8
+ else
9
+ # ignore input and use defaults
10
+ table_from_array(::Autoperf::Display::DEFAULT_FIELDS)
11
+ end
12
+ results.each do |rate, result|
13
+ result.merge!(:rate => rate) if @table.column_names.include?(:rate)
14
+ @table << result
15
+ end
16
+ @table
17
+ end
18
+
19
+ def table
20
+ @table
21
+ end
22
+
23
+ def to_s
24
+ @table.to_s
25
+ end
26
+
27
+ def print
28
+ puts to_s
29
+ end
30
+
31
+ def table_from_array report
32
+ Table(:column_names => report)
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,19 @@
1
+ class Autoperf::Display
2
+ class CSV
3
+ def initialize results, report=nil
4
+ @table = ::Autoperf::Display::Console.new(results, report).table
5
+ end
6
+
7
+ def to_s
8
+ @table.to_csv
9
+ end
10
+
11
+ def to_csv
12
+ to_s
13
+ end
14
+
15
+ def print
16
+ puts to_s
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,25 @@
1
+ class Autoperf::Display
2
+ class JSON
3
+ def initialize(results, fields=nil)
4
+ @results = []
5
+ fields ||= ::Autoperf::Display::DEFAULT_FIELDS
6
+ results.each do |rate, result|
7
+ result.keep_if { |k,v| fields.include?(k) }
8
+ result.merge!(:rate => rate) if fields.include?(:rate)
9
+ @results.push(result)
10
+ end
11
+ end
12
+
13
+ def to_s
14
+ to_json
15
+ end
16
+
17
+ def to_json
18
+ @results.to_json
19
+ end
20
+
21
+ def print
22
+ puts ::JSON.pretty_generate(@results)
23
+ end
24
+ end
25
+ end
@@ -1,3 +1,3 @@
1
1
  class Autoperf
2
- VERSION = "1.0.4"
2
+ VERSION = "1.1.0beta1"
3
3
  end
metadata CHANGED
@@ -1,8 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: autoperf
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.4
5
- prerelease:
4
+ version: 1.1.0beta1
5
+ prerelease: 5
6
6
  platform: ruby
7
7
  authors:
8
8
  - Joshua Mervine
@@ -10,30 +10,46 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2013-04-15 00:00:00.000000000 Z
13
+ date: 2013-04-25 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rake
17
17
  requirement: !ruby/object:Gem::Requirement
18
18
  none: false
19
19
  requirements:
20
- - - ! '>='
20
+ - - ~>
21
21
  - !ruby/object:Gem::Version
22
- version: '0'
22
+ version: 10.0.4
23
23
  type: :development
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
26
26
  none: false
27
27
  requirements:
28
- - - ! '>='
28
+ - - ~>
29
29
  - !ruby/object:Gem::Version
30
- version: '0'
30
+ version: 10.0.4
31
+ - !ruby/object:Gem::Dependency
32
+ name: minitest
33
+ requirement: !ruby/object:Gem::Requirement
34
+ none: false
35
+ requirements:
36
+ - - ~>
37
+ - !ruby/object:Gem::Version
38
+ version: 4.7.1
39
+ type: :development
40
+ prerelease: false
41
+ version_requirements: !ruby/object:Gem::Requirement
42
+ none: false
43
+ requirements:
44
+ - - ~>
45
+ - !ruby/object:Gem::Version
46
+ version: 4.7.1
31
47
  - !ruby/object:Gem::Dependency
32
48
  name: httperfrb
33
49
  requirement: !ruby/object:Gem::Requirement
34
50
  none: false
35
51
  requirements:
36
- - - ! '>='
52
+ - - ~>
37
53
  - !ruby/object:Gem::Version
38
54
  version: 0.3.11
39
55
  type: :runtime
@@ -41,7 +57,7 @@ dependencies:
41
57
  version_requirements: !ruby/object:Gem::Requirement
42
58
  none: false
43
59
  requirements:
44
- - - ! '>='
60
+ - - ~>
45
61
  - !ruby/object:Gem::Version
46
62
  version: 0.3.11
47
63
  - !ruby/object:Gem::Dependency
@@ -49,17 +65,17 @@ dependencies:
49
65
  requirement: !ruby/object:Gem::Requirement
50
66
  none: false
51
67
  requirements:
52
- - - ! '>='
68
+ - - ~>
53
69
  - !ruby/object:Gem::Version
54
- version: '0'
70
+ version: 1.6.3
55
71
  type: :runtime
56
72
  prerelease: false
57
73
  version_requirements: !ruby/object:Gem::Requirement
58
74
  none: false
59
75
  requirements:
60
- - - ! '>='
76
+ - - ~>
61
77
  - !ruby/object:Gem::Version
62
- version: '0'
78
+ version: 1.6.3
63
79
  description: Autoperf is a ruby driver for httperf, designed to help you automate
64
80
  load and performance testing of any web application - for a single end point, or
65
81
  through log replay.
@@ -73,6 +89,9 @@ extensions: []
73
89
  extra_rdoc_files: []
74
90
  files:
75
91
  - lib/autoperf/display.rb
92
+ - lib/autoperf/display/csv.rb
93
+ - lib/autoperf/display/json.rb
94
+ - lib/autoperf/display/console.rb
76
95
  - lib/autoperf/version.rb
77
96
  - lib/replay_log.rb
78
97
  - lib/autoperf.rb
@@ -95,9 +114,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
95
114
  required_rubygems_version: !ruby/object:Gem::Requirement
96
115
  none: false
97
116
  requirements:
98
- - - ! '>='
117
+ - - ! '>'
99
118
  - !ruby/object:Gem::Version
100
- version: '0'
119
+ version: 1.3.1
101
120
  requirements: []
102
121
  rubyforge_project:
103
122
  rubygems_version: 1.8.24