rack-mini-profiler 0.9.2 → 0.9.3
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of rack-mini-profiler might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/README.md +17 -3
- data/lib/html/includes.css +15 -4
- data/lib/html/includes.js +93 -58
- data/lib/html/includes.less +21 -5
- data/lib/html/includes.tmpl +49 -49
- data/lib/html/list.tmpl +8 -8
- data/lib/mini_profiler/asset_version.rb +5 -0
- data/lib/mini_profiler/client_settings.rb +3 -3
- data/lib/mini_profiler/config.rb +11 -11
- data/lib/mini_profiler/gc_profiler.rb +10 -10
- data/lib/mini_profiler/profiler.rb +49 -71
- data/lib/mini_profiler/profiling_methods.rb +15 -17
- data/lib/mini_profiler/storage/file_store.rb +4 -4
- data/lib/mini_profiler/storage/memcache_store.rb +5 -7
- data/lib/mini_profiler/storage/memory_store.rb +56 -27
- data/lib/mini_profiler/storage/redis_store.rb +19 -11
- data/lib/mini_profiler/timer_struct/base.rb +33 -0
- data/lib/mini_profiler/timer_struct/client.rb +89 -0
- data/lib/mini_profiler/timer_struct/custom.rb +22 -0
- data/lib/mini_profiler/timer_struct/page.rb +62 -0
- data/lib/mini_profiler/timer_struct/request.rb +126 -0
- data/lib/mini_profiler/timer_struct/sql.rb +59 -0
- data/lib/mini_profiler/version.rb +2 -2
- data/lib/patches/db/activerecord.rb +42 -0
- data/lib/patches/db/moped.rb +12 -0
- data/lib/patches/db/mysql2.rb +30 -0
- data/lib/patches/db/pg.rb +104 -0
- data/lib/patches/db/plucky.rb +47 -0
- data/lib/patches/db/rsolr.rb +24 -0
- data/lib/patches/db/sequel.rb +10 -0
- data/lib/patches/sql_patches.rb +17 -255
- data/lib/rack-mini-profiler.rb +28 -0
- data/rack-mini-profiler.gemspec +6 -2
- metadata +16 -8
- data/lib/mini_profiler/client_timer_struct.rb +0 -78
- data/lib/mini_profiler/custom_timer_struct.rb +0 -22
- data/lib/mini_profiler/page_timer_struct.rb +0 -58
- data/lib/mini_profiler/request_timer_struct.rb +0 -115
- data/lib/mini_profiler/sql_timer_struct.rb +0 -58
- data/lib/mini_profiler/timer_struct.rb +0 -33
data/lib/rack-mini-profiler.rb
CHANGED
@@ -1,4 +1,32 @@
|
|
1
|
+
require 'json'
|
2
|
+
require 'timeout'
|
3
|
+
require 'thread'
|
4
|
+
|
5
|
+
require 'mini_profiler/version'
|
6
|
+
require 'mini_profiler/asset_version'
|
7
|
+
|
8
|
+
require 'mini_profiler/timer_struct/base'
|
9
|
+
require 'mini_profiler/timer_struct/page'
|
10
|
+
require 'mini_profiler/timer_struct/sql'
|
11
|
+
require 'mini_profiler/timer_struct/custom'
|
12
|
+
require 'mini_profiler/timer_struct/client'
|
13
|
+
require 'mini_profiler/timer_struct/request'
|
14
|
+
|
15
|
+
require 'mini_profiler/storage/abstract_store'
|
16
|
+
require 'mini_profiler/storage/memcache_store'
|
17
|
+
require 'mini_profiler/storage/memory_store'
|
18
|
+
require 'mini_profiler/storage/redis_store'
|
19
|
+
require 'mini_profiler/storage/file_store'
|
20
|
+
|
21
|
+
require 'mini_profiler/config'
|
22
|
+
require 'mini_profiler/profiling_methods'
|
23
|
+
require 'mini_profiler/context'
|
24
|
+
require 'mini_profiler/client_settings'
|
25
|
+
require 'mini_profiler/gc_profiler'
|
1
26
|
require 'mini_profiler/profiler'
|
27
|
+
# TODO
|
28
|
+
# require 'mini_profiler/gc_profiler_ruby_head' if Gem::Version.new('2.1.0') <= Gem::Version.new(RUBY_VERSION)
|
29
|
+
|
2
30
|
require 'patches/sql_patches'
|
3
31
|
require 'patches/net_patches'
|
4
32
|
|
data/rack-mini-profiler.gemspec
CHANGED
@@ -1,8 +1,12 @@
|
|
1
|
+
lib = File.expand_path('../lib', __FILE__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
require 'mini_profiler/version'
|
4
|
+
|
1
5
|
Gem::Specification.new do |s|
|
2
6
|
s.name = "rack-mini-profiler"
|
3
|
-
s.version =
|
7
|
+
s.version = Rack::MiniProfiler::VERSION
|
4
8
|
s.summary = "Profiles loading speed for rack applications."
|
5
|
-
s.authors = ["Sam Saffron",
|
9
|
+
s.authors = ["Sam Saffron","Robin Ward","Aleks Totic"]
|
6
10
|
s.description = "Profiling toolkit for Rack applications with Rails integration. Client Side profiling, DB profiling and Server profiling."
|
7
11
|
s.email = "sam.saffron@gmail.com"
|
8
12
|
s.homepage = "http://miniprofiler.com"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rack-mini-profiler
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sam Saffron
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2015-02-27 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rack
|
@@ -202,25 +202,33 @@ files:
|
|
202
202
|
- lib/html/list.tmpl
|
203
203
|
- lib/html/profile_handler.js
|
204
204
|
- lib/html/share.html
|
205
|
+
- lib/mini_profiler/asset_version.rb
|
205
206
|
- lib/mini_profiler/client_settings.rb
|
206
|
-
- lib/mini_profiler/client_timer_struct.rb
|
207
207
|
- lib/mini_profiler/config.rb
|
208
208
|
- lib/mini_profiler/context.rb
|
209
|
-
- lib/mini_profiler/custom_timer_struct.rb
|
210
209
|
- lib/mini_profiler/gc_profiler.rb
|
211
|
-
- lib/mini_profiler/page_timer_struct.rb
|
212
210
|
- lib/mini_profiler/profiler.rb
|
213
211
|
- lib/mini_profiler/profiling_methods.rb
|
214
|
-
- lib/mini_profiler/request_timer_struct.rb
|
215
|
-
- lib/mini_profiler/sql_timer_struct.rb
|
216
212
|
- lib/mini_profiler/storage/abstract_store.rb
|
217
213
|
- lib/mini_profiler/storage/file_store.rb
|
218
214
|
- lib/mini_profiler/storage/memcache_store.rb
|
219
215
|
- lib/mini_profiler/storage/memory_store.rb
|
220
216
|
- lib/mini_profiler/storage/redis_store.rb
|
221
|
-
- lib/mini_profiler/timer_struct.rb
|
217
|
+
- lib/mini_profiler/timer_struct/base.rb
|
218
|
+
- lib/mini_profiler/timer_struct/client.rb
|
219
|
+
- lib/mini_profiler/timer_struct/custom.rb
|
220
|
+
- lib/mini_profiler/timer_struct/page.rb
|
221
|
+
- lib/mini_profiler/timer_struct/request.rb
|
222
|
+
- lib/mini_profiler/timer_struct/sql.rb
|
222
223
|
- lib/mini_profiler/version.rb
|
223
224
|
- lib/mini_profiler_rails/railtie.rb
|
225
|
+
- lib/patches/db/activerecord.rb
|
226
|
+
- lib/patches/db/moped.rb
|
227
|
+
- lib/patches/db/mysql2.rb
|
228
|
+
- lib/patches/db/pg.rb
|
229
|
+
- lib/patches/db/plucky.rb
|
230
|
+
- lib/patches/db/rsolr.rb
|
231
|
+
- lib/patches/db/sequel.rb
|
224
232
|
- lib/patches/net_patches.rb
|
225
233
|
- lib/patches/sql_patches.rb
|
226
234
|
- lib/rack-mini-profiler.rb
|
@@ -1,78 +0,0 @@
|
|
1
|
-
require 'mini_profiler/timer_struct'
|
2
|
-
|
3
|
-
module Rack
|
4
|
-
class MiniProfiler
|
5
|
-
|
6
|
-
# This class holds the client timings
|
7
|
-
class ClientTimerStruct < TimerStruct
|
8
|
-
|
9
|
-
def self.init_instrumentation
|
10
|
-
"<script type=\"text/javascript\">mPt=function(){var t=[];return{t:t,probe:function(n){t.push({d:new Date(),n:n})}}}()</script>"
|
11
|
-
end
|
12
|
-
|
13
|
-
def self.instrument(name,orig)
|
14
|
-
probe = "<script>mPt.probe('#{name}')</script>"
|
15
|
-
wrapped = probe
|
16
|
-
wrapped << orig
|
17
|
-
wrapped << probe
|
18
|
-
wrapped
|
19
|
-
end
|
20
|
-
|
21
|
-
|
22
|
-
def initialize(env={})
|
23
|
-
super
|
24
|
-
end
|
25
|
-
|
26
|
-
def self.init_from_form_data(env, page_struct)
|
27
|
-
timings = []
|
28
|
-
clientTimes, clientPerf, baseTime = nil
|
29
|
-
form = env['rack.request.form_hash']
|
30
|
-
|
31
|
-
clientPerf = form['clientPerformance'] if form
|
32
|
-
clientTimes = clientPerf['timing'] if clientPerf
|
33
|
-
|
34
|
-
baseTime = clientTimes['navigationStart'].to_i if clientTimes
|
35
|
-
return unless clientTimes && baseTime
|
36
|
-
|
37
|
-
probes = form['clientProbes']
|
38
|
-
translated = {}
|
39
|
-
if probes && !["null", ""].include?(probes)
|
40
|
-
probes.each do |id, val|
|
41
|
-
name = val["n"]
|
42
|
-
translated[name] ||= {}
|
43
|
-
if translated[name][:start]
|
44
|
-
translated[name][:finish] = val["d"]
|
45
|
-
else
|
46
|
-
translated[name][:start] = val["d"]
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
translated.each do |name, data|
|
52
|
-
h = {"Name" => name, "Start" => data[:start].to_i - baseTime}
|
53
|
-
h["Duration"] = data[:finish].to_i - data[:start].to_i if data[:finish]
|
54
|
-
timings.push(h)
|
55
|
-
end
|
56
|
-
|
57
|
-
clientTimes.keys.find_all{|k| k =~ /Start$/ }.each do |k|
|
58
|
-
start = clientTimes[k].to_i - baseTime
|
59
|
-
finish = clientTimes[k.sub(/Start$/, "End")].to_i - baseTime
|
60
|
-
duration = 0
|
61
|
-
duration = finish - start if finish > start
|
62
|
-
name = k.sub(/Start$/, "").split(/(?=[A-Z])/).map{|s| s.capitalize}.join(' ')
|
63
|
-
timings.push({"Name" => name, "Start" => start, "Duration" => duration}) if start >= 0
|
64
|
-
end
|
65
|
-
|
66
|
-
clientTimes.keys.find_all{|k| !(k =~ /(End|Start)$/)}.each do |k|
|
67
|
-
timings.push("Name" => k, "Start" => clientTimes[k].to_i - baseTime, "Duration" => -1)
|
68
|
-
end
|
69
|
-
|
70
|
-
rval = self.new
|
71
|
-
rval['RedirectCount'] = env['rack.request.form_hash']['clientPerformance']['navigation']['redirectCount']
|
72
|
-
rval['Timings'] = timings
|
73
|
-
rval
|
74
|
-
end
|
75
|
-
end
|
76
|
-
|
77
|
-
end
|
78
|
-
end
|
@@ -1,22 +0,0 @@
|
|
1
|
-
require 'mini_profiler/timer_struct'
|
2
|
-
|
3
|
-
module Rack
|
4
|
-
class MiniProfiler
|
5
|
-
|
6
|
-
# Timing system for a custom timers such as cache, redis, RPC, external API
|
7
|
-
# calls, etc.
|
8
|
-
class CustomTimerStruct < TimerStruct
|
9
|
-
def initialize(type, duration_ms, page, parent)
|
10
|
-
@parent = parent
|
11
|
-
@page = page
|
12
|
-
@type = type
|
13
|
-
|
14
|
-
super("Type" => type,
|
15
|
-
"StartMilliseconds" => ((Time.now.to_f * 1000).to_i - page['Started']) - duration_ms,
|
16
|
-
"DurationMilliseconds" => duration_ms,
|
17
|
-
"ParentTimingId" => nil)
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
end
|
22
|
-
end
|
@@ -1,58 +0,0 @@
|
|
1
|
-
require 'mini_profiler/timer_struct'
|
2
|
-
|
3
|
-
module Rack
|
4
|
-
class MiniProfiler
|
5
|
-
|
6
|
-
# PageTimerStruct
|
7
|
-
# Root: RequestTimer
|
8
|
-
# :has_many RequestTimer children
|
9
|
-
# :has_many SqlTimer children
|
10
|
-
# :has_many CustomTimer children
|
11
|
-
class PageTimerStruct < TimerStruct
|
12
|
-
def initialize(env)
|
13
|
-
super("Id" => MiniProfiler.generate_id,
|
14
|
-
"Name" => env['PATH_INFO'],
|
15
|
-
"Started" => (Time.now.to_f * 1000).to_i,
|
16
|
-
"MachineName" => env['SERVER_NAME'],
|
17
|
-
"Level" => 0,
|
18
|
-
"User" => "unknown user",
|
19
|
-
"HasUserViewed" => false,
|
20
|
-
"ClientTimings" => nil,
|
21
|
-
"DurationMilliseconds" => 0,
|
22
|
-
"HasTrivialTimings" => true,
|
23
|
-
"HasAllTrivialTimigs" => false,
|
24
|
-
"TrivialDurationThresholdMilliseconds" => 2,
|
25
|
-
"Head" => nil,
|
26
|
-
"DurationMillisecondsInSql" => 0,
|
27
|
-
"HasSqlTimings" => true,
|
28
|
-
"HasDuplicateSqlTimings" => false,
|
29
|
-
"ExecutedReaders" => 0,
|
30
|
-
"ExecutedScalars" => 0,
|
31
|
-
"ExecutedNonQueries" => 0,
|
32
|
-
"CustomTimingNames" => [],
|
33
|
-
"CustomTimingStats" => {}
|
34
|
-
)
|
35
|
-
name = "#{env['REQUEST_METHOD']} http://#{env['SERVER_NAME']}:#{env['SERVER_PORT']}#{env['SCRIPT_NAME']}#{env['PATH_INFO']}"
|
36
|
-
self['Root'] = RequestTimerStruct.createRoot(name, self)
|
37
|
-
end
|
38
|
-
|
39
|
-
def duration_ms
|
40
|
-
@attributes['Root']['DurationMilliseconds']
|
41
|
-
end
|
42
|
-
|
43
|
-
def root
|
44
|
-
@attributes['Root']
|
45
|
-
end
|
46
|
-
|
47
|
-
def to_json(*a)
|
48
|
-
attribs = @attributes.merge(
|
49
|
-
"Started" => '/Date(%d)/' % @attributes['Started'],
|
50
|
-
"DurationMilliseconds" => @attributes['Root']['DurationMilliseconds'],
|
51
|
-
"CustomTimingNames" => @attributes['CustomTimingStats'].keys.sort
|
52
|
-
)
|
53
|
-
::JSON.generate(attribs, :max_nesting => 100)
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
end
|
58
|
-
end
|
@@ -1,115 +0,0 @@
|
|
1
|
-
require 'mini_profiler/timer_struct'
|
2
|
-
|
3
|
-
module Rack
|
4
|
-
class MiniProfiler
|
5
|
-
|
6
|
-
class RequestTimerStruct < TimerStruct
|
7
|
-
|
8
|
-
def self.createRoot(name, page)
|
9
|
-
rt = RequestTimerStruct.new(name, page, nil)
|
10
|
-
rt["IsRoot"]= true
|
11
|
-
rt
|
12
|
-
end
|
13
|
-
|
14
|
-
attr_accessor :children_duration
|
15
|
-
|
16
|
-
def initialize(name, page, parent)
|
17
|
-
super("Id" => MiniProfiler.generate_id,
|
18
|
-
"Name" => name,
|
19
|
-
"DurationMilliseconds" => 0,
|
20
|
-
"DurationWithoutChildrenMilliseconds"=> 0,
|
21
|
-
"StartMilliseconds" => (Time.now.to_f * 1000).to_i - page['Started'],
|
22
|
-
"ParentTimingId" => nil,
|
23
|
-
"Children" => [],
|
24
|
-
"HasChildren"=> false,
|
25
|
-
"KeyValues" => nil,
|
26
|
-
"HasSqlTimings"=> false,
|
27
|
-
"HasDuplicateSqlTimings"=> false,
|
28
|
-
"TrivialDurationThresholdMilliseconds" => 2,
|
29
|
-
"SqlTimings" => [],
|
30
|
-
"SqlTimingsDurationMilliseconds"=> 0,
|
31
|
-
"IsTrivial"=> false,
|
32
|
-
"IsRoot"=> false,
|
33
|
-
"Depth"=> parent ? parent.depth + 1 : 0,
|
34
|
-
"ExecutedReaders"=> 0,
|
35
|
-
"ExecutedScalars"=> 0,
|
36
|
-
"ExecutedNonQueries"=> 0,
|
37
|
-
"CustomTimingStats" => {},
|
38
|
-
"CustomTimings" => {})
|
39
|
-
@children_duration = 0
|
40
|
-
@start = Time.now
|
41
|
-
@parent = parent
|
42
|
-
@page = page
|
43
|
-
end
|
44
|
-
|
45
|
-
def duration_ms
|
46
|
-
self['DurationMilliseconds']
|
47
|
-
end
|
48
|
-
|
49
|
-
def start_ms
|
50
|
-
self['StartMilliseconds']
|
51
|
-
end
|
52
|
-
|
53
|
-
def start
|
54
|
-
@start
|
55
|
-
end
|
56
|
-
|
57
|
-
def depth
|
58
|
-
self['Depth']
|
59
|
-
end
|
60
|
-
|
61
|
-
def children
|
62
|
-
self['Children']
|
63
|
-
end
|
64
|
-
|
65
|
-
def add_child(name)
|
66
|
-
request_timer = RequestTimerStruct.new(name, @page, self)
|
67
|
-
self['Children'].push(request_timer)
|
68
|
-
self['HasChildren'] = true
|
69
|
-
request_timer['ParentTimingId'] = self['Id']
|
70
|
-
request_timer['Depth'] = self['Depth'] + 1
|
71
|
-
request_timer
|
72
|
-
end
|
73
|
-
|
74
|
-
def add_sql(query, elapsed_ms, page, skip_backtrace = false, full_backtrace = false)
|
75
|
-
timer = SqlTimerStruct.new(query, elapsed_ms, page, self , skip_backtrace, full_backtrace)
|
76
|
-
timer['ParentTimingId'] = self['Id']
|
77
|
-
self['SqlTimings'].push(timer)
|
78
|
-
self['HasSqlTimings'] = true
|
79
|
-
self['SqlTimingsDurationMilliseconds'] += elapsed_ms
|
80
|
-
page['DurationMillisecondsInSql'] += elapsed_ms
|
81
|
-
timer
|
82
|
-
end
|
83
|
-
|
84
|
-
def add_custom(type, elapsed_ms, page)
|
85
|
-
timer = CustomTimerStruct.new(type, elapsed_ms, page, self)
|
86
|
-
timer['ParentTimingId'] = self['Id']
|
87
|
-
self['CustomTimings'][type] ||= []
|
88
|
-
self['CustomTimings'][type].push(timer)
|
89
|
-
|
90
|
-
self['CustomTimingStats'][type] ||= {"Count" => 0, "Duration" => 0.0}
|
91
|
-
self['CustomTimingStats'][type]['Count'] += 1
|
92
|
-
self['CustomTimingStats'][type]['Duration'] += elapsed_ms
|
93
|
-
|
94
|
-
page['CustomTimingStats'][type] ||= {"Count" => 0, "Duration" => 0.0}
|
95
|
-
page['CustomTimingStats'][type]['Count'] += 1
|
96
|
-
page['CustomTimingStats'][type]['Duration'] += elapsed_ms
|
97
|
-
|
98
|
-
timer
|
99
|
-
end
|
100
|
-
|
101
|
-
def record_time(milliseconds = nil)
|
102
|
-
milliseconds ||= (Time.now - @start) * 1000
|
103
|
-
self['DurationMilliseconds'] = milliseconds
|
104
|
-
self['IsTrivial'] = true if milliseconds < self["TrivialDurationThresholdMilliseconds"]
|
105
|
-
self['DurationWithoutChildrenMilliseconds'] = milliseconds - @children_duration
|
106
|
-
|
107
|
-
if @parent
|
108
|
-
@parent.children_duration += milliseconds
|
109
|
-
end
|
110
|
-
|
111
|
-
end
|
112
|
-
end
|
113
|
-
end
|
114
|
-
|
115
|
-
end
|
@@ -1,58 +0,0 @@
|
|
1
|
-
require 'mini_profiler/timer_struct'
|
2
|
-
|
3
|
-
module Rack
|
4
|
-
class MiniProfiler
|
5
|
-
|
6
|
-
# Timing system for a SQL query
|
7
|
-
class SqlTimerStruct < TimerStruct
|
8
|
-
def initialize(query, duration_ms, page, parent, skip_backtrace = false, full_backtrace = false)
|
9
|
-
|
10
|
-
stack_trace = nil
|
11
|
-
unless skip_backtrace || duration_ms < Rack::MiniProfiler.config.backtrace_threshold_ms
|
12
|
-
# Allow us to filter the stack trace
|
13
|
-
stack_trace = ""
|
14
|
-
# Clean up the stack trace if there are options to do so
|
15
|
-
Kernel.caller.each do |ln|
|
16
|
-
ln.gsub!(Rack::MiniProfiler.config.backtrace_remove, '') if Rack::MiniProfiler.config.backtrace_remove and !full_backtrace
|
17
|
-
if full_backtrace or
|
18
|
-
(
|
19
|
-
(
|
20
|
-
Rack::MiniProfiler.config.backtrace_includes.nil? or
|
21
|
-
Rack::MiniProfiler.config.backtrace_includes.all?{|regex| ln =~ regex}
|
22
|
-
) and
|
23
|
-
(
|
24
|
-
Rack::MiniProfiler.config.backtrace_ignores.nil? or
|
25
|
-
Rack::MiniProfiler.config.backtrace_ignores.all?{|regex| !(ln =~ regex)}
|
26
|
-
)
|
27
|
-
)
|
28
|
-
stack_trace << ln << "\n"
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
@parent = parent
|
34
|
-
@page = page
|
35
|
-
|
36
|
-
super("ExecuteType" => 3, # TODO
|
37
|
-
"FormattedCommandString" => query,
|
38
|
-
"StackTraceSnippet" => stack_trace,
|
39
|
-
"StartMilliseconds" => ((Time.now.to_f * 1000).to_i - page['Started']) - duration_ms,
|
40
|
-
"DurationMilliseconds" => duration_ms,
|
41
|
-
"FirstFetchDurationMilliseconds" => duration_ms,
|
42
|
-
"Parameters" => nil,
|
43
|
-
"ParentTimingId" => nil,
|
44
|
-
"IsDuplicate" => false)
|
45
|
-
end
|
46
|
-
|
47
|
-
def report_reader_duration(elapsed_ms)
|
48
|
-
return if @reported
|
49
|
-
@reported = true
|
50
|
-
self["DurationMilliseconds"] += elapsed_ms
|
51
|
-
@parent["SqlTimingsDurationMilliseconds"] += elapsed_ms
|
52
|
-
@page["DurationMillisecondsInSql"] += elapsed_ms
|
53
|
-
end
|
54
|
-
|
55
|
-
end
|
56
|
-
|
57
|
-
end
|
58
|
-
end
|
@@ -1,33 +0,0 @@
|
|
1
|
-
module Rack
|
2
|
-
class MiniProfiler
|
3
|
-
|
4
|
-
# A base class for timing structures
|
5
|
-
class TimerStruct
|
6
|
-
|
7
|
-
def initialize(attrs={})
|
8
|
-
@attributes = attrs
|
9
|
-
end
|
10
|
-
|
11
|
-
def attributes
|
12
|
-
@attributes ||= {}
|
13
|
-
end
|
14
|
-
|
15
|
-
def [](name)
|
16
|
-
attributes[name]
|
17
|
-
end
|
18
|
-
|
19
|
-
def []=(name, val)
|
20
|
-
attributes[name] = val
|
21
|
-
self
|
22
|
-
end
|
23
|
-
|
24
|
-
def to_json(*a)
|
25
|
-
# this does could take in an option hash, but the only interesting there is max_nesting.
|
26
|
-
# if this becomes an option we could increase
|
27
|
-
::JSON.generate( @attributes, :max_nesting => 100 )
|
28
|
-
end
|
29
|
-
|
30
|
-
end
|
31
|
-
|
32
|
-
end
|
33
|
-
end
|