rack-mini-profiler 0.1.13.pre → 0.1.18
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.
Potentially problematic release.
This version of rack-mini-profiler might be problematic. Click here for more details.
- data/CHANGELOG +18 -0
- data/lib/html/includes.js +1 -1
- data/lib/html/includes.tmpl +4 -4
- data/lib/mini_profiler/client_settings.rb +2 -2
- data/lib/mini_profiler/profiler.rb +30 -7
- data/lib/mini_profiler/profiling_methods.rb +32 -4
- data/lib/mini_profiler/storage/memory_store.rb +1 -1
- data/rack-mini-profiler.gemspec +1 -1
- metadata +9 -6
data/CHANGELOG
CHANGED
@@ -63,3 +63,21 @@
|
|
63
63
|
* made pp=full-backtrace "sticky"
|
64
64
|
* added pp=normal-backtrace to clear the "sticky" state
|
65
65
|
* change "pp=sample" to work with "caller" no need for stack trace gem
|
66
|
+
|
67
|
+
4-September-2012 - Sam
|
68
|
+
|
69
|
+
* 1.15.pre
|
70
|
+
* fixed annoying bug where client settings were not sticking
|
71
|
+
* fixed long standing issue with Rack::ConditionalGet stopping MiniProfiler from working properly
|
72
|
+
|
73
|
+
5-September-2012 - Sam
|
74
|
+
|
75
|
+
* 1.16
|
76
|
+
* fixed long standing problem specs (issue with memory store)
|
77
|
+
* fixed issue where profiler would be dumped when you got a 404 in production (and any time rails is bypassed)
|
78
|
+
* implemented stacktrace properly
|
79
|
+
|
80
|
+
9-September-2012 - Sam
|
81
|
+
|
82
|
+
* 1.17
|
83
|
+
* pp=sample was bust unless stacktrace was installed
|
data/lib/html/includes.js
CHANGED
@@ -114,7 +114,7 @@ var MiniProfiler = (function ($) {
|
|
114
114
|
|
115
115
|
}
|
116
116
|
}
|
117
|
-
} else if (ajaxStartTime != null && clientProbes.length > 0) {
|
117
|
+
} else if (ajaxStartTime != null && clientProbes && clientProbes.length > 0) {
|
118
118
|
clientPerformance = { timing: { navigationStart: ajaxStartTime.getTime() } };
|
119
119
|
ajaxStartTime = null;
|
120
120
|
}
|
data/lib/html/includes.tmpl
CHANGED
@@ -43,7 +43,7 @@
|
|
43
43
|
{{if HasSqlTimings}}
|
44
44
|
<td colspan="2" class="profiler-number profiler-percent-in-sql" title="${MiniProfiler.getSqlTimingsCount(Root)} queries spent ${MiniProfiler.formatDuration(DurationMillisecondsInSql)} ms of total request time">
|
45
45
|
${MiniProfiler.formatDuration(DurationMillisecondsInSql / DurationMilliseconds * 100)}
|
46
|
-
<span class="profiler-unit">% in
|
46
|
+
<span class="profiler-unit">% in sql</span>
|
47
47
|
</td>
|
48
48
|
{{/if}}
|
49
49
|
</tr>
|
@@ -138,10 +138,10 @@
|
|
138
138
|
</td>
|
139
139
|
|
140
140
|
{{if HasSqlTimings}}
|
141
|
-
<td class="profiler-duration {{if HasDuplicateSqlTimings}}profiler-warning{{/if}}" title="{{if HasDuplicateSqlTimings}}duplicate queries detected - {{/if}}${ExecutedReaders} reader, ${ExecutedScalars} scalar, ${ExecutedNonQueries} non-query statements executed">
|
141
|
+
<td class="profiler-duration {{if HasDuplicateSqlTimings}}profiler-warning{{/if}}" title="{{if HasDuplicateSqlTimings}}duplicate queries detected - {{/if}}{{if ExecutedReaders > 0 || ExecutedScalars > 0 || ExecutedNonQueries > 0}}${ExecutedReaders} reader, ${ExecutedScalars} scalar, ${ExecutedNonQueries} non-query statements executed{{/if}}">
|
142
142
|
<a class="profiler-queries-show">
|
143
143
|
{{if HasDuplicateSqlTimings}}<span class="profiler-nuclear">!</span>{{/if}}
|
144
|
-
${SqlTimings.length} <span class="profiler-unit">
|
144
|
+
${SqlTimings.length} <span class="profiler-unit">sql</span>
|
145
145
|
</a>
|
146
146
|
</td>
|
147
147
|
<td class="profiler-duration" title="aggregate duration of all queries in this step (excludes children)">
|
@@ -192,4 +192,4 @@
|
|
192
192
|
</td>
|
193
193
|
</tr>
|
194
194
|
|
195
|
-
</script>
|
195
|
+
</script>
|
@@ -33,12 +33,12 @@ module Rack
|
|
33
33
|
settings["dp"] = "t" if @disable_profiling
|
34
34
|
settings["bt"] = @backtrace_level if @backtrace_level
|
35
35
|
settings_string = settings.map{|k,v| "#{k}=#{v}"}.join(",")
|
36
|
-
Rack::Utils.set_cookie_header!(headers, COOKIE_NAME, :value => settings_string)
|
36
|
+
Rack::Utils.set_cookie_header!(headers, COOKIE_NAME, :value => settings_string, :path => '/')
|
37
37
|
end
|
38
38
|
end
|
39
39
|
|
40
40
|
def discard_cookie!(headers)
|
41
|
-
Rack::Utils.delete_cookie_header!(headers, COOKIE_NAME)
|
41
|
+
Rack::Utils.delete_cookie_header!(headers, COOKIE_NAME, :path => '/')
|
42
42
|
end
|
43
43
|
|
44
44
|
def has_cookie?
|
@@ -19,7 +19,7 @@ module Rack
|
|
19
19
|
|
20
20
|
class MiniProfiler
|
21
21
|
|
22
|
-
VERSION = '
|
22
|
+
VERSION = '107'.freeze
|
23
23
|
|
24
24
|
class << self
|
25
25
|
|
@@ -225,17 +225,30 @@ module Rack
|
|
225
225
|
done_sampling = false
|
226
226
|
quit_sampler = false
|
227
227
|
backtraces = nil
|
228
|
-
|
228
|
+
stacktrace_installed = true
|
229
229
|
if query_string =~ /pp=sample/
|
230
|
+
skip_frames = 0
|
230
231
|
backtraces = []
|
231
232
|
t = Thread.current
|
233
|
+
|
234
|
+
begin
|
235
|
+
require 'stacktrace'
|
236
|
+
skip_frames = stacktrace.length
|
237
|
+
rescue LoadError
|
238
|
+
stacktrace_installed = false
|
239
|
+
end
|
240
|
+
|
232
241
|
Thread.new {
|
233
242
|
begin
|
234
243
|
i = 10000 # for sanity never grab more than 10k samples
|
235
244
|
while i > 0
|
236
245
|
break if done_sampling
|
237
246
|
i -= 1
|
238
|
-
|
247
|
+
if stacktrace_installed
|
248
|
+
backtraces << t.stacktrace(0,-(1+skip_frames), StackFrame::Flags::METHOD | StackFrame::Flags::KLASS)
|
249
|
+
else
|
250
|
+
backtraces << t.backtrace
|
251
|
+
end
|
239
252
|
sleep 0.001
|
240
253
|
end
|
241
254
|
ensure
|
@@ -247,6 +260,12 @@ module Rack
|
|
247
260
|
status, headers, body = nil
|
248
261
|
start = Time.now
|
249
262
|
begin
|
263
|
+
|
264
|
+
# Strip all the caching headers so we don't get 304s back
|
265
|
+
# This solves a very annoying bug where rack mini profiler never shows up
|
266
|
+
env['HTTP_IF_MODIFIED_SINCE'] = nil
|
267
|
+
env['HTTP_IF_NONE_MATCH'] = nil
|
268
|
+
|
250
269
|
status,headers,body = @app.call(env)
|
251
270
|
client_settings.write!(headers)
|
252
271
|
ensure
|
@@ -258,10 +277,14 @@ module Rack
|
|
258
277
|
|
259
278
|
skip_it = current.discard
|
260
279
|
if (config.authorization_mode == :whitelist && !MiniProfiler.request_authorized?)
|
261
|
-
|
280
|
+
# this is non-obvious, don't kill the profiling cookie on errors or short requests
|
281
|
+
# this ensures that stuff that never reaches the rails stack does not kill profiling
|
282
|
+
if status == 200 && ((Time.now - start) > 0.1)
|
283
|
+
client_settings.discard_cookie!(headers)
|
284
|
+
end
|
262
285
|
skip_it = true
|
263
286
|
end
|
264
|
-
|
287
|
+
|
265
288
|
return [status,headers,body] if skip_it
|
266
289
|
|
267
290
|
# we must do this here, otherwise current[:discard] is not being properly treated
|
@@ -280,7 +303,6 @@ module Rack
|
|
280
303
|
|
281
304
|
if backtraces
|
282
305
|
body.close if body.respond_to? :close
|
283
|
-
return help(:stacktrace, client_settings) if missing_stacktrace
|
284
306
|
return analyze(backtraces, page_struct)
|
285
307
|
end
|
286
308
|
|
@@ -360,7 +382,7 @@ module Rack
|
|
360
382
|
pp=no-backtrace #{"(*) " if client_settings.backtrace_none?}: don't collect stack traces from all the SQL executed (sticky, use pp=normal-backtrace to enable)
|
361
383
|
pp=normal-backtrace #{"(*) " if client_settings.backtrace_default?}: collect stack traces from all the SQL executed and filter normally
|
362
384
|
pp=full-backtrace #{"(*) " if client_settings.backtrace_full?}: enable full backtraces for SQL executed (use pp=normal-backtrace to disable)
|
363
|
-
pp=sample : sample stack traces and return a report isolating heavy usage (experimental)
|
385
|
+
pp=sample : sample stack traces and return a report isolating heavy usage (experimental works best with the stacktrace gem)
|
364
386
|
pp=disable : disable profiling for this session
|
365
387
|
pp=enable : enable profiling for this session (if previously disabled)
|
366
388
|
"
|
@@ -382,6 +404,7 @@ module Rack
|
|
382
404
|
fulldump << "\n\n"
|
383
405
|
distinct = {}
|
384
406
|
trace.each do |frame|
|
407
|
+
frame = "#{frame.klass}::#{frame.method}" unless String === frame
|
385
408
|
unless distinct[frame]
|
386
409
|
distinct[frame] = true
|
387
410
|
seen[frame] ||= 0
|
@@ -8,6 +8,22 @@ module Rack
|
|
8
8
|
c.current_timer.add_sql(query, elapsed_ms, c.page_struct, c.skip_backtrace, c.full_backtrace) if (c && c.current_timer)
|
9
9
|
end
|
10
10
|
|
11
|
+
def start_step(name)
|
12
|
+
if current
|
13
|
+
parent_timer = current.current_timer
|
14
|
+
current.current_timer = current_timer = current.current_timer.add_child(name)
|
15
|
+
[current_timer,parent_timer]
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def finish_step(obj)
|
20
|
+
if obj && current
|
21
|
+
current_timer, parent_timer = obj
|
22
|
+
current_timer.record_time
|
23
|
+
current.current_timer = parent_timer
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
11
27
|
# perform a profiling step on given block
|
12
28
|
def step(name, opts = nil)
|
13
29
|
if current
|
@@ -26,8 +42,11 @@ module Rack
|
|
26
42
|
end
|
27
43
|
|
28
44
|
def unprofile_method(klass, method)
|
29
|
-
|
30
|
-
|
45
|
+
|
46
|
+
clean = clean_method_name(method)
|
47
|
+
|
48
|
+
with_profiling = ("#{clean}_with_mini_profiler").intern
|
49
|
+
without_profiling = ("#{clean}_without_mini_profiler").intern
|
31
50
|
|
32
51
|
if klass.send :method_defined?, with_profiling
|
33
52
|
klass.send :alias_method, method, without_profiling
|
@@ -38,8 +57,10 @@ module Rack
|
|
38
57
|
|
39
58
|
def profile_method(klass, method, &blk)
|
40
59
|
default_name = klass.to_s + " " + method.to_s
|
41
|
-
|
42
|
-
|
60
|
+
clean = clean_method_name(method)
|
61
|
+
|
62
|
+
with_profiling = ("#{clean}_with_mini_profiler").intern
|
63
|
+
without_profiling = ("#{clean}_without_mini_profiler").intern
|
43
64
|
|
44
65
|
if klass.send :method_defined?, with_profiling
|
45
66
|
return # dont double profile
|
@@ -67,6 +88,13 @@ module Rack
|
|
67
88
|
end
|
68
89
|
klass.send :alias_method, method, with_profiling
|
69
90
|
end
|
91
|
+
|
92
|
+
private
|
93
|
+
|
94
|
+
def clean_method_name(method)
|
95
|
+
method.to_s.gsub(/[\?\!]/, "")
|
96
|
+
end
|
97
|
+
|
70
98
|
end
|
71
99
|
end
|
72
100
|
end
|
@@ -55,7 +55,7 @@ module Rack
|
|
55
55
|
def cleanup_cache
|
56
56
|
expire_older_than = ((Time.now.to_f - MiniProfiler::MemoryStore::EXPIRE_TIMER_CACHE) * 1000).to_i
|
57
57
|
@timer_struct_lock.synchronize {
|
58
|
-
@timer_struct_cache.delete_if { |k, v| v['
|
58
|
+
@timer_struct_cache.delete_if { |k, v| v['Started'] < expire_older_than }
|
59
59
|
}
|
60
60
|
end
|
61
61
|
end
|
data/rack-mini-profiler.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = "rack-mini-profiler"
|
3
|
-
s.version = "0.1.
|
3
|
+
s.version = "0.1.18"
|
4
4
|
s.summary = "Profiles loading speed for rack applications."
|
5
5
|
s.authors = ["Aleks Totic","Sam Saffron", "Robin Ward"]
|
6
6
|
s.description = "Page loading speed displayed on every page. Optimize while you develop, performance is a feature."
|
metadata
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rack-mini-profiler
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
5
|
-
prerelease:
|
4
|
+
version: 0.1.18
|
5
|
+
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Aleks Totic
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2012-09-
|
14
|
+
date: 2012-09-07 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: rack
|
@@ -131,13 +131,16 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
131
131
|
version: '0'
|
132
132
|
segments:
|
133
133
|
- 0
|
134
|
-
hash: -
|
134
|
+
hash: -322245347
|
135
135
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
136
136
|
none: false
|
137
137
|
requirements:
|
138
|
-
- - ! '
|
138
|
+
- - ! '>='
|
139
139
|
- !ruby/object:Gem::Version
|
140
|
-
version:
|
140
|
+
version: '0'
|
141
|
+
segments:
|
142
|
+
- 0
|
143
|
+
hash: -322245347
|
141
144
|
requirements: []
|
142
145
|
rubyforge_project:
|
143
146
|
rubygems_version: 1.8.24
|