rack-perftools_profiler 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +26 -12
- data/VERSION +1 -1
- data/lib/rack/perftools_profiler.rb +2 -0
- data/lib/rack/perftools_profiler/profile_once.rb +9 -1
- data/lib/rack/perftools_profiler/profiler.rb +42 -6
- data/lib/rack/perftools_profiler/return_data.rb +1 -1
- data/lib/rack/perftools_profiler/start_profiling.rb +14 -1
- data/lib/rack/perftools_profiler/utils.rb +11 -0
- data/rack-perftools_profiler.gemspec +81 -0
- data/test/multiple_request_profiling_test.rb +352 -0
- data/test/rack-perftools-profiler_test.rb +14 -369
- data/test/single_request_profiling_test.rb +278 -0
- data/test/test_helper.rb +64 -0
- metadata +29 -7
- data/.gitignore +0 -6
data/test/test_helper.rb
CHANGED
@@ -8,4 +8,68 @@ $LOAD_PATH.unshift(File.dirname(__FILE__))
|
|
8
8
|
require 'rack/perftools_profiler'
|
9
9
|
|
10
10
|
class Test::Unit::TestCase
|
11
|
+
|
12
|
+
end
|
13
|
+
|
14
|
+
ITERATIONS = case RUBY_VERSION
|
15
|
+
# Ruby 1.9.x is so fast that we need to add extra iterations
|
16
|
+
# to get profiling data
|
17
|
+
when /1\.9\../
|
18
|
+
350_000
|
19
|
+
else
|
20
|
+
35_000
|
21
|
+
end
|
22
|
+
|
23
|
+
# From the Rack spec (http://rack.rubyforge.org/doc/files/SPEC.html) :
|
24
|
+
# The Body must respond to each and must only yield String values. The Body should not be an instance of String.
|
25
|
+
# ... The Body commonly is an Array of Strings, the application instance itself, or a File-like object.
|
26
|
+
|
27
|
+
class RackResponseBody
|
28
|
+
include Test::Unit::Assertions
|
29
|
+
|
30
|
+
def initialize(body)
|
31
|
+
assert !body.instance_of?(String)
|
32
|
+
@body = body
|
33
|
+
end
|
34
|
+
|
35
|
+
def to_s
|
36
|
+
str = ""
|
37
|
+
@body.each do |part|
|
38
|
+
str << part
|
39
|
+
end
|
40
|
+
str
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
|
45
|
+
class TestApp
|
46
|
+
|
47
|
+
def call(env)
|
48
|
+
case env['PATH_INFO']
|
49
|
+
when /method1/
|
50
|
+
ITERATIONS.times do
|
51
|
+
self.class.new.method1
|
52
|
+
end
|
53
|
+
GC.start
|
54
|
+
when /method2/
|
55
|
+
ITERATIONS.times do
|
56
|
+
self.class.new.method2
|
57
|
+
end
|
58
|
+
GC.start
|
59
|
+
end
|
60
|
+
[200, {}, ['Done']]
|
61
|
+
end
|
62
|
+
|
63
|
+
def method1
|
64
|
+
100.times do
|
65
|
+
1+2+3+4+5
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
def method2
|
70
|
+
100.times do
|
71
|
+
1+2+3+4+5
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
11
75
|
end
|
metadata
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rack-perftools_profiler
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
+
hash: 15
|
4
5
|
prerelease: false
|
5
6
|
segments:
|
6
7
|
- 0
|
7
|
-
-
|
8
|
+
- 4
|
8
9
|
- 0
|
9
|
-
version: 0.
|
10
|
+
version: 0.4.0
|
10
11
|
platform: ruby
|
11
12
|
authors:
|
12
13
|
- Ben Brinckerhoff
|
@@ -14,16 +15,18 @@ autorequire:
|
|
14
15
|
bindir: bin
|
15
16
|
cert_chain: []
|
16
17
|
|
17
|
-
date:
|
18
|
+
date: 2011-01-16 00:00:00 -07:00
|
18
19
|
default_executable:
|
19
20
|
dependencies:
|
20
21
|
- !ruby/object:Gem::Dependency
|
21
22
|
name: perftools.rb
|
22
23
|
prerelease: false
|
23
24
|
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
24
26
|
requirements:
|
25
27
|
- - ~>
|
26
28
|
- !ruby/object:Gem::Version
|
29
|
+
hash: 1
|
27
30
|
segments:
|
28
31
|
- 0
|
29
32
|
- 5
|
@@ -34,9 +37,11 @@ dependencies:
|
|
34
37
|
name: rack
|
35
38
|
prerelease: false
|
36
39
|
requirement: &id002 !ruby/object:Gem::Requirement
|
40
|
+
none: false
|
37
41
|
requirements:
|
38
42
|
- - ~>
|
39
43
|
- !ruby/object:Gem::Version
|
44
|
+
hash: 15
|
40
45
|
segments:
|
41
46
|
- 1
|
42
47
|
- 0
|
@@ -47,9 +52,11 @@ dependencies:
|
|
47
52
|
name: open4
|
48
53
|
prerelease: false
|
49
54
|
requirement: &id003 !ruby/object:Gem::Requirement
|
55
|
+
none: false
|
50
56
|
requirements:
|
51
57
|
- - ~>
|
52
58
|
- !ruby/object:Gem::Version
|
59
|
+
hash: 15
|
53
60
|
segments:
|
54
61
|
- 1
|
55
62
|
- 0
|
@@ -60,9 +67,11 @@ dependencies:
|
|
60
67
|
name: rack
|
61
68
|
prerelease: false
|
62
69
|
requirement: &id004 !ruby/object:Gem::Requirement
|
70
|
+
none: false
|
63
71
|
requirements:
|
64
72
|
- - ~>
|
65
73
|
- !ruby/object:Gem::Version
|
74
|
+
hash: 13
|
66
75
|
segments:
|
67
76
|
- 1
|
68
77
|
- 1
|
@@ -73,9 +82,11 @@ dependencies:
|
|
73
82
|
name: shoulda
|
74
83
|
prerelease: false
|
75
84
|
requirement: &id005 !ruby/object:Gem::Requirement
|
85
|
+
none: false
|
76
86
|
requirements:
|
77
87
|
- - ~>
|
78
88
|
- !ruby/object:Gem::Version
|
89
|
+
hash: 23
|
79
90
|
segments:
|
80
91
|
- 2
|
81
92
|
- 10
|
@@ -86,9 +97,11 @@ dependencies:
|
|
86
97
|
name: mocha
|
87
98
|
prerelease: false
|
88
99
|
requirement: &id006 !ruby/object:Gem::Requirement
|
100
|
+
none: false
|
89
101
|
requirements:
|
90
102
|
- - ~>
|
91
103
|
- !ruby/object:Gem::Version
|
104
|
+
hash: 25
|
92
105
|
segments:
|
93
106
|
- 0
|
94
107
|
- 9
|
@@ -106,7 +119,6 @@ extra_rdoc_files:
|
|
106
119
|
- README.rdoc
|
107
120
|
files:
|
108
121
|
- .document
|
109
|
-
- .gitignore
|
110
122
|
- LICENSE
|
111
123
|
- README.rdoc
|
112
124
|
- Rakefile
|
@@ -121,38 +133,48 @@ files:
|
|
121
133
|
- lib/rack/perftools_profiler/return_data.rb
|
122
134
|
- lib/rack/perftools_profiler/start_profiling.rb
|
123
135
|
- lib/rack/perftools_profiler/stop_profiling.rb
|
136
|
+
- lib/rack/perftools_profiler/utils.rb
|
137
|
+
- rack-perftools_profiler.gemspec
|
138
|
+
- test/multiple_request_profiling_test.rb
|
124
139
|
- test/rack-perftools-profiler_test.rb
|
140
|
+
- test/single_request_profiling_test.rb
|
125
141
|
- test/test_helper.rb
|
126
142
|
has_rdoc: true
|
127
143
|
homepage: http://github.com/bhb/rack-perftools_profiler
|
128
144
|
licenses: []
|
129
145
|
|
130
146
|
post_install_message:
|
131
|
-
rdoc_options:
|
132
|
-
|
147
|
+
rdoc_options: []
|
148
|
+
|
133
149
|
require_paths:
|
134
150
|
- lib
|
135
151
|
required_ruby_version: !ruby/object:Gem::Requirement
|
152
|
+
none: false
|
136
153
|
requirements:
|
137
154
|
- - ">="
|
138
155
|
- !ruby/object:Gem::Version
|
156
|
+
hash: 3
|
139
157
|
segments:
|
140
158
|
- 0
|
141
159
|
version: "0"
|
142
160
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
161
|
+
none: false
|
143
162
|
requirements:
|
144
163
|
- - ">="
|
145
164
|
- !ruby/object:Gem::Version
|
165
|
+
hash: 3
|
146
166
|
segments:
|
147
167
|
- 0
|
148
168
|
version: "0"
|
149
169
|
requirements: []
|
150
170
|
|
151
171
|
rubyforge_project:
|
152
|
-
rubygems_version: 1.3.
|
172
|
+
rubygems_version: 1.3.7
|
153
173
|
signing_key:
|
154
174
|
specification_version: 3
|
155
175
|
summary: Middleware for profiling Rack-compatible apps using perftools.rb
|
156
176
|
test_files:
|
177
|
+
- test/multiple_request_profiling_test.rb
|
157
178
|
- test/rack-perftools-profiler_test.rb
|
179
|
+
- test/single_request_profiling_test.rb
|
158
180
|
- test/test_helper.rb
|