httperfrb 0.0.2 → 0.1.0
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/Gemfile +1 -0
- data/HISTORY.md +10 -0
- data/README.md +14 -6
- data/lib/httperf.rb +40 -7
- metadata +9 -9
data/Gemfile
CHANGED
data/HISTORY.md
CHANGED
@@ -1,10 +1,20 @@
|
|
1
1
|
HTTPerf.rb
|
2
2
|
==========
|
3
3
|
|
4
|
+
### 0.1.0
|
5
|
+
|
6
|
+
* refactored #run to run system commands in a cleaner fashion
|
7
|
+
* added #fork to run in a thread
|
8
|
+
* added #fork_out to return the output from the last #fork
|
9
|
+
* added #fork_err to return the error from the last #fork
|
10
|
+
|
11
|
+
|
4
12
|
### 0.0.2
|
5
13
|
|
6
14
|
* fix a few critical bugs with params - 0.0.1 is bad
|
7
15
|
|
16
|
+
|
8
17
|
### 0.0.1
|
9
18
|
|
10
19
|
* Initial release.
|
20
|
+
|
data/README.md
CHANGED
@@ -1,29 +1,37 @@
|
|
1
1
|
HTTPERF.rb
|
2
2
|
==========
|
3
3
|
|
4
|
+
### [Documentation](http://rubyops.github.com/httperfrb/doc/) | [Coverage](http://rubyops.github.com/httperfrb/coverage/)
|
5
|
+
|
4
6
|
Simple Ruby interface for httperf.
|
5
7
|
|
6
|
-
|
8
|
+
#### Note
|
9
|
+
|
10
|
+
This currently needs a lot of work to be production ready. It's done more in a scripting style then a true solid application style.
|
11
|
+
|
12
|
+
|
7
13
|
|
8
14
|
### Installing 'httperf'
|
9
15
|
|
10
|
-
|
16
|
+
Requires httperf, of course...
|
17
|
+
|
18
|
+
##### Mac
|
11
19
|
|
12
20
|
sudo port install httperf
|
13
21
|
|
14
|
-
|
22
|
+
##### Debian / Ubuntu
|
15
23
|
|
16
24
|
sudo apt-get install httperf
|
17
25
|
|
18
|
-
|
26
|
+
##### Redhat / CentOS
|
19
27
|
|
20
28
|
sudo yum install httperf
|
21
29
|
|
22
|
-
|
30
|
+
#### Install
|
23
31
|
|
24
32
|
gem install httperfrb
|
25
33
|
|
26
|
-
|
34
|
+
#### Usage
|
27
35
|
|
28
36
|
require 'httperf'
|
29
37
|
perf = HTTPerf.new( "server" => "host", "port" => 8080, "uri" => "/foo" )
|
data/lib/httperf.rb
CHANGED
@@ -1,10 +1,12 @@
|
|
1
1
|
# @author Joshua Mervine <joshua@mervine.net>
|
2
|
+
require 'open4'
|
2
3
|
class HTTPerf
|
3
4
|
# gem version
|
4
|
-
VERSION = "0.0
|
5
|
+
VERSION = "0.1.0"
|
5
6
|
|
6
7
|
# availbe instance methods
|
7
|
-
@
|
8
|
+
@fork_out, @fork_err = ''
|
9
|
+
@fork_thr, @options, @command = nil
|
8
10
|
|
9
11
|
# initialize with (optional):
|
10
12
|
# - options: see below for options
|
@@ -52,7 +54,7 @@ class HTTPerf
|
|
52
54
|
# - wset
|
53
55
|
def initialize options={}, path=nil
|
54
56
|
options.each_key do |k|
|
55
|
-
raise "#{k} is an invalid httperf param" unless params.keys.include?(k)
|
57
|
+
raise "'#{k}' is an invalid httperf param" unless params.keys.include?(k)
|
56
58
|
end
|
57
59
|
@options = params.merge(options)
|
58
60
|
if path.nil?
|
@@ -70,15 +72,46 @@ class HTTPerf
|
|
70
72
|
@options[opt] = val
|
71
73
|
end
|
72
74
|
|
73
|
-
# run httperf
|
75
|
+
# run httperf and wait for it to finish
|
76
|
+
# return errors if any, otherwise return
|
77
|
+
# results
|
74
78
|
def run
|
75
|
-
|
79
|
+
status, out, err = nil
|
80
|
+
Open3.popen3(command) do |stdin, stdout, stderr, wait_thr|
|
81
|
+
pid = wait_thr.pid
|
82
|
+
out = stdout.readlines
|
83
|
+
err = stderr.readlines
|
84
|
+
status = wait_thr.value
|
85
|
+
end
|
86
|
+
if status == 0
|
87
|
+
return out.join("\n")
|
88
|
+
else
|
89
|
+
return err.join("\n")
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
# run httperf, fork and return thread
|
94
|
+
def fork
|
95
|
+
raise "httperf fork currently running" if @fork_thr && @fork_thr.alive?
|
96
|
+
@fork_out, @fork_err = ''
|
97
|
+
@fork_thr = Open4::bg command, :stdin => nil, :stdout => @fork_out, :stderr => @fork_err
|
98
|
+
@fork_thr
|
99
|
+
end
|
100
|
+
|
101
|
+
# return results of last fork
|
102
|
+
def fork_out
|
103
|
+
@fork_out
|
104
|
+
end
|
105
|
+
|
106
|
+
# return errors from last fork
|
107
|
+
def fork_err
|
108
|
+
@fork_err
|
76
109
|
end
|
77
110
|
|
78
111
|
# print httperf command to be run
|
79
112
|
# - for debugging and testing
|
80
|
-
def
|
81
|
-
return
|
113
|
+
def command
|
114
|
+
return "#{@command} #{options}"
|
82
115
|
end
|
83
116
|
|
84
117
|
private
|
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.0
|
4
|
+
version: 0.1.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-07-
|
12
|
+
date: 2012-07-27 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
16
|
-
requirement: &
|
16
|
+
requirement: &23863840 !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: *
|
24
|
+
version_requirements: *23863840
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: simplecov
|
27
|
-
requirement: &
|
27
|
+
requirement: &23863300 !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: *
|
35
|
+
version_requirements: *23863300
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: yard
|
38
|
-
requirement: &
|
38
|
+
requirement: &23862580 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,7 +43,7 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *23862580
|
47
47
|
description: Simple interface for calling httperf via ruby.
|
48
48
|
email:
|
49
49
|
- joshua@mervine.net
|
@@ -69,7 +69,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
69
69
|
version: '0'
|
70
70
|
segments:
|
71
71
|
- 0
|
72
|
-
hash: -
|
72
|
+
hash: -2900852867171754939
|
73
73
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
74
74
|
none: false
|
75
75
|
requirements:
|