hansel 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/VERSION +1 -1
- data/hansel.gemspec +2 -2
- data/lib/arg_parser.rb +5 -0
- data/lib/hansel.rb +24 -15
- data/lib/octave_formatter.rb +4 -2
- metadata +2 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.2
|
data/hansel.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{hansel}
|
8
|
-
s.version = "0.0.
|
8
|
+
s.version = "0.0.2"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Paul Mylchreest"]
|
12
|
-
s.date = %q{2010-
|
12
|
+
s.date = %q{2010-02-27}
|
13
13
|
s.default_executable = %q{hansel}
|
14
14
|
s.description = %q{Ruby driver for httperf - automated load and performance testing}
|
15
15
|
s.email = %q{paul.mylchreest@mac.com}
|
data/lib/arg_parser.rb
CHANGED
@@ -17,6 +17,7 @@ class ArgParser
|
|
17
17
|
options.rate_step = 1
|
18
18
|
options.output_format = :yaml
|
19
19
|
options.output = nil
|
20
|
+
options.output_dir = File.join ENV['HOME'], 'hansel_output'
|
20
21
|
|
21
22
|
opts = OptionParser.new do |opts|
|
22
23
|
opts.banner = "Usage: hansel [options]"
|
@@ -72,6 +73,10 @@ class ArgParser
|
|
72
73
|
options.output = opt
|
73
74
|
end
|
74
75
|
|
76
|
+
opts.on("-d", "--output_dir=PATH", "Specify an output directory.") do |opt|
|
77
|
+
options.output_dir = opt
|
78
|
+
end
|
79
|
+
|
75
80
|
opts.separator ""
|
76
81
|
opts.separator "Common options:"
|
77
82
|
|
data/lib/hansel.rb
CHANGED
@@ -1,23 +1,29 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
|
1
3
|
class Hansel
|
2
4
|
def initialize(options = {})
|
3
5
|
@options = options
|
4
6
|
@results = {}
|
5
7
|
end
|
6
8
|
|
9
|
+
def options
|
10
|
+
@options
|
11
|
+
end
|
12
|
+
|
7
13
|
def verbose?
|
8
|
-
|
14
|
+
options.verbose
|
9
15
|
end
|
10
16
|
|
11
17
|
def benchmark(rate)
|
12
18
|
result = {:output => ""}
|
13
19
|
httperf_cmd = [
|
14
20
|
"httperf --hog",
|
15
|
-
"--server=#{
|
16
|
-
"--port=#{
|
17
|
-
"--uri=#{
|
18
|
-
"--num-conns=#{
|
21
|
+
"--server=#{options.server}",
|
22
|
+
"--port=#{options.port}",
|
23
|
+
"--uri=#{options.uri}",
|
24
|
+
"--num-conns=#{options.num_conns}",
|
19
25
|
"--rate=#{rate}",
|
20
|
-
|
26
|
+
options.cookie && "--add-header='Cookie: #{options.cookie}\\n'"
|
21
27
|
].compact.join ' '
|
22
28
|
|
23
29
|
IO.popen("#{httperf_cmd} 2>&1") do |pipe|
|
@@ -43,9 +49,12 @@ class Hansel
|
|
43
49
|
end
|
44
50
|
|
45
51
|
def output
|
46
|
-
if
|
47
|
-
|
48
|
-
|
52
|
+
if options.output
|
53
|
+
FileUtils.mkdir_p options.output_dir
|
54
|
+
output_file = File.join options.output_dir, [options.server, options.num_conns.to_s].join('.')
|
55
|
+
type = { :yaml => 'yml', :csv => 'csv', :octave => 'm' }[options.output_format]
|
56
|
+
File.open([output_file, type].join('.'), "w+") do |f|
|
57
|
+
formatter = case options.output_format
|
49
58
|
when :yaml
|
50
59
|
load File.here '/../lib/yaml_formatter.rb'
|
51
60
|
YamlFormatter.new(@results)
|
@@ -54,7 +63,7 @@ class Hansel
|
|
54
63
|
CsvFormatter.new(@results)
|
55
64
|
when :octave
|
56
65
|
load File.here '/../lib/octave_formatter.rb'
|
57
|
-
OctaveFormatter.new(@results)
|
66
|
+
OctaveFormatter.new(@results, {:output_file => output_file})
|
58
67
|
end
|
59
68
|
f.puts formatter.format
|
60
69
|
end
|
@@ -63,12 +72,12 @@ class Hansel
|
|
63
72
|
|
64
73
|
def run
|
65
74
|
puts "starting run..." if verbose?
|
66
|
-
(
|
75
|
+
(options.low_rate..options.high_rate).step(options.rate_step) do |rate|
|
67
76
|
puts "benchmarking at rate: #{rate}" if verbose?
|
68
|
-
@results[:server] =
|
69
|
-
@results[:port] =
|
70
|
-
@results[:uri] =
|
71
|
-
@results[:num_conns] =
|
77
|
+
@results[:server] = options.server
|
78
|
+
@results[:port] = options.port
|
79
|
+
@results[:uri] = options.uri
|
80
|
+
@results[:num_conns] = options.num_conns
|
72
81
|
@results[rate] = benchmark(rate)
|
73
82
|
end
|
74
83
|
puts "ending run..." if verbose?
|
data/lib/octave_formatter.rb
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
class OctaveFormatter
|
2
|
-
def initialize(data)
|
2
|
+
def initialize(data, options = {})
|
3
3
|
@data = data
|
4
|
+
@options = options
|
5
|
+
@png_output = [(options[:output_file] || 'stats'), 'png'].join('.')
|
4
6
|
end
|
5
7
|
|
6
8
|
def format
|
@@ -39,7 +41,7 @@ class OctaveFormatter
|
|
39
41
|
title('Hansel report for #{@data[:server]}:#{@data[:port]}#{@data[:uri]} (#{@data[:num_conns]} connections per run)')
|
40
42
|
xlabel('Demanded Request Rate');
|
41
43
|
legend('Request Rate', 'Connection Rate', 'Avg. reply rate', 'Max. reply rate', 'Reply rate StdDev', 'Errors');
|
42
|
-
print('
|
44
|
+
print('#{@png_output}', '-dpng')
|
43
45
|
EOS
|
44
46
|
result = result.gsub ' ', ''
|
45
47
|
result
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hansel
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Paul Mylchreest
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2010-
|
12
|
+
date: 2010-02-27 00:00:00 -05:00
|
13
13
|
default_executable: hansel
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|