oink 0.1.2 → 0.9.1
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/README.rdoc +15 -29
- data/Rakefile +4 -6
- data/bin/oink +2 -2
- data/lib/oink.rb +1 -9
- data/lib/oink/cli.rb +71 -67
- data/lib/oink/instrumentation.rb +2 -0
- data/lib/oink/instrumentation/active_record.rb +63 -0
- data/lib/oink/instrumentation/memory_snapshot.rb +119 -0
- data/lib/oink/middleware.rb +48 -0
- data/lib/oink/rails/instance_type_counter.rb +8 -62
- data/lib/oink/rails/memory_usage_logger.rb +11 -33
- data/lib/oink/reports/active_record_instantiation_oinked_request.rb +13 -0
- data/lib/oink/reports/active_record_instantiation_report.rb +67 -0
- data/lib/oink/reports/base.rb +38 -0
- data/lib/oink/reports/memory_oinked_request.rb +13 -0
- data/lib/oink/reports/memory_usage_report.rb +71 -0
- data/lib/oink/reports/priority_queue.rb +41 -0
- data/lib/oink/reports/request.rb +20 -0
- data/lib/oink/utils/hash_utils.rb +9 -0
- data/spec/fakes/fake_application_controller.rb +30 -0
- data/spec/fakes/psuedo_output.rb +7 -0
- data/spec/helpers/database.rb +20 -0
- data/spec/{rails → oink/instrumentation}/instance_type_counter_spec.rb +11 -9
- data/spec/oink/instrumentation/memory_snapshot_spec.rb +84 -0
- data/spec/oink/middleware_spec.rb +73 -0
- data/spec/oink/rails/instance_type_counter_spec.rb +52 -0
- data/spec/oink/rails/memory_usage_logger_spec.rb +23 -0
- data/spec/oink/reports/active_record_instantiation_report_spec.rb +193 -0
- data/spec/oink/reports/memory_usage_report_spec.rb +267 -0
- data/spec/oink/reports/oinked_request_spec.rb +22 -0
- data/spec/oink/reports/priority_queue_spec.rb +74 -0
- data/spec/spec_helper.rb +10 -26
- metadata +158 -29
- data/lib/oink/active_record_instantiation_reporter.rb +0 -68
- data/lib/oink/base.rb +0 -40
- data/lib/oink/memory_usage_reporter.rb +0 -72
- data/lib/oink/oinked_request/oinked_ar_request.rb +0 -9
- data/lib/oink/oinked_request/oinked_memory_request.rb +0 -9
- data/lib/oink/oinked_request/oinked_request.rb +0 -16
- data/lib/oink/priority_queue.rb +0 -37
- data/spec/oink/active_record_instantiation_reporter_spec.rb +0 -191
- data/spec/oink/memory_usage_reporter_spec.rb +0 -265
- data/spec/oinked_request/oinked_request_spec.rb +0 -20
- data/spec/priority_queue/priority_queue_spec.rb +0 -75
- data/spec/rails/memory_usage_logger_spec.rb +0 -87
@@ -0,0 +1,267 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper")
|
2
|
+
|
3
|
+
module Oink::Reports
|
4
|
+
describe MemoryUsageReport do
|
5
|
+
|
6
|
+
TEN_MEGS = 10 * 1024
|
7
|
+
|
8
|
+
describe "short summary with frequent offenders" do
|
9
|
+
|
10
|
+
it "should report actions which exceed the threshold once" do
|
11
|
+
str = <<-STR
|
12
|
+
Feb 01 01:58:29 ey04-s00297 rails[4413]: Processing Users#show (for 92.84.151.171 at 2009-02-01 01:58:29) [GET]
|
13
|
+
Feb 01 01:58:30 ey04-s00297 rails[4413]: Memory usage: 0 | PID: 4413
|
14
|
+
Feb 01 01:58:30 ey04-s00297 rails[4413]: Completed in
|
15
|
+
Feb 01 01:58:29 ey04-s00297 rails[4413]: Processing MediaController#show (for 92.84.151.171 at 2009-02-01 01:58:29) [GET]
|
16
|
+
Feb 01 01:58:30 ey04-s00297 rails[4413]: Memory usage: #{TEN_MEGS + 1} | PID: 4413
|
17
|
+
Feb 01 01:58:30 ey04-s00297 rails[4413]: Completed in
|
18
|
+
STR
|
19
|
+
|
20
|
+
io = StringIO.new(str)
|
21
|
+
output = PsuedoOutput.new
|
22
|
+
MemoryUsageReport.new(io, TEN_MEGS).print(output)
|
23
|
+
output.should include("1, MediaController#show")
|
24
|
+
end
|
25
|
+
|
26
|
+
it "should not report actions which do not exceed the threshold" do
|
27
|
+
threshold = 10
|
28
|
+
|
29
|
+
str = <<-STR
|
30
|
+
Feb 01 01:58:29 ey04-s00297 rails[4413]: Processing Users#show (for 92.84.151.171 at 2009-02-01 01:58:29) [GET]
|
31
|
+
Feb 01 01:58:30 ey04-s00297 rails[4413]: Memory usage: 0 | PID: 4413
|
32
|
+
Feb 01 01:58:30 ey04-s00297 rails[4413]: Completed in
|
33
|
+
Feb 01 01:58:29 ey04-s00297 rails[4413]: Processing MediaController#show (for 92.84.151.171 at 2009-02-01 01:58:29) [GET]
|
34
|
+
Feb 01 01:58:30 ey04-s00297 rails[4413]: Memory usage: #{TEN_MEGS} | PID: 4413
|
35
|
+
Feb 01 01:58:30 ey04-s00297 rails[4413]: Completed in
|
36
|
+
STR
|
37
|
+
|
38
|
+
io = StringIO.new(str)
|
39
|
+
output = PsuedoOutput.new
|
40
|
+
MemoryUsageReport.new(io, TEN_MEGS).print(output)
|
41
|
+
output.should_not include("1, MediaController#show")
|
42
|
+
end
|
43
|
+
|
44
|
+
it "should report actions which exceed the threshold multiple times" do
|
45
|
+
str = <<-STR
|
46
|
+
Feb 01 01:58:29 ey04-s00297 rails[4413]: Processing Users#show (for 92.84.151.171 at 2009-02-01 01:58:29) [GET]
|
47
|
+
Feb 01 01:58:30 ey04-s00297 rails[4413]: Memory usage: 0 | PID: 4413
|
48
|
+
Feb 01 01:58:30 ey04-s00297 rails[4413]: Completed in
|
49
|
+
Feb 01 01:58:29 ey04-s00297 rails[4413]: Processing MediaController#show (for 92.84.151.171 at 2009-02-01 01:58:29) [GET]
|
50
|
+
Feb 01 01:58:30 ey04-s00297 rails[4413]: Memory usage: #{TEN_MEGS + 1} | PID: 4413
|
51
|
+
Feb 01 01:58:30 ey04-s00297 rails[4413]: Completed in
|
52
|
+
Feb 01 01:58:29 ey04-s00297 rails[4413]: Processing MediaController#show (for 92.84.151.171 at 2009-02-01 01:58:29) [GET]
|
53
|
+
Feb 01 01:58:30 ey04-s00297 rails[4413]: Memory usage: #{(TEN_MEGS * 2) + 2} | PID: 4413
|
54
|
+
Feb 01 01:58:30 ey04-s00297 rails[4413]: Completed in
|
55
|
+
STR
|
56
|
+
|
57
|
+
io = StringIO.new(str)
|
58
|
+
output = PsuedoOutput.new
|
59
|
+
MemoryUsageReport.new(io, TEN_MEGS).print(output)
|
60
|
+
output.should include("2, MediaController#show")
|
61
|
+
end
|
62
|
+
|
63
|
+
it "should order actions by most exceeded" do
|
64
|
+
str = <<-STR
|
65
|
+
Feb 01 01:58:29 ey04-s00297 rails[4413]: Processing Users#show (for 92.84.151.171 at 2009-02-01 01:58:29) [GET]
|
66
|
+
Feb 01 01:58:30 ey04-s00297 rails[4413]: Memory usage: 0 | PID: 4413
|
67
|
+
Feb 01 01:58:30 ey04-s00297 rails[4413]: Completed in
|
68
|
+
Feb 01 01:58:29 ey04-s00297 rails[4413]: Processing Users#show (for 92.84.151.171 at 2009-02-01 01:58:29) [GET]
|
69
|
+
Feb 01 01:58:30 ey04-s00297 rails[4413]: Memory usage: #{TEN_MEGS + 1} | PID: 4413
|
70
|
+
Feb 01 01:58:30 ey04-s00297 rails[4413]: Completed in
|
71
|
+
Feb 01 01:58:29 ey04-s00297 rails[4413]: Processing MediaController#show (for 92.84.151.171 at 2009-02-01 01:58:29) [GET]
|
72
|
+
Feb 01 01:58:30 ey04-s00297 rails[4413]: Memory usage: #{(TEN_MEGS * 2) + 2} | PID: 4413
|
73
|
+
Feb 01 01:58:30 ey04-s00297 rails[4413]: Completed in
|
74
|
+
Feb 01 01:58:29 ey04-s00297 rails[4413]: Processing MediaController#show (for 92.84.151.171 at 2009-02-01 01:58:29) [GET]
|
75
|
+
Feb 01 01:58:30 ey04-s00297 rails[4413]: Memory usage: #{(TEN_MEGS * 3) + 3} | PID: 4413
|
76
|
+
Feb 01 01:58:30 ey04-s00297 rails[4413]: Completed in
|
77
|
+
STR
|
78
|
+
|
79
|
+
io = StringIO.new(str)
|
80
|
+
output = PsuedoOutput.new
|
81
|
+
MemoryUsageReport.new(io, TEN_MEGS).print(output)
|
82
|
+
output[-2].should == "2, MediaController#show"
|
83
|
+
output[-1].should == "1, Users#show"
|
84
|
+
end
|
85
|
+
|
86
|
+
it "should not report actions which do not complete properly" do
|
87
|
+
threshold = 10
|
88
|
+
|
89
|
+
str = <<-STR
|
90
|
+
Feb 01 01:58:29 ey04-s00297 rails[4413]: Processing Users#show (for 92.84.151.171 at 2009-02-01 01:58:29) [GET]
|
91
|
+
Feb 01 01:58:30 ey04-s00297 rails[4413]: Memory usage: 0 | PID: 4413
|
92
|
+
Feb 01 01:58:29 ey04-s00297 rails[4413]: Processing MediaController#show (for 92.84.151.171 at 2009-02-01 01:58:29) [GET]
|
93
|
+
Feb 01 01:58:29 ey04-s00297 rails[4413]: Processing MediaController#show (for 92.84.151.171 at 2009-02-01 01:58:29) [GET]
|
94
|
+
Feb 01 01:58:30 ey04-s00297 rails[4413]: Memory usage: #{TEN_MEGS + 1} | PID: 4413
|
95
|
+
Feb 01 01:58:30 ey04-s00297 rails[4413]: Completed in
|
96
|
+
STR
|
97
|
+
|
98
|
+
io = StringIO.new(str)
|
99
|
+
output = PsuedoOutput.new
|
100
|
+
MemoryUsageReport.new(io, TEN_MEGS).print(output)
|
101
|
+
output.should_not include("1, MediaController#show")
|
102
|
+
end
|
103
|
+
|
104
|
+
it "should not report actions from different pids" do
|
105
|
+
str = <<-STR
|
106
|
+
Feb 01 01:58:29 ey04-s00297 rails[4413]: Processing Users#show (for 92.84.151.171 at 2009-02-01 01:58:29) [GET]
|
107
|
+
Feb 01 01:58:30 ey04-s00297 rails[4413]: Memory usage: 0 | PID: 4413
|
108
|
+
Feb 01 01:58:30 ey04-s00297 rails[4413]: Completed in
|
109
|
+
Feb 01 01:58:29 ey04-s00297 rails[5513]: Processing MediaController#show (for 92.84.151.171 at 2009-02-01 01:58:29) [GET]
|
110
|
+
Feb 01 01:58:30 ey04-s00297 rails[5513]: Memory usage: #{TEN_MEGS + 1} | PID: 4413
|
111
|
+
Feb 01 01:58:30 ey04-s00297 rails[5513]: Completed in
|
112
|
+
STR
|
113
|
+
|
114
|
+
io = StringIO.new(str)
|
115
|
+
output = PsuedoOutput.new
|
116
|
+
MemoryUsageReport.new(io, TEN_MEGS).print(output)
|
117
|
+
output.should_not include("1, MediaController#show")
|
118
|
+
end
|
119
|
+
|
120
|
+
describe "summary with top 10 offenses" do
|
121
|
+
|
122
|
+
it "should only report requests over threshold" do
|
123
|
+
str = <<-STR
|
124
|
+
Feb 01 01:58:29 ey04-s00297 rails[4413]: Processing Users#show (for 92.84.151.171 at 2009-02-01 01:58:29) [GET]
|
125
|
+
Feb 01 01:58:30 ey04-s00297 rails[4413]: Memory usage: 0 | PID: 4413
|
126
|
+
Feb 01 01:58:31 ey04-s00297 rails[4413]: Completed in
|
127
|
+
Feb 01 01:58:32 ey04-s00297 rails[4413]: Processing MediaController#show (for 92.84.151.171 at 2009-02-01 01:58:29) [GET]
|
128
|
+
Feb 01 01:58:33 ey04-s00297 rails[4413]: Memory usage: #{TEN_MEGS + 1} | PID: 4413
|
129
|
+
Feb 01 01:58:34 ey04-s00297 rails[4413]: Completed in
|
130
|
+
STR
|
131
|
+
|
132
|
+
io = StringIO.new(str)
|
133
|
+
output = PsuedoOutput.new
|
134
|
+
MemoryUsageReport.new(io, TEN_MEGS).print(output)
|
135
|
+
output.should include("1. Feb 01 01:58:34, #{TEN_MEGS + 1} KB, MediaController#show")
|
136
|
+
end
|
137
|
+
|
138
|
+
it "should not include requests which are not over the threshold" do
|
139
|
+
str = <<-STR
|
140
|
+
Feb 01 01:58:29 ey04-s00297 rails[4413]: Processing Users#show (for 92.84.151.171 at 2009-02-01 01:58:29) [GET]
|
141
|
+
Feb 01 01:58:30 ey04-s00297 rails[4413]: Memory usage: 0 | PID: 4413
|
142
|
+
Feb 01 01:58:31 ey04-s00297 rails[4413]: Completed in
|
143
|
+
Feb 01 01:58:32 ey04-s00297 rails[4413]: Processing MediaController#show (for 92.84.151.171 at 2009-02-01 01:58:29) [GET]
|
144
|
+
Feb 01 01:58:33 ey04-s00297 rails[4413]: Memory usage: #{TEN_MEGS} | PID: 4413
|
145
|
+
Feb 01 01:58:34 ey04-s00297 rails[4413]: Completed in
|
146
|
+
STR
|
147
|
+
|
148
|
+
io = StringIO.new(str)
|
149
|
+
output = PsuedoOutput.new
|
150
|
+
MemoryUsageReport.new(io, TEN_MEGS).print(output)
|
151
|
+
output.should_not include("1. Feb 01 01:58:34, #{TEN_MEGS + 1} KB, MediaController#show")
|
152
|
+
end
|
153
|
+
|
154
|
+
it "should order offenses from biggest to smallest" do
|
155
|
+
str = <<-STR
|
156
|
+
Feb 01 01:58:29 ey04-s00297 rails[4413]: Processing Users#show (for 92.84.151.171 at 2009-02-01 01:58:29) [GET]
|
157
|
+
Feb 01 01:58:30 ey04-s00297 rails[4413]: Memory usage: 0 | PID: 4413
|
158
|
+
Feb 01 01:58:31 ey04-s00297 rails[4413]: Completed in
|
159
|
+
Feb 01 01:58:32 ey04-s00297 rails[4413]: Processing MediaController#show (for 92.84.151.171 at 2009-02-01 01:58:29) [GET]
|
160
|
+
Feb 01 01:58:33 ey04-s00297 rails[4413]: Memory usage: #{TEN_MEGS + 1} | PID: 4413
|
161
|
+
Feb 01 01:58:34 ey04-s00297 rails[4413]: Completed in
|
162
|
+
Feb 01 01:58:35 ey04-s00297 rails[4413]: Processing DetailsController#show (for 92.84.151.171 at 2009-02-01 01:58:29) [GET]
|
163
|
+
Feb 01 01:58:36 ey04-s00297 rails[4413]: Memory usage: #{(TEN_MEGS * 2) + 2} | PID: 4413
|
164
|
+
Feb 01 01:58:37 ey04-s00297 rails[4413]: Completed in
|
165
|
+
STR
|
166
|
+
|
167
|
+
io = StringIO.new(str)
|
168
|
+
output = PsuedoOutput.new
|
169
|
+
MemoryUsageReport.new(io, TEN_MEGS).print(output)
|
170
|
+
output[4].should == "1. Feb 01 01:58:34, #{TEN_MEGS + 1} KB, MediaController#show"
|
171
|
+
output[5].should == "2. Feb 01 01:58:37, #{TEN_MEGS + 1} KB, DetailsController#show"
|
172
|
+
end
|
173
|
+
|
174
|
+
end
|
175
|
+
|
176
|
+
# it "should report the time span" do
|
177
|
+
# str = <<-STR
|
178
|
+
# Feb 01 01:58:29 ey04-s00297 rails[4413]: Processing Users#show (for 92.84.151.171 at 2009-02-01 01:58:29) [GET]
|
179
|
+
# Feb 01 01:58:30 ey04-s00297 rails[4413]: Memory usage: 0 | PID: 4413
|
180
|
+
# Feb 01 01:58:30 ey04-s00297 rails[4413]: Completed in
|
181
|
+
# Mar 13 01:58:29 ey04-s00297 rails[5513]: Processing MediaController#show (for 92.84.151.171 at 2009-02-01 01:58:29) [GET]
|
182
|
+
# Mar 13 01:58:30 ey04-s00297 rails[5513]: Memory usage: #{TEN_MEGS + 1} | PID: 4413
|
183
|
+
# Mar 13 03:58:30 ey04-s00297 rails[5513]: Completed in
|
184
|
+
# STR
|
185
|
+
#
|
186
|
+
# io = StringIO.new(str)
|
187
|
+
# output = PsuedoOutput.new
|
188
|
+
# MemoryUsageReport.new(io, TEN_MEGS).each_line do |line|
|
189
|
+
# output << line
|
190
|
+
# end
|
191
|
+
# output.first.should == "Feb 01 01:58:29 - Mar 13 03:58:30"
|
192
|
+
# end
|
193
|
+
|
194
|
+
end
|
195
|
+
|
196
|
+
describe "verbose format" do
|
197
|
+
it "should print the full lines of actions exceeding the threshold" do
|
198
|
+
str = <<-STR
|
199
|
+
Feb 01 01:58:29 ey04-s00297 rails[4413]: Processing Users#show (for 92.84.151.171 at 2009-02-01 01:58:29) [GET]
|
200
|
+
Feb 01 01:58:29 ey04-s00297 rails[4413]: Parameters: {"id"=>"2332", "controller"=>"users"}
|
201
|
+
Feb 01 01:58:30 ey04-s00297 rails[4413]: Memory usage: 0 | PID: 4413
|
202
|
+
Feb 01 01:58:30 ey04-s00297 rails[4413]: Completed in
|
203
|
+
Feb 01 01:58:29 ey04-s00297 rails[4413]: Processing MediaController#show (for 92.84.151.171 at 2009-02-01 01:58:29) [GET]
|
204
|
+
Feb 01 01:58:29 ey04-s00297 rails[4413]: Parameters: {"id"=>"22900", "controller"=>"media"}
|
205
|
+
Feb 01 01:58:30 ey04-s00297 rails[4413]: Memory usage: #{TEN_MEGS + 1} | PID: 4413
|
206
|
+
Feb 01 01:58:30 ey04-s00297 rails[4413]: Completed in
|
207
|
+
STR
|
208
|
+
io = StringIO.new(str)
|
209
|
+
output = PsuedoOutput.new
|
210
|
+
MemoryUsageReport.new(io, TEN_MEGS, :format => :verbose).print(output)
|
211
|
+
output[3..6].should == str.split("\n")[4..7].map { |o| o.strip }
|
212
|
+
end
|
213
|
+
|
214
|
+
it "should handle actions which do not complete properly" do
|
215
|
+
threshold = 10
|
216
|
+
|
217
|
+
str = <<-STR
|
218
|
+
Feb 01 01:58:29 ey04-s00297 rails[4413]: Processing Users#show (for 92.84.151.171 at 2009-02-01 01:58:29) [GET]
|
219
|
+
Feb 01 01:58:30 ey04-s00297 rails[4413]: Memory usage: 0 | PID: 4413
|
220
|
+
Feb 01 01:58:29 ey04-s00297 rails[4413]: Processing MediaController#show (for 92.84.151.171 at 2009-02-01 01:58:29) [GET]
|
221
|
+
Feb 01 01:58:29 ey04-s00297 rails[4413]: Processing MediaController#show (for 92.84.151.171 at 2009-02-01 01:58:29) [GET]
|
222
|
+
Feb 01 01:58:30 ey04-s00297 rails[4413]: Memory usage: #{TEN_MEGS + 1} | PID: 4413
|
223
|
+
Feb 01 01:58:30 ey04-s00297 rails[4413]: Completed in
|
224
|
+
Feb 01 01:58:29 ey04-s00297 rails[4413]: Processing ActorController#show (for 92.84.151.171 at 2009-02-01 01:58:29) [GET]
|
225
|
+
Feb 01 01:58:30 ey04-s00297 rails[4413]: Memory usage: #{(TEN_MEGS * 2) + 2} | PID: 4413
|
226
|
+
Feb 01 01:58:30 ey04-s00297 rails[4413]: Completed in
|
227
|
+
STR
|
228
|
+
|
229
|
+
io = StringIO.new(str)
|
230
|
+
output = PsuedoOutput.new
|
231
|
+
MemoryUsageReport.new(io, TEN_MEGS, :format => :verbose).print(output)
|
232
|
+
output[3..5].should == str.split("\n")[6..8].map { |o| o.strip }
|
233
|
+
end
|
234
|
+
end
|
235
|
+
|
236
|
+
describe "multiple io streams" do
|
237
|
+
it "should accept multiple files" do
|
238
|
+
|
239
|
+
str1 = <<-STR
|
240
|
+
Feb 01 01:58:29 ey04-s00297 rails[4413]: Processing Users#show (for 92.84.151.171 at 2009-02-01 01:58:29) [GET]
|
241
|
+
Feb 01 01:58:30 ey04-s00297 rails[4413]: Memory usage: 0 | PID: 4413
|
242
|
+
Feb 01 01:58:30 ey04-s00297 rails[4413]: Completed in
|
243
|
+
Feb 01 01:58:29 ey04-s00297 rails[4413]: Processing MediaController#show (for 92.84.151.171 at 2009-02-01 01:58:29) [GET]
|
244
|
+
Feb 01 01:58:30 ey04-s00297 rails[4413]: Memory usage: #{TEN_MEGS + 1} | PID: 4413
|
245
|
+
Feb 01 01:58:30 ey04-s00297 rails[4413]: Completed in
|
246
|
+
STR
|
247
|
+
|
248
|
+
str2 = <<-STR
|
249
|
+
Feb 01 01:58:29 ey04-s00297 rails[4413]: Processing Users#show (for 92.84.151.171 at 2009-02-01 01:58:29) [GET]
|
250
|
+
Feb 01 01:58:30 ey04-s00297 rails[4413]: Memory usage: 0 | PID: 4413
|
251
|
+
Feb 01 01:58:30 ey04-s00297 rails[4413]: Completed in
|
252
|
+
Feb 01 01:58:29 ey04-s00297 rails[4413]: Processing MediaController#show (for 92.84.151.171 at 2009-02-01 01:58:29) [GET]
|
253
|
+
Feb 01 01:58:30 ey04-s00297 rails[4413]: Memory usage: #{TEN_MEGS + 1} | PID: 4413
|
254
|
+
Feb 01 01:58:30 ey04-s00297 rails[4413]: Completed in
|
255
|
+
STR
|
256
|
+
|
257
|
+
io1 = StringIO.new(str1)
|
258
|
+
io2 = StringIO.new(str2)
|
259
|
+
output = PsuedoOutput.new
|
260
|
+
MemoryUsageReport.new([io1, io2], TEN_MEGS).print(output)
|
261
|
+
output.should include("2, MediaController#show")
|
262
|
+
end
|
263
|
+
|
264
|
+
end
|
265
|
+
|
266
|
+
end
|
267
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper")
|
2
|
+
|
3
|
+
module Oink::Reports
|
4
|
+
describe Request do
|
5
|
+
it "should be comparable" do
|
6
|
+
lr1 = Request.new("Controller#Action", "February 1 10:20", [], 10)
|
7
|
+
lr2 = Request.new("Controller#Action", "February 1 10:20", [], 5)
|
8
|
+
|
9
|
+
(lr1 > lr2).should == true
|
10
|
+
(lr1 == lr2).should == false
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should sort by memory used" do
|
14
|
+
lr1 = Request.new("Controller#Action", "February 1 10:20", [], 10)
|
15
|
+
lr2 = Request.new("Controller#Action", "February 1 10:20", [], 5)
|
16
|
+
lr3 = Request.new("Controller#Action", "February 1 10:20", [], 30)
|
17
|
+
|
18
|
+
[lr1, lr2, lr3].sort.should == [lr2, lr1, lr3]
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,74 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper")
|
2
|
+
|
3
|
+
module Oink::Reports
|
4
|
+
describe PriorityQueue do
|
5
|
+
describe "size" do
|
6
|
+
|
7
|
+
it "should report the right size" do
|
8
|
+
pq = PriorityQueue.new(5)
|
9
|
+
pq.push(1)
|
10
|
+
pq.size.should == 1
|
11
|
+
pq.push(2)
|
12
|
+
pq.size.should == 2
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should be limited to the size initialized with" do
|
16
|
+
pq = PriorityQueue.new(5)
|
17
|
+
pq.push(1)
|
18
|
+
pq.push(2)
|
19
|
+
pq.push(3)
|
20
|
+
pq.push(4)
|
21
|
+
pq.push(5)
|
22
|
+
pq.push(6)
|
23
|
+
pq.size.should == 5
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
|
28
|
+
describe "order" do
|
29
|
+
|
30
|
+
it "should be in order from highest to lowest" do
|
31
|
+
pq = PriorityQueue.new(5)
|
32
|
+
pq.push(1)
|
33
|
+
pq.push(2)
|
34
|
+
pq.push(3)
|
35
|
+
pq.to_a.should == [3,2,1]
|
36
|
+
end
|
37
|
+
|
38
|
+
it "should throw out the lower value when adding a new value" do
|
39
|
+
pq = PriorityQueue.new(3)
|
40
|
+
pq.push(1)
|
41
|
+
pq.push(2)
|
42
|
+
pq.push(3)
|
43
|
+
pq.push(4)
|
44
|
+
pq.to_a.should == [4,3,2]
|
45
|
+
end
|
46
|
+
|
47
|
+
it "should not make it into the queue if it's smaller than the items in the queue" do
|
48
|
+
pq = PriorityQueue.new(3)
|
49
|
+
pq.push(2)
|
50
|
+
pq.push(3)
|
51
|
+
pq.push(4)
|
52
|
+
pq.push(1)
|
53
|
+
pq.to_a.should == [4,3,2]
|
54
|
+
end
|
55
|
+
|
56
|
+
end
|
57
|
+
|
58
|
+
describe "each" do
|
59
|
+
it "should return each item in turn" do
|
60
|
+
arr = []
|
61
|
+
pq = PriorityQueue.new(5)
|
62
|
+
pq.push(2)
|
63
|
+
pq.push(3)
|
64
|
+
pq.push(4)
|
65
|
+
pq.push(1)
|
66
|
+
pq.push(5)
|
67
|
+
pq.each do |i|
|
68
|
+
arr << i
|
69
|
+
end
|
70
|
+
arr.should == [5,4,3,2,1]
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,34 +1,18 @@
|
|
1
|
-
require "
|
2
|
-
require "
|
3
|
-
require
|
1
|
+
require "rspec"
|
2
|
+
require "ostruct"
|
3
|
+
require "logger"
|
4
4
|
|
5
|
-
|
6
|
-
require
|
7
|
-
require
|
8
|
-
require "oink/rails/memory_usage_logger"
|
9
|
-
require File.join(dir, '../config/environment')
|
5
|
+
require 'helpers/database'
|
6
|
+
require 'fakes/fake_application_controller'
|
7
|
+
require 'fakes/psuedo_output'
|
10
8
|
|
11
|
-
|
12
|
-
|
13
|
-
def puts(line)
|
14
|
-
self << line
|
15
|
-
end
|
16
|
-
|
17
|
-
end
|
18
|
-
|
19
|
-
Spec::Runner.configure do |config|
|
20
|
-
|
21
|
-
config.before :suite do
|
22
|
-
load File.join(dir, "../db/schema.rb")
|
23
|
-
end
|
9
|
+
require 'oink/cli'
|
10
|
+
require 'oink/rails'
|
24
11
|
|
25
|
-
|
26
|
-
Pig.delete_all
|
27
|
-
Pen.delete_all
|
28
|
-
end
|
12
|
+
RSpec.configure do |config|
|
29
13
|
|
30
14
|
config.before :suite do
|
31
|
-
|
15
|
+
setup_memory_database
|
32
16
|
Pig = Class.new(ActiveRecord::Base)
|
33
17
|
Pen = Class.new(ActiveRecord::Base)
|
34
18
|
Pig.belongs_to :pen
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: oink
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
5
|
-
prerelease:
|
4
|
+
hash: 57
|
5
|
+
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
+
- 9
|
8
9
|
- 1
|
9
|
-
|
10
|
-
version: 0.1.2
|
10
|
+
version: 0.9.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Noah Davis
|
@@ -15,13 +15,40 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date:
|
18
|
+
date: 2011-03-24 00:00:00 -04:00
|
19
19
|
default_executable: oink
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
22
|
+
type: :runtime
|
23
|
+
version_requirements: &id001 !ruby/object:Gem::Requirement
|
24
|
+
none: false
|
25
|
+
requirements:
|
26
|
+
- - ">="
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
hash: 3
|
29
|
+
segments:
|
30
|
+
- 0
|
31
|
+
version: "0"
|
32
|
+
requirement: *id001
|
33
|
+
prerelease: false
|
22
34
|
name: hodel_3000_compliant_logger
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
type: :runtime
|
37
|
+
version_requirements: &id002 !ruby/object:Gem::Requirement
|
38
|
+
none: false
|
39
|
+
requirements:
|
40
|
+
- - ">="
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
hash: 3
|
43
|
+
segments:
|
44
|
+
- 0
|
45
|
+
version: "0"
|
46
|
+
requirement: *id002
|
23
47
|
prerelease: false
|
24
|
-
|
48
|
+
name: activerecord
|
49
|
+
- !ruby/object:Gem::Dependency
|
50
|
+
type: :development
|
51
|
+
version_requirements: &id003 !ruby/object:Gem::Requirement
|
25
52
|
none: false
|
26
53
|
requirements:
|
27
54
|
- - ">="
|
@@ -30,8 +57,93 @@ dependencies:
|
|
30
57
|
segments:
|
31
58
|
- 0
|
32
59
|
version: "0"
|
60
|
+
requirement: *id003
|
61
|
+
prerelease: false
|
62
|
+
name: jeweler
|
63
|
+
- !ruby/object:Gem::Dependency
|
64
|
+
type: :development
|
65
|
+
version_requirements: &id004 !ruby/object:Gem::Requirement
|
66
|
+
none: false
|
67
|
+
requirements:
|
68
|
+
- - ">="
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
hash: 3
|
71
|
+
segments:
|
72
|
+
- 0
|
73
|
+
version: "0"
|
74
|
+
requirement: *id004
|
75
|
+
prerelease: false
|
76
|
+
name: rspec
|
77
|
+
- !ruby/object:Gem::Dependency
|
78
|
+
type: :development
|
79
|
+
version_requirements: &id005 !ruby/object:Gem::Requirement
|
80
|
+
none: false
|
81
|
+
requirements:
|
82
|
+
- - ">="
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
hash: 3
|
85
|
+
segments:
|
86
|
+
- 0
|
87
|
+
version: "0"
|
88
|
+
requirement: *id005
|
89
|
+
prerelease: false
|
90
|
+
name: sqlite3
|
91
|
+
- !ruby/object:Gem::Dependency
|
92
|
+
type: :development
|
93
|
+
version_requirements: &id006 !ruby/object:Gem::Requirement
|
94
|
+
none: false
|
95
|
+
requirements:
|
96
|
+
- - ">="
|
97
|
+
- !ruby/object:Gem::Version
|
98
|
+
hash: 3
|
99
|
+
segments:
|
100
|
+
- 0
|
101
|
+
version: "0"
|
102
|
+
requirement: *id006
|
103
|
+
prerelease: false
|
104
|
+
name: rack-test
|
105
|
+
- !ruby/object:Gem::Dependency
|
106
|
+
type: :development
|
107
|
+
version_requirements: &id007 !ruby/object:Gem::Requirement
|
108
|
+
none: false
|
109
|
+
requirements:
|
110
|
+
- - ">="
|
111
|
+
- !ruby/object:Gem::Version
|
112
|
+
hash: 3
|
113
|
+
segments:
|
114
|
+
- 0
|
115
|
+
version: "0"
|
116
|
+
requirement: *id007
|
117
|
+
prerelease: false
|
118
|
+
name: rake
|
119
|
+
- !ruby/object:Gem::Dependency
|
120
|
+
type: :development
|
121
|
+
version_requirements: &id008 !ruby/object:Gem::Requirement
|
122
|
+
none: false
|
123
|
+
requirements:
|
124
|
+
- - ">="
|
125
|
+
- !ruby/object:Gem::Version
|
126
|
+
hash: 3
|
127
|
+
segments:
|
128
|
+
- 0
|
129
|
+
version: "0"
|
130
|
+
requirement: *id008
|
131
|
+
prerelease: false
|
132
|
+
name: ruby-debug
|
133
|
+
- !ruby/object:Gem::Dependency
|
33
134
|
type: :runtime
|
34
|
-
version_requirements:
|
135
|
+
version_requirements: &id009 !ruby/object:Gem::Requirement
|
136
|
+
none: false
|
137
|
+
requirements:
|
138
|
+
- - ">="
|
139
|
+
- !ruby/object:Gem::Version
|
140
|
+
hash: 3
|
141
|
+
segments:
|
142
|
+
- 0
|
143
|
+
version: "0"
|
144
|
+
requirement: *id009
|
145
|
+
prerelease: false
|
146
|
+
name: hodel_3000_compliant_logger
|
35
147
|
description: Log parser to identify actions which significantly increase VM heap size
|
36
148
|
email: noahd1@yahoo.com
|
37
149
|
executables:
|
@@ -47,31 +159,42 @@ files:
|
|
47
159
|
- Rakefile
|
48
160
|
- bin/oink
|
49
161
|
- lib/oink.rb
|
50
|
-
- lib/oink/active_record_instantiation_reporter.rb
|
51
|
-
- lib/oink/base.rb
|
52
162
|
- lib/oink/cli.rb
|
53
|
-
- lib/oink/
|
54
|
-
- lib/oink/
|
55
|
-
- lib/oink/
|
56
|
-
- lib/oink/
|
57
|
-
- lib/oink/priority_queue.rb
|
163
|
+
- lib/oink/instrumentation.rb
|
164
|
+
- lib/oink/instrumentation/active_record.rb
|
165
|
+
- lib/oink/instrumentation/memory_snapshot.rb
|
166
|
+
- lib/oink/middleware.rb
|
58
167
|
- lib/oink/rails.rb
|
59
168
|
- lib/oink/rails/instance_type_counter.rb
|
60
169
|
- lib/oink/rails/memory_usage_logger.rb
|
61
|
-
-
|
62
|
-
-
|
63
|
-
-
|
64
|
-
-
|
65
|
-
-
|
66
|
-
-
|
170
|
+
- lib/oink/reports/active_record_instantiation_oinked_request.rb
|
171
|
+
- lib/oink/reports/active_record_instantiation_report.rb
|
172
|
+
- lib/oink/reports/base.rb
|
173
|
+
- lib/oink/reports/memory_oinked_request.rb
|
174
|
+
- lib/oink/reports/memory_usage_report.rb
|
175
|
+
- lib/oink/reports/priority_queue.rb
|
176
|
+
- lib/oink/reports/request.rb
|
177
|
+
- lib/oink/utils/hash_utils.rb
|
178
|
+
- spec/fakes/fake_application_controller.rb
|
179
|
+
- spec/fakes/psuedo_output.rb
|
180
|
+
- spec/helpers/database.rb
|
181
|
+
- spec/oink/instrumentation/instance_type_counter_spec.rb
|
182
|
+
- spec/oink/instrumentation/memory_snapshot_spec.rb
|
183
|
+
- spec/oink/middleware_spec.rb
|
184
|
+
- spec/oink/rails/instance_type_counter_spec.rb
|
185
|
+
- spec/oink/rails/memory_usage_logger_spec.rb
|
186
|
+
- spec/oink/reports/active_record_instantiation_report_spec.rb
|
187
|
+
- spec/oink/reports/memory_usage_report_spec.rb
|
188
|
+
- spec/oink/reports/oinked_request_spec.rb
|
189
|
+
- spec/oink/reports/priority_queue_spec.rb
|
67
190
|
- spec/spec_helper.rb
|
68
191
|
has_rdoc: true
|
69
192
|
homepage: http://github.com/noahd1/oink
|
70
193
|
licenses: []
|
71
194
|
|
72
195
|
post_install_message:
|
73
|
-
rdoc_options:
|
74
|
-
|
196
|
+
rdoc_options: []
|
197
|
+
|
75
198
|
require_paths:
|
76
199
|
- lib
|
77
200
|
required_ruby_version: !ruby/object:Gem::Requirement
|
@@ -95,15 +218,21 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
95
218
|
requirements: []
|
96
219
|
|
97
220
|
rubyforge_project:
|
98
|
-
rubygems_version: 1.
|
221
|
+
rubygems_version: 1.4.2
|
99
222
|
signing_key:
|
100
223
|
specification_version: 3
|
101
224
|
summary: Log parser to identify actions which significantly increase VM heap size
|
102
225
|
test_files:
|
103
|
-
- spec/
|
104
|
-
- spec/
|
105
|
-
- spec/
|
106
|
-
- spec/
|
107
|
-
- spec/
|
108
|
-
- spec/
|
226
|
+
- spec/fakes/fake_application_controller.rb
|
227
|
+
- spec/fakes/psuedo_output.rb
|
228
|
+
- spec/helpers/database.rb
|
229
|
+
- spec/oink/instrumentation/instance_type_counter_spec.rb
|
230
|
+
- spec/oink/instrumentation/memory_snapshot_spec.rb
|
231
|
+
- spec/oink/middleware_spec.rb
|
232
|
+
- spec/oink/rails/instance_type_counter_spec.rb
|
233
|
+
- spec/oink/rails/memory_usage_logger_spec.rb
|
234
|
+
- spec/oink/reports/active_record_instantiation_report_spec.rb
|
235
|
+
- spec/oink/reports/memory_usage_report_spec.rb
|
236
|
+
- spec/oink/reports/oinked_request_spec.rb
|
237
|
+
- spec/oink/reports/priority_queue_spec.rb
|
109
238
|
- spec/spec_helper.rb
|