httperfrb 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +11 -0
- data/HISTORY.md +6 -0
- data/README.md +34 -0
- data/lib/httperf.rb +93 -0
- metadata +86 -0
data/Gemfile
ADDED
data/HISTORY.md
ADDED
data/README.md
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
HTTPERF.rb
|
2
|
+
==========
|
3
|
+
|
4
|
+
Simple Ruby interface for httperf.
|
5
|
+
|
6
|
+
Requires httperf, of course...
|
7
|
+
|
8
|
+
### Installing 'httperf'
|
9
|
+
|
10
|
+
#### Mac
|
11
|
+
|
12
|
+
sudo port install httperf
|
13
|
+
|
14
|
+
#### Debian / Ubuntu
|
15
|
+
|
16
|
+
sudo apt-get install httperf
|
17
|
+
|
18
|
+
#### Redhat / CentOS
|
19
|
+
|
20
|
+
sudo yum install httperf
|
21
|
+
|
22
|
+
### Install
|
23
|
+
|
24
|
+
gem install httperfrb
|
25
|
+
|
26
|
+
### Usage
|
27
|
+
|
28
|
+
require 'httperf'
|
29
|
+
perf = HTTPerf.new( "server" => "host", "port" => 8080, "uri" => "/foo" )
|
30
|
+
perf.run
|
31
|
+
|
32
|
+
perf.update_option("uri", "/foo/bar")
|
33
|
+
perf.run
|
34
|
+
|
data/lib/httperf.rb
ADDED
@@ -0,0 +1,93 @@
|
|
1
|
+
class HTTPerf
|
2
|
+
VERSION = "0.0.1"
|
3
|
+
|
4
|
+
@options, @command = nil
|
5
|
+
|
6
|
+
# initialize with (optional):
|
7
|
+
# - options: see 'man httperf'
|
8
|
+
# - path: path to httperf
|
9
|
+
# - e.g. /usr/bin/httperf
|
10
|
+
def initialize options={}, path=nil
|
11
|
+
options.each_key do |k|
|
12
|
+
raise "#{k} is an invalid httperf param" unless params.keys.include?(k)
|
13
|
+
end
|
14
|
+
@options = params.merge(options)
|
15
|
+
if path.nil?
|
16
|
+
@command = %x{ which httperf }.chomp
|
17
|
+
raise "httperf not found" unless @command =~ /httperf/
|
18
|
+
else
|
19
|
+
path = path.chomp
|
20
|
+
@command = (path =~ /httperf$/ ? path : File.join(path, "httperf"))
|
21
|
+
raise "#{@command} not found" unless %x{ test -x "#{@command}" && echo "true" }.chomp == "true"
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
# update a given option
|
26
|
+
def update_option(opt, val)
|
27
|
+
@options[opt] = val
|
28
|
+
end
|
29
|
+
|
30
|
+
# run httperf
|
31
|
+
def run
|
32
|
+
return %x{ #{@command} #{options} }
|
33
|
+
end
|
34
|
+
|
35
|
+
# print httperf command to be run
|
36
|
+
# - for debugging and testing
|
37
|
+
def pretend
|
38
|
+
return %x{ echo "#{@command} #{options}" }
|
39
|
+
end
|
40
|
+
|
41
|
+
private
|
42
|
+
def options
|
43
|
+
opts = ""
|
44
|
+
@options.each do |key,val|
|
45
|
+
opts << "--#{key}=#{val} " unless val.nil?
|
46
|
+
end
|
47
|
+
opts
|
48
|
+
end
|
49
|
+
|
50
|
+
def params
|
51
|
+
{
|
52
|
+
"add-header" => nil,
|
53
|
+
"burst-length" => nil,
|
54
|
+
"client" => nil,
|
55
|
+
"close-with-reset" => nil,
|
56
|
+
"debug" => nil,
|
57
|
+
"failure-status" => nil,
|
58
|
+
"hog" => nil,
|
59
|
+
"http-version" => nil,
|
60
|
+
"max-connections" => nil,
|
61
|
+
"max-piped-calls" => nil,
|
62
|
+
"method" => nil,
|
63
|
+
"no-host-hdr" => nil,
|
64
|
+
"num-calls" => nil,
|
65
|
+
"num-conns" => nil,
|
66
|
+
"period [d|u|e" => nil,
|
67
|
+
"port" => nil,
|
68
|
+
"print-reply [header|body" => nil,
|
69
|
+
"print-request [header|body" => nil,
|
70
|
+
"rate" => nil,
|
71
|
+
"recv-buffer" => nil,
|
72
|
+
"retry-on-failure" => nil,
|
73
|
+
"send-buffer" => nil,
|
74
|
+
"server" => nil,
|
75
|
+
"server-name" => nil,
|
76
|
+
"session-cookies" => nil,
|
77
|
+
"ssl" => nil,
|
78
|
+
"ssl-ciphers" => nil,
|
79
|
+
"ssl-no-reuse" => nil,
|
80
|
+
"think-timeout" => nil,
|
81
|
+
"timeout" => nil,
|
82
|
+
"uri" => nil,
|
83
|
+
"verbose" => nil,
|
84
|
+
"version" => nil,
|
85
|
+
"wlog" => nil,
|
86
|
+
"wsess" => nil,
|
87
|
+
"wsesslog" => nil,
|
88
|
+
"wset" => nil
|
89
|
+
}
|
90
|
+
end
|
91
|
+
|
92
|
+
end
|
93
|
+
|
metadata
ADDED
@@ -0,0 +1,86 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: httperfrb
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Joshua Mervine
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-07-26 00:00:00.000000000Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rspec
|
16
|
+
requirement: &16582700 !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: *16582700
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: simplecov
|
27
|
+
requirement: &16581880 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
type: :development
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *16581880
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: yard
|
38
|
+
requirement: &16580940 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ! '>='
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '0'
|
44
|
+
type: :development
|
45
|
+
prerelease: false
|
46
|
+
version_requirements: *16580940
|
47
|
+
description: Simple interface for calling httperf via ruby.
|
48
|
+
email:
|
49
|
+
- joshua@mervine.net
|
50
|
+
executables: []
|
51
|
+
extensions: []
|
52
|
+
extra_rdoc_files: []
|
53
|
+
files:
|
54
|
+
- lib/httperf.rb
|
55
|
+
- README.md
|
56
|
+
- HISTORY.md
|
57
|
+
- Gemfile
|
58
|
+
homepage: http://github.com/rubyops/httperfrb
|
59
|
+
licenses: []
|
60
|
+
post_install_message:
|
61
|
+
rdoc_options: []
|
62
|
+
require_paths:
|
63
|
+
- lib
|
64
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
segments:
|
71
|
+
- 0
|
72
|
+
hash: -1274722979085222874
|
73
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
74
|
+
none: false
|
75
|
+
requirements:
|
76
|
+
- - ! '>='
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: 1.3.6
|
79
|
+
requirements: []
|
80
|
+
rubyforge_project:
|
81
|
+
rubygems_version: 1.7.2
|
82
|
+
signing_key:
|
83
|
+
specification_version: 3
|
84
|
+
summary: HTTPerf via Ruby
|
85
|
+
test_files: []
|
86
|
+
has_rdoc:
|