brontes3d-production_log_analyzer 2009022403
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/History.txt +34 -0
- data/LICENSE.txt +27 -0
- data/Manifest.txt +18 -0
- data/README.txt +147 -0
- data/Rakefile +17 -0
- data/bin/action_errors +46 -0
- data/bin/action_grep +19 -0
- data/bin/pl_analyze +36 -0
- data/lib/passenger_log_per_proc.rb +55 -0
- data/lib/production_log/action_grep.rb +41 -0
- data/lib/production_log/analyzer.rb +416 -0
- data/lib/production_log/parser.rb +228 -0
- data/test/test_action_grep.rb +72 -0
- data/test/test_analyzer.rb +425 -0
- data/test/test_helper.rb +68 -0
- data/test/test_parser.rb +420 -0
- data/test/test_passenger_log_per_proc.rb +88 -0
- data/test/test_syslogs/test.syslog.0.14.x.log +4 -0
- data/test/test_syslogs/test.syslog.1.2.shortname.log +4 -0
- data/test/test_syslogs/test.syslog.empty.log +0 -0
- data/test/test_syslogs/test.syslog.log +256 -0
- data/test/test_vanilla/test.0.14.x.log +4 -0
- data/test/test_vanilla/test.1.2.shortname.log +4 -0
- data/test/test_vanilla/test.empty.log +0 -0
- data/test/test_vanilla/test.log +255 -0
- data/test/test_vanilla/test_log_parts/1_online1-rails-59600.log +7 -0
- data/test/test_vanilla/test_log_parts/2_online2-rails-59628.log +11 -0
- data/test/test_vanilla/test_log_parts/3_online1-rails-59628.log +9 -0
- data/test/test_vanilla/test_log_parts/4_online1-rails-59645.log +30 -0
- data/test/test_vanilla/test_log_parts/5_online1-rails-59629.log +38 -0
- data/test/test_vanilla/test_log_parts/6_online1-rails-60654.log +32 -0
- data/test/test_vanilla/test_log_parts/7_online1-rails-59627.log +70 -0
- data/test/test_vanilla/test_log_parts/8_online1-rails-59635.log +58 -0
- metadata +113 -0
@@ -0,0 +1,72 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/test_helper'
|
2
|
+
|
3
|
+
class TestActionGrep < TestTwice
|
4
|
+
|
5
|
+
twice_test :test_module_grep do
|
6
|
+
begin
|
7
|
+
old_stdout = $stdout.dup
|
8
|
+
stdout = StringIO.new
|
9
|
+
$stdout = stdout
|
10
|
+
|
11
|
+
if test_sys_log_style?
|
12
|
+
@syslog_file_name = File.expand_path(File.join(File.dirname(__FILE__), 'test_syslogs',
|
13
|
+
'test.syslog.log'))
|
14
|
+
ActionGrep.grep 'RssController', @syslog_file_name
|
15
|
+
else
|
16
|
+
logs_dir = File.expand_path(File.join(File.dirname(__FILE__), 'test_vanilla','test_log_parts'))
|
17
|
+
Dir.new(logs_dir).each do |file|
|
18
|
+
unless file.to_s[0,1] == "."
|
19
|
+
ActionGrep.grep 'RssController', File.join(logs_dir, file)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
stdout.rewind
|
25
|
+
|
26
|
+
lines = stdout.readlines
|
27
|
+
|
28
|
+
assert_equal 19, lines.length
|
29
|
+
|
30
|
+
ensure
|
31
|
+
$stdout = old_stdout
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
twice_test :test_module_grep_arguments do
|
36
|
+
begin
|
37
|
+
file = Tempfile.new File.basename(__FILE__)
|
38
|
+
|
39
|
+
assert_raises ArgumentError do
|
40
|
+
ActionGrep.grep 'Foo_Controller', '/tmp/no_such_file/no_really/'
|
41
|
+
end
|
42
|
+
|
43
|
+
assert_raises ArgumentError do
|
44
|
+
ActionGrep.grep 'FooController#5', '/tmp/no_such_file/no_really/'
|
45
|
+
end
|
46
|
+
|
47
|
+
assert_raises ArgumentError do
|
48
|
+
ActionGrep.grep '5', '/tmp/no_such_file/no_really/'
|
49
|
+
end
|
50
|
+
|
51
|
+
assert_raises ArgumentError do
|
52
|
+
ActionGrep.grep 'FooController', '/tmp/no_such_file/no_really'
|
53
|
+
end
|
54
|
+
|
55
|
+
assert_nothing_raised do
|
56
|
+
ActionGrep.grep 'FooController', file.path
|
57
|
+
ActionGrep.grep 'FooController5', file.path
|
58
|
+
ActionGrep.grep 'FooController#action', file.path
|
59
|
+
ActionGrep.grep 'FooController#action_thingy', file.path
|
60
|
+
ActionGrep.grep 'FooController#action_thingy5', file.path
|
61
|
+
ActionGrep.grep 'FooController5#action', file.path
|
62
|
+
ActionGrep.grep 'FooController5#action_thingy', file.path
|
63
|
+
ActionGrep.grep 'FooController5#action_thingy5', file.path
|
64
|
+
end
|
65
|
+
|
66
|
+
ensure
|
67
|
+
file.close
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
end
|
72
|
+
|
@@ -0,0 +1,425 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/test_helper'
|
2
|
+
|
3
|
+
class TestEnumerable < TestTwice
|
4
|
+
|
5
|
+
twice_test :test_sum do
|
6
|
+
assert_equal 45, (1..9).to_a.sum
|
7
|
+
end
|
8
|
+
|
9
|
+
twice_test :test_average do
|
10
|
+
# Ranges don't have a length
|
11
|
+
assert_in_delta 5.0, (1..9).to_a.average, 0.01
|
12
|
+
end
|
13
|
+
|
14
|
+
twice_test :test_sample_variance do
|
15
|
+
assert_in_delta 6.6666, (1..9).to_a.sample_variance, 0.0001
|
16
|
+
end
|
17
|
+
|
18
|
+
twice_test :test_standard_deviation do
|
19
|
+
assert_in_delta 2.5819, (1..9).to_a.standard_deviation, 0.0001
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
|
24
|
+
class TestSizedList < TestTwice
|
25
|
+
|
26
|
+
setup do
|
27
|
+
@list = SizedList.new 10 do |arr,|
|
28
|
+
arr.delete_at 0
|
29
|
+
true
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
twice_test :test_append do
|
34
|
+
assert_equal [], @list.entries
|
35
|
+
|
36
|
+
(1..10).each { |i| @list << i }
|
37
|
+
assert_equal 10, @list.length
|
38
|
+
assert_equal((1..10).to_a, @list.entries)
|
39
|
+
|
40
|
+
@list << 11
|
41
|
+
assert_equal 10, @list.length
|
42
|
+
assert_equal((2..11).to_a, @list.entries)
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
46
|
+
|
47
|
+
class TestSlowestTimes < TestTwice
|
48
|
+
|
49
|
+
setup do
|
50
|
+
@list = SlowestTimes.new 10
|
51
|
+
end
|
52
|
+
|
53
|
+
twice_test :test_that_it_works do
|
54
|
+
expected = []
|
55
|
+
|
56
|
+
10.downto(1) do |i|
|
57
|
+
@list << [i, nil]
|
58
|
+
expected << [i, nil]
|
59
|
+
end
|
60
|
+
|
61
|
+
assert_equal expected, @list.entries
|
62
|
+
|
63
|
+
@list << [11, nil]
|
64
|
+
expected.pop
|
65
|
+
expected.push [11, nil]
|
66
|
+
|
67
|
+
assert_equal 10, @list.length
|
68
|
+
assert_equal expected, @list.entries
|
69
|
+
|
70
|
+
@list << [0, nil]
|
71
|
+
|
72
|
+
assert_equal expected, @list.entries
|
73
|
+
end
|
74
|
+
|
75
|
+
end
|
76
|
+
|
77
|
+
class TestAnalyzer < TestTwice
|
78
|
+
|
79
|
+
setup do
|
80
|
+
if test_sys_log_style?
|
81
|
+
@analyzer = Analyzer.new "#{File.dirname(__FILE__)}/test_syslogs/test.syslog.log"
|
82
|
+
else
|
83
|
+
@analyzer = Analyzer.new "#{File.dirname(__FILE__)}/test_vanilla/test_log_parts"
|
84
|
+
end
|
85
|
+
@analyzer.process
|
86
|
+
end
|
87
|
+
|
88
|
+
twice_test :test_self_email do
|
89
|
+
if test_sys_log_style?
|
90
|
+
email = Analyzer.email("#{File.dirname(__FILE__)}/test_syslogs/test.syslog.log", 'devnull@robotcoop.com',
|
91
|
+
nil, 1)
|
92
|
+
else
|
93
|
+
email = Analyzer.email("#{File.dirname(__FILE__)}/test_vanilla/test_log_parts", 'devnull@robotcoop.com',
|
94
|
+
nil, 1)
|
95
|
+
end
|
96
|
+
expected = <<-EOF
|
97
|
+
Subject: pl_analyze
|
98
|
+
To: devnull@robotcoop.com
|
99
|
+
Content-Type: text/html
|
100
|
+
|
101
|
+
<pre>Request Times Summary: Count Avg Std Dev Min Max
|
102
|
+
ALL REQUESTS: 11 0.576 0.508 0.000 1.470
|
103
|
+
|
104
|
+
ThingsController#view: 3 0.716 0.387 0.396 1.260
|
105
|
+
TeamsController#progress: 2 0.841 0.629 0.212 1.470
|
106
|
+
RssController#uber: 2 0.035 0.000 0.035 0.035
|
107
|
+
PeopleController#progress: 2 0.489 0.489 0.000 0.977
|
108
|
+
PeopleController#view: 2 0.731 0.371 0.360 1.102
|
109
|
+
|
110
|
+
Slowest Request Times:
|
111
|
+
\tTeamsController#progress took 1.470s
|
112
|
+
|
113
|
+
------------------------------------------------------------------------
|
114
|
+
|
115
|
+
DB Times Summary: Count Avg Std Dev Min Max
|
116
|
+
ALL REQUESTS: 11 0.366 0.393 0.000 1.144
|
117
|
+
|
118
|
+
ThingsController#view: 3 0.403 0.362 0.122 0.914
|
119
|
+
TeamsController#progress: 2 0.646 0.497 0.149 1.144
|
120
|
+
RssController#uber: 2 0.008 0.000 0.008 0.008
|
121
|
+
PeopleController#progress: 2 0.415 0.415 0.000 0.830
|
122
|
+
PeopleController#view: 2 0.338 0.149 0.189 0.486
|
123
|
+
|
124
|
+
Slowest Total DB Times:
|
125
|
+
\tTeamsController#progress took 1.144s
|
126
|
+
|
127
|
+
------------------------------------------------------------------------
|
128
|
+
|
129
|
+
Render Times Summary: Count Avg Std Dev Min Max
|
130
|
+
ALL REQUESTS: 11 0.219 0.253 0.000 0.695
|
131
|
+
|
132
|
+
ThingsController#view: 3 0.270 0.171 0.108 0.506
|
133
|
+
TeamsController#progress: 2 0.000 0.000 0.000 0.000
|
134
|
+
RssController#uber: 2 0.012 0.000 0.012 0.012
|
135
|
+
PeopleController#progress: 2 0.302 0.302 0.000 0.604
|
136
|
+
PeopleController#view: 2 0.487 0.209 0.278 0.695
|
137
|
+
|
138
|
+
Slowest Total Render Times:
|
139
|
+
\tPeopleController#view took 0.695s
|
140
|
+
</pre>
|
141
|
+
EOF
|
142
|
+
|
143
|
+
assert_mostly_equal expected, email
|
144
|
+
end
|
145
|
+
|
146
|
+
twice_test :test_self_envelope do
|
147
|
+
expected = [
|
148
|
+
"Subject: pl_analyze",
|
149
|
+
"To: devnull@example.com",
|
150
|
+
"Content-Type: text/html"
|
151
|
+
]
|
152
|
+
|
153
|
+
assert_equal expected.sort, Analyzer.envelope('devnull@example.com').sort
|
154
|
+
end
|
155
|
+
|
156
|
+
twice_test :test_self_envelope_subject do
|
157
|
+
expected = [
|
158
|
+
"Subject: happy fancy boom",
|
159
|
+
"To: devnull@example.com",
|
160
|
+
"Content-Type: text/html"
|
161
|
+
]
|
162
|
+
|
163
|
+
assert_equal(expected.sort,
|
164
|
+
Analyzer.envelope('devnull@example.com', 'happy fancy boom').sort)
|
165
|
+
end
|
166
|
+
|
167
|
+
twice_test :test_average_db_time do
|
168
|
+
assert_in_delta 0.4023761, @analyzer.average_db_time, 0.0000001
|
169
|
+
end
|
170
|
+
|
171
|
+
twice_test :test_average_render_time do
|
172
|
+
assert_in_delta 0.3015584, @analyzer.average_render_time, 0.0000001
|
173
|
+
end
|
174
|
+
|
175
|
+
twice_test :test_average_request_time do
|
176
|
+
assert_in_delta 0.6338176, @analyzer.average_request_time, 0.0000001
|
177
|
+
end
|
178
|
+
|
179
|
+
twice_test :test_db_time_std_dev do
|
180
|
+
assert_in_delta 0.3941380, @analyzer.db_time_std_dev, 0.0000001
|
181
|
+
end
|
182
|
+
|
183
|
+
twice_test :test_db_times_summary do
|
184
|
+
expected = <<EOF.strip
|
185
|
+
DB Times Summary: Count Avg Std Dev Min Max
|
186
|
+
ALL REQUESTS: 11 0.366 0.393 0.000 1.144
|
187
|
+
|
188
|
+
ThingsController#view: 3 0.403 0.362 0.122 0.914
|
189
|
+
TeamsController#progress: 2 0.646 0.497 0.149 1.144
|
190
|
+
RssController#uber: 2 0.008 0.000 0.008 0.008
|
191
|
+
PeopleController#progress: 2 0.415 0.415 0.000 0.830
|
192
|
+
PeopleController#view: 2 0.338 0.149 0.189 0.486
|
193
|
+
EOF
|
194
|
+
|
195
|
+
assert_mostly_equal expected, @analyzer.db_times_summary
|
196
|
+
end
|
197
|
+
|
198
|
+
twice_test :test_empty_syslog do
|
199
|
+
analyzer = Analyzer.new "#{File.dirname(__FILE__)}/test_syslogs/test.syslog.empty.log"
|
200
|
+
assert_nothing_raised do
|
201
|
+
analyzer.process
|
202
|
+
analyzer.report(1)
|
203
|
+
end
|
204
|
+
assert_equal "No requests to analyze", analyzer.report(1)
|
205
|
+
end
|
206
|
+
|
207
|
+
twice_test :test_logfile_name do
|
208
|
+
if test_sys_log_style?
|
209
|
+
assert_equal "#{File.dirname(__FILE__)}/test_syslogs/test.syslog.log", @analyzer.logfile_name
|
210
|
+
else
|
211
|
+
assert_equal "#{File.dirname(__FILE__)}/test_vanilla/test_log_parts", @analyzer.logfile_name
|
212
|
+
end
|
213
|
+
end
|
214
|
+
|
215
|
+
twice_test :test_longest_request_name do
|
216
|
+
assert_equal false, @analyzer.instance_variables.include?('@longest_req')
|
217
|
+
|
218
|
+
request_times = {
|
219
|
+
"ThingsController#view" => [0],
|
220
|
+
"TeamsController#progress" => [1],
|
221
|
+
"RssController#uber" => [0],
|
222
|
+
"PeopleController#progress" => [0],
|
223
|
+
nil => [0],
|
224
|
+
}
|
225
|
+
|
226
|
+
@analyzer.instance_variable_set('@request_times', request_times)
|
227
|
+
|
228
|
+
assert_equal 26, @analyzer.longest_request_name
|
229
|
+
end
|
230
|
+
|
231
|
+
twice_test :test_pad_request_name do
|
232
|
+
assert_equal 26, @analyzer.longest_request_name
|
233
|
+
assert_equal("PeopleController#view: ",
|
234
|
+
@analyzer.pad_request_name("PeopleController#view"))
|
235
|
+
end
|
236
|
+
|
237
|
+
twice_test :test_pad_request_name_nil do
|
238
|
+
assert_equal 26, @analyzer.longest_request_name
|
239
|
+
assert_equal("Unknown: ",
|
240
|
+
@analyzer.pad_request_name(nil))
|
241
|
+
end
|
242
|
+
|
243
|
+
twice_test :test_pad_request_name_short do
|
244
|
+
analyzer = Analyzer.new "#{File.dirname(__FILE__)}/test_syslogs/test.syslog.1.2.shortname.log"
|
245
|
+
analyzer.process
|
246
|
+
longer_request_name_value = " " * (analyzer.longest_request_name + 1)
|
247
|
+
assert_nothing_raised do
|
248
|
+
analyzer.pad_request_name(longer_request_name_value)
|
249
|
+
end
|
250
|
+
assert_equal longer_request_name_value + ":", analyzer.pad_request_name(longer_request_name_value)
|
251
|
+
end
|
252
|
+
|
253
|
+
twice_test :test_process do
|
254
|
+
expected_request_times = {
|
255
|
+
"PeopleController#view" => [1.102098, 0.36021],
|
256
|
+
"ThingsController#view" => [0.396183, 0.49176, 1.259728],
|
257
|
+
"TeamsController#progress" => [1.469788, 0.211973],
|
258
|
+
"RssController#uber" => [0.034519, 0.034519],
|
259
|
+
"PeopleController#progress" => [0.977398, 0]
|
260
|
+
}
|
261
|
+
assert_equal expected_request_times, @analyzer.request_times
|
262
|
+
|
263
|
+
expected_db_times = {
|
264
|
+
"PeopleController#view" => [0.486258, 0.189119],
|
265
|
+
"ThingsController#view" => [0.122158, 0.172767, 0.914192],
|
266
|
+
"TeamsController#progress" => [1.143577, 0.149357],
|
267
|
+
"RssController#uber" => [0.007962, 0.007962],
|
268
|
+
"PeopleController#progress" => [0.830409, 0]
|
269
|
+
}
|
270
|
+
assert_equal expected_db_times, @analyzer.db_times
|
271
|
+
|
272
|
+
expected_render_times = {
|
273
|
+
"PeopleController#view" => [0.695476, 0.277921],
|
274
|
+
"ThingsController#view" => [0.107987, 0.197126, 0.505973],
|
275
|
+
"TeamsController#progress" => [0, 0],
|
276
|
+
"RssController#uber" => [0.01177, 0.01177],
|
277
|
+
"PeopleController#progress" => [0.604444, 0]
|
278
|
+
}
|
279
|
+
assert_equal expected_render_times, @analyzer.render_times
|
280
|
+
end
|
281
|
+
|
282
|
+
twice_test :test_render_time_std_dev do
|
283
|
+
assert_in_delta 0.2513925, @analyzer.render_time_std_dev, 0.0000001
|
284
|
+
end
|
285
|
+
|
286
|
+
twice_test :test_render_times_summary do
|
287
|
+
expected = <<EOF.strip
|
288
|
+
Render Times Summary: Count Avg Std Dev Min Max
|
289
|
+
ALL REQUESTS: 11 0.219 0.253 0.000 0.695
|
290
|
+
|
291
|
+
ThingsController#view: 3 0.270 0.171 0.108 0.506
|
292
|
+
TeamsController#progress: 2 0.000 0.000 0.000 0.000
|
293
|
+
RssController#uber: 2 0.012 0.000 0.012 0.012
|
294
|
+
PeopleController#progress: 2 0.302 0.302 0.000 0.604
|
295
|
+
PeopleController#view: 2 0.487 0.209 0.278 0.695
|
296
|
+
EOF
|
297
|
+
|
298
|
+
assert_mostly_equal expected, @analyzer.render_times_summary
|
299
|
+
end
|
300
|
+
|
301
|
+
twice_test :test_report do
|
302
|
+
expected = <<-EOF
|
303
|
+
Request Times Summary: Count Avg Std Dev Min Max
|
304
|
+
ALL REQUESTS: 11 0.576 0.508 0.000 1.470
|
305
|
+
|
306
|
+
ThingsController#view: 3 0.716 0.387 0.396 1.260
|
307
|
+
TeamsController#progress: 2 0.841 0.629 0.212 1.470
|
308
|
+
RssController#uber: 2 0.035 0.000 0.035 0.035
|
309
|
+
PeopleController#progress: 2 0.489 0.489 0.000 0.977
|
310
|
+
PeopleController#view: 2 0.731 0.371 0.360 1.102
|
311
|
+
|
312
|
+
Slowest Request Times:
|
313
|
+
\tTeamsController#progress took 1.470s
|
314
|
+
\tThingsController#view took 1.260s
|
315
|
+
\tPeopleController#view took 1.102s
|
316
|
+
\tPeopleController#progress took 0.977s
|
317
|
+
\tThingsController#view took 0.492s
|
318
|
+
\tThingsController#view took 0.396s
|
319
|
+
\tPeopleController#view took 0.360s
|
320
|
+
\tTeamsController#progress took 0.212s
|
321
|
+
\tRssController#uber took 0.035s
|
322
|
+
\tRssController#uber took 0.035s
|
323
|
+
|
324
|
+
------------------------------------------------------------------------
|
325
|
+
|
326
|
+
DB Times Summary: Count Avg Std Dev Min Max
|
327
|
+
ALL REQUESTS: 11 0.366 0.393 0.000 1.144
|
328
|
+
|
329
|
+
ThingsController#view: 3 0.403 0.362 0.122 0.914
|
330
|
+
TeamsController#progress: 2 0.646 0.497 0.149 1.144
|
331
|
+
RssController#uber: 2 0.008 0.000 0.008 0.008
|
332
|
+
PeopleController#progress: 2 0.415 0.415 0.000 0.830
|
333
|
+
PeopleController#view: 2 0.338 0.149 0.189 0.486
|
334
|
+
|
335
|
+
Slowest Total DB Times:
|
336
|
+
\tTeamsController#progress took 1.144s
|
337
|
+
\tThingsController#view took 0.914s
|
338
|
+
\tPeopleController#progress took 0.830s
|
339
|
+
\tPeopleController#view took 0.486s
|
340
|
+
\tPeopleController#view took 0.189s
|
341
|
+
\tThingsController#view took 0.173s
|
342
|
+
\tTeamsController#progress took 0.149s
|
343
|
+
\tThingsController#view took 0.122s
|
344
|
+
\tRssController#uber took 0.008s
|
345
|
+
\tRssController#uber took 0.008s
|
346
|
+
|
347
|
+
------------------------------------------------------------------------
|
348
|
+
|
349
|
+
Render Times Summary: Count Avg Std Dev Min Max
|
350
|
+
ALL REQUESTS: 11 0.219 0.253 0.000 0.695
|
351
|
+
|
352
|
+
ThingsController#view: 3 0.270 0.171 0.108 0.506
|
353
|
+
TeamsController#progress: 2 0.000 0.000 0.000 0.000
|
354
|
+
RssController#uber: 2 0.012 0.000 0.012 0.012
|
355
|
+
PeopleController#progress: 2 0.302 0.302 0.000 0.604
|
356
|
+
PeopleController#view: 2 0.487 0.209 0.278 0.695
|
357
|
+
|
358
|
+
Slowest Total Render Times:
|
359
|
+
\tPeopleController#view took 0.695s
|
360
|
+
\tPeopleController#progress took 0.604s
|
361
|
+
\tThingsController#view took 0.506s
|
362
|
+
\tPeopleController#view took 0.278s
|
363
|
+
\tThingsController#view took 0.197s
|
364
|
+
\tThingsController#view took 0.108s
|
365
|
+
\tRssController#uber took 0.012s
|
366
|
+
\tRssController#uber took 0.012s
|
367
|
+
EOF
|
368
|
+
|
369
|
+
assert_mostly_equal expected, @analyzer.report(10)
|
370
|
+
end
|
371
|
+
|
372
|
+
twice_test :test_request_time_std_dev do
|
373
|
+
assert_in_delta 0.4975667, @analyzer.request_time_std_dev, 0.0000001
|
374
|
+
end
|
375
|
+
|
376
|
+
twice_test :test_request_times_summary do
|
377
|
+
expected = <<EOF.strip
|
378
|
+
Request Times Summary: Count Avg Std Dev Min Max
|
379
|
+
ALL REQUESTS: 11 0.576 0.508 0.000 1.470
|
380
|
+
|
381
|
+
ThingsController#view: 3 0.716 0.387 0.396 1.260
|
382
|
+
TeamsController#progress: 2 0.841 0.629 0.212 1.470
|
383
|
+
RssController#uber: 2 0.035 0.000 0.035 0.035
|
384
|
+
PeopleController#progress: 2 0.489 0.489 0.000 0.977
|
385
|
+
PeopleController#view: 2 0.731 0.371 0.360 1.102
|
386
|
+
EOF
|
387
|
+
|
388
|
+
assert_mostly_equal expected, @analyzer.request_times_summary
|
389
|
+
end
|
390
|
+
|
391
|
+
twice_test :test_slowest_db_times do
|
392
|
+
times = @analyzer.slowest_db_times 3
|
393
|
+
assert_equal 3, times.length
|
394
|
+
expected = [
|
395
|
+
[1.143577, "TeamsController#progress"],
|
396
|
+
[0.914192, "ThingsController#view"],
|
397
|
+
[0.830409, "PeopleController#progress"]
|
398
|
+
]
|
399
|
+
assert_equal expected, times
|
400
|
+
end
|
401
|
+
|
402
|
+
twice_test :test_slowest_request_times do
|
403
|
+
times = @analyzer.slowest_request_times 3
|
404
|
+
assert_equal 3, times.length
|
405
|
+
expected = [
|
406
|
+
[1.469788, "TeamsController#progress"],
|
407
|
+
[1.259728, "ThingsController#view"],
|
408
|
+
[1.102098, "PeopleController#view"]
|
409
|
+
]
|
410
|
+
assert_equal expected, times
|
411
|
+
end
|
412
|
+
|
413
|
+
twice_test :test_slowest_render_times do
|
414
|
+
times = @analyzer.slowest_render_times 3
|
415
|
+
assert_equal 3, times.length
|
416
|
+
expected = [
|
417
|
+
[0.695476, "PeopleController#view"],
|
418
|
+
[0.604444, "PeopleController#progress"],
|
419
|
+
[0.505973, "ThingsController#view"]
|
420
|
+
]
|
421
|
+
assert_equal expected, times
|
422
|
+
end
|
423
|
+
|
424
|
+
end
|
425
|
+
|