httperf-output-parser 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in httperf-output-parser.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Will Jessop
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,106 @@
1
+ # HttperfOutputParser
2
+
3
+ > [Httperf](http://code.google.com/p/httperf/) is a tool for measuring web server performance. It provides a flexible facility for generating various HTTP workloads and for measuring server performance.
4
+
5
+ httperf is run from the command line outputs information like this:
6
+
7
+ # httperf --client=0/1 --server=10.10.0.201 --port=889 --uri=/hello.txt --send-buffer=4096 --recv-buffer=16384 --ssl --num-conns=20000 --hog --ssl-no-reuse
8
+ Maximum connect burst length: 1
9
+
10
+ Total: connections 20000 requests 20000 replies 20000 test-duration 350.422 s
11
+
12
+ Connection rate: 57.1 conn/s (17.5 ms/conn, <=1 concurrent connections)
13
+ Connection time [ms]: min 10.9 avg 17.5 max 3027.5 median 11.5 stddev 105.9
14
+ Connection time [ms]: connect 16.3
15
+ Connection length [replies/conn]: 1.000
16
+
17
+ Request rate: 57.1 req/s (17.5 ms/req)
18
+ Request size [B]: 73.0
19
+
20
+ Reply rate [replies/s]: min 6.4 avg 57.0 max 80.6 stddev 19.9 (70 samples)
21
+ Reply time [ms]: response 1.2 transfer 0.0
22
+ Reply size [B]: header 215.0 content 6.0 footer 0.0 (total 221.0)
23
+ Reply status: 1xx=0 2xx=20000 3xx=0 4xx=0 5xx=0
24
+
25
+ CPU time [s]: user 141.21 system 208.21 (user 40.3% system 59.4% total 99.7%)
26
+ Net I/O: 16.4 KB/s (0.1*10^6 bps)
27
+
28
+ Errors: total 0 client-timo 0 socket-timo 0 connrefused 0 connreset 0
29
+ Errors: fd-unavail 0 addrunavail 0 ftab-full 0 other 0
30
+
31
+ httperf is great, but if you're running more than a few tests and need to log the output (in a database or spreadsheet etc.) then copy/pasting the values from this output becomes tedious. I wrote HttperfOutputParser to make it easier to get these values in machine readable/processable form.
32
+
33
+ Currently I'm parsing out these values because those are what I need:
34
+
35
+ Total connections
36
+ Total time (s)
37
+ conn/s
38
+ ms/conn
39
+ min
40
+ avg
41
+ max
42
+ median
43
+ stddev
44
+ Request rate (req/s)
45
+ ms per request
46
+ min
47
+ avg
48
+ max
49
+ stddev
50
+ Reply time (ms)
51
+
52
+ If you need more then feel free to send a pull request.
53
+
54
+ ## Installation
55
+
56
+ Add this line to your application's Gemfile:
57
+
58
+ gem 'httperf-output-parser'
59
+
60
+ And then execute:
61
+
62
+ $ bundle
63
+
64
+ Or install it yourself as:
65
+
66
+ $ gem install httperf-output-parser
67
+
68
+ ## Usage
69
+
70
+ ``` ruby
71
+ require 'httperf-output-parser'
72
+ parser = HttperfOutputParser.new
73
+
74
+ # Pass the parser a string
75
+ results = parser.parse(STDIN.read)
76
+
77
+ # Result will just be a hash
78
+ puts results.inspect
79
+
80
+ # with the hash we can do something with the data, like create a CSV:
81
+ puts %w{
82
+ total_connections
83
+ test_duration
84
+ connections_per_sec
85
+ min_ms_per_connection
86
+ avg_ms_per_connection
87
+ max_ms_per_connection
88
+ median_ms_per_connection
89
+ stddev_ms_per_connection
90
+ request_rate_per_sec
91
+ ms_per_request
92
+ min_ms_per_request
93
+ avg_ms_per_request
94
+ max_ms_per_request
95
+ stddev_ms_per_request
96
+ reply_time_response
97
+ }.map {|dt| results[dt.to_sym]}.join "\t"
98
+ ```
99
+
100
+ ## Contributing
101
+
102
+ 1. Fork it
103
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
104
+ 3. Commit your changes (`git commit -am 'Added some feature'`)
105
+ 4. Push to the branch (`git push origin my-new-feature`)
106
+ 5. Create new Pull Request
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
3
+ require 'rake/testtask'
4
+
5
+ Rake::TestTask.new do |t|
6
+ t.libs << 'test'
7
+ end
8
+
9
+ desc "Run tests"
10
+ task :default => :test
@@ -0,0 +1,19 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/httperf-output-parser/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ["Will Jessop"]
6
+ gem.email = ["will@willj.net"]
7
+ gem.description = %q{httperf output parser}
8
+ gem.summary = %q{httperf output parser}
9
+ gem.homepage = "https://github.com/wjessop/httperf-output-parser"
10
+
11
+ gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
12
+ gem.files = `git ls-files`.split("\n")
13
+ gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
14
+ gem.name = "httperf-output-parser"
15
+ gem.require_paths = ["lib"]
16
+ gem.version = HttperfOutputParser::VERSION
17
+
18
+ gem.add_development_dependency 'simplecov'
19
+ end
@@ -0,0 +1,35 @@
1
+ require "httperf-output-parser/version"
2
+
3
+ class HttperfOutputParser
4
+ def parse(raw_httperf_output)
5
+ # http://rubular.com/r/EZ4xSydMlk
6
+ matches = raw_httperf_output.match(/connections (\d+).+duration ([\d.]+).+Connection rate: ([\d.]+).+Connection time \[ms\]: min ([\d.]+) avg ([\d.]+) max ([\d.]+) median ([\d.]+) stddev ([\d.]+).+Request rate: ([\d.]+) req\/s \(([\d.]+).+Reply rate.+min ([\d.]+) avg ([\d.]+) max ([\d.]+) stddev ([\d.]+).+Reply time.+response ([\d.]+)/m)
7
+ parsed_values = {}
8
+ 15.times do |i|
9
+ parsed_values[data_types[i].to_sym] = matches[i+1].to_f
10
+ end
11
+ return parsed_values
12
+ end
13
+
14
+ private
15
+
16
+ def data_types
17
+ %w{
18
+ total_connections
19
+ test_duration
20
+ connections_per_sec
21
+ min_ms_per_connection
22
+ avg_ms_per_connection
23
+ max_ms_per_connection
24
+ median_ms_per_connection
25
+ stddev_ms_per_connection
26
+ request_rate_per_sec
27
+ ms_per_request
28
+ min_ms_per_request
29
+ avg_ms_per_request
30
+ max_ms_per_request
31
+ stddev_ms_per_request
32
+ reply_time_response
33
+ }
34
+ end
35
+ end
@@ -0,0 +1,3 @@
1
+ class HttperfOutputParser
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,75 @@
1
+ ---
2
+ - total_connections: 20000
3
+ test_duration: 592.676
4
+ connections_per_sec: 33.7
5
+ min_ms_per_connection: 10.8
6
+ avg_ms_per_connection: 29.6
7
+ max_ms_per_connection: 11652.5
8
+ median_ms_per_connection: 11.5
9
+ stddev_ms_per_connection: 217.1
10
+ request_rate_per_sec: 33.7
11
+ ms_per_request: 29.6
12
+ min_ms_per_request: 0.0
13
+ avg_ms_per_request: 33.7
14
+ max_ms_per_request: 76.2
15
+ stddev_ms_per_request: 19.3
16
+ reply_time_response: 2.1
17
+ raw_output: ! 'Maximum connect burst length: 1
18
+
19
+ Total: connections 20000 requests 20000 replies 20000 test-duration 592.676 s
20
+
21
+ Connection rate: 33.7 conn/s (29.6 ms/conn, <=1 concurrent connections)
22
+ Connection time [ms]: min 10.8 avg 29.6 max 11652.5 median 11.5 stddev 217.1
23
+ Connection time [ms]: connect 27.6
24
+ Connection length [replies/conn]: 1.000
25
+
26
+ Request rate: 33.7 req/s (29.6 ms/req)
27
+ Request size [B]: 73.0
28
+
29
+ Reply rate [replies/s]: min 0.0 avg 33.7 max 76.2 stddev 19.3 (118 samples)
30
+ Reply time [ms]: response 2.1 transfer 0.0
31
+ Reply size [B]: header 215.0 content 6.0 footer 0.0 (total 221.0)
32
+ Reply status: 1xx=0 2xx=20000 3xx=0 4xx=0 5xx=0
33
+
34
+ CPU time [s]: user 197.28 system 394.31 (user 33.3% system 66.5% total 99.8%)
35
+ Net I/O: 9.7 KB/s (0.1*10^6 bps)
36
+
37
+ Errors: total 0 client-timo 0 socket-timo 0 connrefused 0 connreset 0
38
+ Errors: fd-unavail 0 addrunavail 0 ftab-full 0 other 0'
39
+ - total_connections: 20000
40
+ test_duration: 350.422
41
+ connections_per_sec: 57.1
42
+ min_ms_per_connection: 10.9
43
+ avg_ms_per_connection: 17.5
44
+ max_ms_per_connection: 3027.5
45
+ median_ms_per_connection: 11.5
46
+ stddev_ms_per_connection: 105.9
47
+ request_rate_per_sec: 57.1
48
+ ms_per_request: 17.5
49
+ min_ms_per_request: 6.4
50
+ avg_ms_per_request: 57.0
51
+ max_ms_per_request: 80.6
52
+ stddev_ms_per_request: 19.9
53
+ reply_time_response: 1.2
54
+ raw_output: ! 'Maximum connect burst length: 1
55
+
56
+ Total: connections 20000 requests 20000 replies 20000 test-duration 350.422 s
57
+
58
+ Connection rate: 57.1 conn/s (17.5 ms/conn, <=1 concurrent connections)
59
+ Connection time [ms]: min 10.9 avg 17.5 max 3027.5 median 11.5 stddev 105.9
60
+ Connection time [ms]: connect 16.3
61
+ Connection length [replies/conn]: 1.000
62
+
63
+ Request rate: 57.1 req/s (17.5 ms/req)
64
+ Request size [B]: 73.0
65
+
66
+ Reply rate [replies/s]: min 6.4 avg 57.0 max 80.6 stddev 19.9 (70 samples)
67
+ Reply time [ms]: response 1.2 transfer 0.0
68
+ Reply size [B]: header 215.0 content 6.0 footer 0.0 (total 221.0)
69
+ Reply status: 1xx=0 2xx=20000 3xx=0 4xx=0 5xx=0
70
+
71
+ CPU time [s]: user 141.21 system 208.21 (user 40.3% system 59.4% total 99.7%)
72
+ Net I/O: 16.4 KB/s (0.1*10^6 bps)
73
+
74
+ Errors: total 0 client-timo 0 socket-timo 0 connrefused 0 connreset 0
75
+ Errors: fd-unavail 0 addrunavail 0 ftab-full 0 other 0'
@@ -0,0 +1,7 @@
1
+ # encoding: utf-8
2
+
3
+ require 'simplecov'
4
+ SimpleCov.start do
5
+ add_filter "/test/"
6
+ add_filter "lib/httperf-output-parser/version.rb"
7
+ end
@@ -0,0 +1,38 @@
1
+ require 'test/unit'
2
+ require 'test_helper'
3
+ require 'httperf-output-parser'
4
+ require 'yaml'
5
+
6
+ class HttperfOutputParserTest < Test::Unit::TestCase
7
+ def test_initialize_with_invalid_params
8
+ assert_raise(ArgumentError) { HttperfOutputParser.new("Not expecting this!") }
9
+ end
10
+
11
+ def test_initialize
12
+ parser = HttperfOutputParser.new
13
+ assert_equal parser.class, HttperfOutputParser
14
+ end
15
+
16
+ def test_httperf_output_parsing
17
+ YAML.load_file('test/httperf_sample_output.yml').each do |result|
18
+ parser = HttperfOutputParser.new
19
+ parsed_values = parser.parse(result["raw_output"])
20
+
21
+ assert_equal result["total_connections"], parsed_values[:total_connections]
22
+ assert_equal result["test_duration"], parsed_values[:test_duration]
23
+ assert_equal result["connections_per_sec"], parsed_values[:connections_per_sec]
24
+ assert_equal result["min_ms_per_connection"], parsed_values[:min_ms_per_connection]
25
+ assert_equal result["avg_ms_per_connection"], parsed_values[:avg_ms_per_connection]
26
+ assert_equal result["max_ms_per_connection"], parsed_values[:max_ms_per_connection]
27
+ assert_equal result["median_ms_per_connection"], parsed_values[:median_ms_per_connection]
28
+ assert_equal result["stddev_ms_per_connection"], parsed_values[:stddev_ms_per_connection]
29
+ assert_equal result["request_rate_per_sec"], parsed_values[:request_rate_per_sec]
30
+ assert_equal result["ms_per_request"], parsed_values[:ms_per_request]
31
+ assert_equal result["min_ms_per_request"], parsed_values[:min_ms_per_request]
32
+ assert_equal result["avg_ms_per_request"], parsed_values[:avg_ms_per_request]
33
+ assert_equal result["max_ms_per_request"], parsed_values[:max_ms_per_request]
34
+ assert_equal result["stddev_ms_per_request"], parsed_values[:stddev_ms_per_request]
35
+ assert_equal result["response_reply_time"], parsed_values[:response_reply_time]
36
+ end
37
+ end
38
+ end
metadata ADDED
@@ -0,0 +1,70 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: httperf-output-parser
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Will Jessop
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-03-31 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: simplecov
16
+ requirement: &70175232674760 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: *70175232674760
25
+ description: httperf output parser
26
+ email:
27
+ - will@willj.net
28
+ executables: []
29
+ extensions: []
30
+ extra_rdoc_files: []
31
+ files:
32
+ - .gitignore
33
+ - Gemfile
34
+ - LICENSE
35
+ - README.md
36
+ - Rakefile
37
+ - httperf-output-parser.gemspec
38
+ - lib/httperf-output-parser.rb
39
+ - lib/httperf-output-parser/version.rb
40
+ - test/httperf_sample_output.yml
41
+ - test/test_helper.rb
42
+ - test/test_httperf_output_parser.rb
43
+ homepage: https://github.com/wjessop/httperf-output-parser
44
+ licenses: []
45
+ post_install_message:
46
+ rdoc_options: []
47
+ require_paths:
48
+ - lib
49
+ required_ruby_version: !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ required_rubygems_version: !ruby/object:Gem::Requirement
56
+ none: false
57
+ requirements:
58
+ - - ! '>='
59
+ - !ruby/object:Gem::Version
60
+ version: '0'
61
+ requirements: []
62
+ rubyforge_project:
63
+ rubygems_version: 1.8.10
64
+ signing_key:
65
+ specification_version: 3
66
+ summary: httperf output parser
67
+ test_files:
68
+ - test/httperf_sample_output.yml
69
+ - test/test_helper.rb
70
+ - test/test_httperf_output_parser.rb