rack-mini-profiler 1.0.2 → 3.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +138 -21
- data/README.md +201 -94
- data/lib/enable_rails_patches.rb +5 -0
- data/lib/generators/rack_mini_profiler/USAGE +9 -0
- data/lib/generators/rack_mini_profiler/install_generator.rb +13 -0
- data/lib/generators/{rack_profiler/templates/rack_profiler.rb → rack_mini_profiler/templates/rack_mini_profiler.rb} +1 -1
- data/lib/generators/rack_profiler/install_generator.rb +6 -3
- data/lib/html/dot.1.1.2.min.js +2 -0
- data/lib/html/includes.css +144 -45
- data/lib/html/includes.js +1423 -1009
- data/lib/html/includes.scss +538 -441
- data/lib/html/includes.tmpl +231 -148
- data/lib/html/pretty-print.js +810 -0
- data/lib/html/profile_handler.js +1 -1
- data/lib/html/rack-mini-profiler.css +3 -0
- data/lib/html/rack-mini-profiler.js +2 -0
- data/lib/html/share.html +0 -1
- data/lib/html/speedscope/LICENSE +21 -0
- data/lib/html/speedscope/README.md +3 -0
- data/lib/html/speedscope/demangle-cpp.1768f4cc.js +4 -0
- data/lib/html/speedscope/favicon-16x16.f74b3187.png +0 -0
- data/lib/html/speedscope/favicon-32x32.bc503437.png +0 -0
- data/lib/html/speedscope/file-format-schema.json +324 -0
- data/lib/html/speedscope/fonts/source-code-pro-regular.css +8 -0
- data/lib/html/speedscope/fonts/source-code-pro-v13-regular.woff +0 -0
- data/lib/html/speedscope/fonts/source-code-pro-v13-regular.woff2 +0 -0
- data/lib/html/speedscope/import.cf0fa83f.js +115 -0
- data/lib/html/speedscope/index.html +2 -0
- data/lib/html/speedscope/release.txt +3 -0
- data/lib/html/speedscope/reset.8c46b7a1.css +2 -0
- data/lib/html/speedscope/source-map.438fa06b.js +24 -0
- data/lib/html/speedscope/speedscope.44364064.js +200 -0
- data/lib/html/vendor.js +848 -0
- data/lib/mini_profiler/asset_version.rb +3 -2
- data/lib/mini_profiler/client_settings.rb +15 -7
- data/lib/mini_profiler/config.rb +51 -5
- data/lib/mini_profiler/gc_profiler.rb +1 -1
- data/lib/mini_profiler/profiling_methods.rb +13 -8
- data/lib/mini_profiler/snapshots_transporter.rb +109 -0
- data/lib/mini_profiler/storage/abstract_store.rb +52 -1
- data/lib/mini_profiler/storage/file_store.rb +7 -3
- data/lib/mini_profiler/storage/memcache_store.rb +13 -7
- data/lib/mini_profiler/storage/memory_store.rb +98 -5
- data/lib/mini_profiler/storage/redis_store.rb +226 -3
- data/lib/mini_profiler/storage.rb +7 -0
- data/lib/mini_profiler/timer_struct/base.rb +2 -0
- data/lib/mini_profiler/timer_struct/custom.rb +1 -0
- data/lib/mini_profiler/timer_struct/page.rb +60 -4
- data/lib/mini_profiler/timer_struct/request.rb +53 -11
- data/lib/mini_profiler/timer_struct/sql.rb +6 -2
- data/lib/mini_profiler/timer_struct.rb +8 -0
- data/lib/mini_profiler/version.rb +2 -1
- data/lib/{mini_profiler/profiler.rb → mini_profiler.rb} +394 -82
- data/lib/mini_profiler_rails/railtie.rb +88 -7
- data/lib/mini_profiler_rails/railtie_methods.rb +61 -0
- data/lib/patches/db/activerecord.rb +1 -12
- data/lib/patches/db/mongo.rb +1 -1
- data/lib/patches/db/moped.rb +1 -1
- data/lib/patches/db/mysql2/alias_method.rb +30 -0
- data/lib/patches/db/mysql2/prepend.rb +34 -0
- data/lib/patches/db/mysql2.rb +4 -27
- data/lib/patches/db/plucky.rb +4 -4
- data/lib/patches/db/riak.rb +1 -1
- data/lib/patches/net_patches.rb +21 -10
- data/lib/patches/sql_patches.rb +13 -5
- data/lib/prepend_mysql2_patch.rb +5 -0
- data/lib/prepend_net_http_patch.rb +5 -0
- data/lib/rack-mini-profiler.rb +1 -24
- data/rack-mini-profiler.gemspec +17 -8
- metadata +156 -32
- data/lib/html/jquery.1.7.1.js +0 -4
- data/lib/html/jquery.tmpl.js +0 -486
- data/lib/html/list.css +0 -9
- data/lib/html/list.js +0 -38
- data/lib/html/list.tmpl +0 -34
data/lib/html/includes.js
CHANGED
@@ -1,1103 +1,1517 @@
|
|
1
1
|
"use strict";
|
2
|
-
var MiniProfiler = (function () {
|
3
|
-
var $;
|
4
|
-
|
5
|
-
var options,
|
6
|
-
container,
|
7
|
-
controls,
|
8
|
-
fetchedIds = [],
|
9
|
-
fetchingIds = [], // so we never pull down a profiler twice
|
10
|
-
ajaxStartTime,
|
11
|
-
totalsControl,
|
12
|
-
reqs = 0,
|
13
|
-
expandedResults = false,
|
14
|
-
totalTime = 0,
|
15
|
-
totalSqlCount = 0
|
16
|
-
;
|
17
|
-
|
18
|
-
var hasLocalStorage = function (keyPrefix) {
|
19
|
-
try {
|
20
|
-
// attempt to save to localStorage as Safari private windows will throw an error
|
21
|
-
localStorage[keyPrefix+'-test'] = '1';
|
22
|
-
localStorage.removeItem(keyPrefix+'-test');
|
23
|
-
return 'localStorage' in window && window['localStorage'] !== null ;
|
24
|
-
} catch (e) {
|
25
|
-
return false;
|
26
|
-
}
|
27
|
-
};
|
28
|
-
|
29
|
-
var getVersionedKey = function (keyPrefix) {
|
30
|
-
return keyPrefix + '-' + options.version;
|
31
|
-
};
|
32
|
-
|
33
|
-
var save = function (keyPrefix, value) {
|
34
|
-
if (!hasLocalStorage(keyPrefix)) { return; }
|
35
2
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
3
|
+
var _MiniProfiler = (function() {
|
4
|
+
var _arguments = arguments;
|
5
|
+
var options,
|
6
|
+
container,
|
7
|
+
controls,
|
8
|
+
fetchedIds = (window.MiniProfiler && window.MiniProfiler.fetchedIds) || [],
|
9
|
+
fetchingIds =
|
10
|
+
(window.MiniProfiler && window.MiniProfiler.fetchingIds) || [],
|
11
|
+
// so we never pull down a profiler twice
|
12
|
+
ajaxStartTime,
|
13
|
+
totalsControl,
|
14
|
+
reqs = 0,
|
15
|
+
expandedResults = false,
|
16
|
+
totalTime = 0,
|
17
|
+
totalSqlCount = 0;
|
18
|
+
|
19
|
+
var hasLocalStorage = function hasLocalStorage(keyPrefix) {
|
20
|
+
try {
|
21
|
+
// attempt to save to localStorage as Safari private windows will throw an error
|
22
|
+
localStorage[keyPrefix + "-test"] = "1";
|
23
|
+
localStorage.removeItem(keyPrefix + "-test");
|
24
|
+
return "localStorage" in window && window["localStorage"] !== null;
|
25
|
+
} catch (e) {
|
26
|
+
return false;
|
27
|
+
}
|
28
|
+
};
|
29
|
+
|
30
|
+
var getVersionedKey = function getVersionedKey(keyPrefix) {
|
31
|
+
return keyPrefix + "-" + options.version;
|
32
|
+
};
|
33
|
+
|
34
|
+
// polyfills as helper functions to avoid conflicts
|
35
|
+
// needed for IE11
|
36
|
+
// remove and replace with Element.closest when we drop IE11 support
|
37
|
+
// https://developer.mozilla.org/en-US/docs/Web/API/Element/closest
|
38
|
+
|
39
|
+
var elementMatches =
|
40
|
+
Element.prototype.msMatchesSelector ||
|
41
|
+
Element.prototype.webkitMatchesSelector;
|
42
|
+
|
43
|
+
var elementClosest = function elementClosest(el, s) {
|
44
|
+
if (typeof el.closest === "function") {
|
45
|
+
return el.closest(s);
|
46
|
+
}
|
47
|
+
|
48
|
+
do {
|
49
|
+
if (typeof el.matches === "function") {
|
50
|
+
if (el.matches(s)) return el;
|
51
|
+
} else {
|
52
|
+
if (elementMatches.call(el, s)) return el;
|
53
|
+
}
|
54
|
+
|
55
|
+
el = el.parentElement || el.parentNode;
|
56
|
+
} while (el !== null && el.nodeType === 1);
|
57
|
+
|
58
|
+
return null;
|
59
|
+
};
|
60
|
+
|
61
|
+
var save = function save(keyPrefix, value) {
|
62
|
+
if (!hasLocalStorage(keyPrefix)) {
|
63
|
+
return;
|
64
|
+
} // clear old keys with this prefix, if any
|
65
|
+
|
66
|
+
for (var i = 0; i < localStorage.length; i++) {
|
67
|
+
if ((localStorage.key(i) || "").indexOf(keyPrefix) > -1) {
|
68
|
+
localStorage.removeItem(localStorage.key(i));
|
69
|
+
}
|
70
|
+
} // save under this version
|
71
|
+
|
72
|
+
localStorage[getVersionedKey(keyPrefix)] = value;
|
73
|
+
};
|
74
|
+
|
75
|
+
var load = function load(keyPrefix) {
|
76
|
+
if (!hasLocalStorage(keyPrefix)) {
|
77
|
+
return null;
|
78
|
+
}
|
79
|
+
|
80
|
+
return localStorage[getVersionedKey(keyPrefix)];
|
81
|
+
};
|
82
|
+
|
83
|
+
var getClientPerformance = function getClientPerformance() {
|
84
|
+
return window.performance === null ? null : window.performance;
|
85
|
+
};
|
86
|
+
|
87
|
+
var fetchResults = function fetchResults(ids) {
|
88
|
+
var clientPerformance, clientProbes, i, j, p, id, idx;
|
89
|
+
|
90
|
+
for (i = 0; i < ids.length; i++) {
|
91
|
+
id = ids[i];
|
92
|
+
clientPerformance = null;
|
93
|
+
clientProbes = null;
|
94
|
+
|
95
|
+
if (window.mPt) {
|
96
|
+
clientProbes = mPt.results();
|
97
|
+
|
98
|
+
for (j = 0; j < clientProbes.length; j++) {
|
99
|
+
clientProbes[j].d = clientProbes[j].d.getTime();
|
41
100
|
}
|
42
101
|
|
43
|
-
|
44
|
-
|
45
|
-
};
|
102
|
+
mPt.flush();
|
103
|
+
}
|
46
104
|
|
47
|
-
|
48
|
-
|
105
|
+
if (id == options.currentId) {
|
106
|
+
clientPerformance = getClientPerformance();
|
49
107
|
|
50
|
-
|
51
|
-
|
108
|
+
if (clientPerformance !== null) {
|
109
|
+
// ie is buggy strip out functions
|
110
|
+
var copy = {
|
111
|
+
navigation: {},
|
112
|
+
timing: clientPerformance.timing.toJSON()
|
113
|
+
};
|
52
114
|
|
53
|
-
|
54
|
-
|
55
|
-
|
115
|
+
if (clientPerformance.navigation) {
|
116
|
+
copy.navigation.redirectCount =
|
117
|
+
clientPerformance.navigation.redirectCount;
|
118
|
+
}
|
56
119
|
|
57
|
-
|
58
|
-
$('body').append(cached);
|
59
|
-
success();
|
60
|
-
}
|
61
|
-
else {
|
62
|
-
$.get(options.path + 'includes.tmpl?v=' + options.version, function (data) {
|
63
|
-
if (data) {
|
64
|
-
save(key, data);
|
65
|
-
$('body').append(data);
|
66
|
-
success();
|
67
|
-
}
|
68
|
-
}, "text");
|
120
|
+
clientPerformance = copy;
|
69
121
|
}
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
122
|
+
} else if (
|
123
|
+
ajaxStartTime !== null &&
|
124
|
+
clientProbes &&
|
125
|
+
clientProbes.length > 0
|
126
|
+
) {
|
127
|
+
clientPerformance = {
|
128
|
+
timing: {
|
129
|
+
navigationStart: ajaxStartTime.getTime()
|
130
|
+
}
|
131
|
+
};
|
132
|
+
ajaxStartTime = null;
|
133
|
+
}
|
134
|
+
|
135
|
+
if (fetchedIds.indexOf(id) < 0 && fetchingIds.indexOf(id) < 0) {
|
136
|
+
idx = fetchingIds.push(id) - 1;
|
137
|
+
|
138
|
+
(function() {
|
139
|
+
var request = new XMLHttpRequest();
|
140
|
+
var url = options.path + "results";
|
141
|
+
var params = {
|
142
|
+
id: id,
|
143
|
+
clientPerformance: clientPerformance,
|
144
|
+
clientProbes: clientProbes,
|
145
|
+
popup: 1
|
146
|
+
};
|
147
|
+
var queryParam = toQueryString(params);
|
148
|
+
request.open("POST", url, true);
|
81
149
|
|
82
|
-
|
83
|
-
|
150
|
+
request.onload = function() {
|
151
|
+
if (request.status >= 200 && request.status < 400) {
|
152
|
+
var json = JSON.parse(request.responseText);
|
153
|
+
fetchedIds.push(id);
|
84
154
|
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
clientProbes[j].d = clientProbes[j].d.getTime();
|
89
|
-
}
|
90
|
-
mPt.flush();
|
155
|
+
if (json != "hidden" && MiniProfiler.templates) {
|
156
|
+
buttonShow(json);
|
157
|
+
}
|
91
158
|
}
|
92
159
|
|
93
|
-
|
94
|
-
|
95
|
-
clientPerformance = getClientPerformance();
|
96
|
-
|
97
|
-
if (clientPerformance !== null) {
|
98
|
-
// ie is buggy strip out functions
|
99
|
-
var copy = { navigation: {}, timing: {} };
|
100
|
-
|
101
|
-
var timing = $.extend({}, clientPerformance.timing);
|
102
|
-
|
103
|
-
for (p in timing) {
|
104
|
-
if (timing.hasOwnProperty(p) && !$.isFunction(timing[p])) {
|
105
|
-
copy.timing[p] = timing[p];
|
106
|
-
}
|
107
|
-
}
|
108
|
-
if (clientPerformance.navigation) {
|
109
|
-
copy.navigation.redirectCount = clientPerformance.navigation.redirectCount;
|
110
|
-
}
|
111
|
-
clientPerformance = copy;
|
112
|
-
}
|
113
|
-
} else if (ajaxStartTime !== null && clientProbes && clientProbes.length > 0) {
|
114
|
-
clientPerformance = { timing: { navigationStart: ajaxStartTime.getTime() } };
|
115
|
-
ajaxStartTime = null;
|
116
|
-
}
|
160
|
+
fetchingIds.splice(idx, 1);
|
161
|
+
};
|
117
162
|
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
163
|
+
request.setRequestHeader("Accept", "application/json");
|
164
|
+
request.setRequestHeader("X-Requested-With", "XMLHttpRequest");
|
165
|
+
request.setRequestHeader(
|
166
|
+
"Content-Type",
|
167
|
+
"application/x-www-form-urlencoded"
|
168
|
+
);
|
169
|
+
request.send(queryParam);
|
170
|
+
})();
|
171
|
+
}
|
172
|
+
}
|
173
|
+
};
|
174
|
+
|
175
|
+
var toQueryString = function toQueryString(data, parentKey) {
|
176
|
+
var result = [];
|
177
|
+
for (var key in data) {
|
178
|
+
var val = data[key];
|
179
|
+
var newKey = !parentKey ? key : parentKey + "[" + key + "]";
|
180
|
+
if (
|
181
|
+
typeof val === "object" &&
|
182
|
+
!Array.isArray(val) &&
|
183
|
+
val !== null &&
|
184
|
+
val !== undefined
|
185
|
+
) {
|
186
|
+
result[result.length] = toQueryString(val, newKey);
|
187
|
+
} else {
|
188
|
+
if (Array.isArray(val)) {
|
189
|
+
val.forEach(function(v) {
|
190
|
+
result[result.length] =
|
191
|
+
encodeURIComponent(newKey + "[]") + "=" + encodeURIComponent(v);
|
192
|
+
});
|
193
|
+
} else if (val === null || val === undefined) {
|
194
|
+
result[result.length] = encodeURIComponent(newKey) + "=";
|
195
|
+
} else {
|
196
|
+
result[result.length] =
|
197
|
+
encodeURIComponent(newKey) +
|
198
|
+
"=" +
|
199
|
+
encodeURIComponent(val.toString());
|
138
200
|
}
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
201
|
+
}
|
202
|
+
}
|
203
|
+
return result
|
204
|
+
.filter(function(element) {
|
205
|
+
return element && element.length > 0;
|
206
|
+
})
|
207
|
+
.join("&");
|
208
|
+
};
|
209
|
+
|
210
|
+
var renderTemplate = function renderTemplate(json) {
|
211
|
+
var textDom = MiniProfiler.templates.profilerTemplate(json);
|
212
|
+
var tempElement = document.createElement("DIV");
|
213
|
+
tempElement.innerHTML = textDom;
|
214
|
+
return tempElement.children[0];
|
215
|
+
};
|
216
|
+
|
217
|
+
var buttonShow = function buttonShow(json) {
|
218
|
+
var result = renderTemplate(json);
|
219
|
+
totalTime += parseFloat(json.duration_milliseconds, 10);
|
220
|
+
totalSqlCount += parseInt(json.sql_count);
|
221
|
+
reqs++;
|
222
|
+
|
223
|
+
if (!controls && reqs > 1 && options.collapseResults && !expandedResults) {
|
224
|
+
if (!totalsControl) {
|
225
|
+
toArray(container.querySelectorAll(".profiler-result")).forEach(
|
226
|
+
function(el) {
|
227
|
+
return (el.style.display = "none");
|
166
228
|
}
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
result.appendTo(container);
|
182
|
-
|
183
|
-
var button = result.find('.profiler-button'),
|
184
|
-
popup = result.find('.profiler-popup');
|
185
|
-
|
186
|
-
// button will appear in corner with the total profiling duration - click to show details
|
187
|
-
button.on('click', function () { buttonClick(button, popup); });
|
188
|
-
|
189
|
-
// small duration steps and the column with aggregate durations are hidden by default; allow toggling
|
190
|
-
toggleHidden(popup);
|
191
|
-
|
192
|
-
// lightbox in the queries
|
193
|
-
popup.find('.profiler-queries-show').on('click', function () { queriesShow($(this), result); });
|
194
|
-
|
195
|
-
// limit count
|
196
|
-
if (container.find('.profiler-result').length > options.maxTracesToShow)
|
197
|
-
container.find('.profiler-result').first().remove();
|
198
|
-
button.show();
|
199
|
-
};
|
200
|
-
|
201
|
-
var toggleHidden = function (popup) {
|
202
|
-
var trivial = popup.find('.profiler-toggle-trivial');
|
203
|
-
var childrenTime = popup.find('.profiler-toggle-duration-with-children');
|
204
|
-
var trivialGaps = popup.parent().find('.profiler-toggle-trivial-gaps');
|
205
|
-
|
206
|
-
var toggleIt = function (node) {
|
207
|
-
var link = $(node),
|
208
|
-
klass = "profiler-" + link.attr('class').substr('profiler-toggle-'.length),
|
209
|
-
isHidden = link.text().indexOf('show') > -1;
|
210
|
-
|
211
|
-
popup.parent().find('.' + klass).toggle(isHidden);
|
212
|
-
link.text(link.text().replace(isHidden ? 'show' : 'hide', isHidden ? 'hide' : 'show'));
|
213
|
-
|
214
|
-
popupPreventHorizontalScroll(popup);
|
215
|
-
};
|
216
|
-
|
217
|
-
childrenTime.add(trivial).add(trivialGaps).on('click', function () {
|
218
|
-
toggleIt(this);
|
229
|
+
);
|
230
|
+
totalsControl = document.createElement("div");
|
231
|
+
totalsControl.setAttribute("class", "profiler-result");
|
232
|
+
totalsControl.innerHTML =
|
233
|
+
"<div class='profiler-button profiler-totals'></div>";
|
234
|
+
container.appendChild(totalsControl);
|
235
|
+
totalsControl.addEventListener("click", function() {
|
236
|
+
toArray(
|
237
|
+
totalsControl.parentNode.querySelectorAll(".profiler-result")
|
238
|
+
).forEach(function(el) {
|
239
|
+
return (el.style.display = "block");
|
240
|
+
});
|
241
|
+
totalsControl.style.display = "none";
|
242
|
+
expandedResults = true;
|
219
243
|
});
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
var
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
244
|
+
toArray(totalsControl.querySelectorAll(".profiler-button")).forEach(
|
245
|
+
function(el) {
|
246
|
+
return (el.style.display = "block");
|
247
|
+
}
|
248
|
+
);
|
249
|
+
}
|
250
|
+
|
251
|
+
var reqsHtml =
|
252
|
+
reqs > 1 ? "<span class='profiler-reqs'>" + reqs + "</span>" : "";
|
253
|
+
var sqlHtml =
|
254
|
+
options.showTotalSqlCount && totalSqlCount > 0
|
255
|
+
? " / <span class='profiler-number'>" +
|
256
|
+
totalSqlCount +
|
257
|
+
"</span> <span class='profiler-unit'>sql</span>"
|
258
|
+
: "";
|
259
|
+
totalsControl.querySelector(".profiler-button").innerHTML =
|
260
|
+
"<span class='profiler-number'>" +
|
261
|
+
totalTime.toFixed(1) +
|
262
|
+
"</span> <span class='profiler-unit'>ms</span>" +
|
263
|
+
sqlHtml +
|
264
|
+
reqsHtml;
|
265
|
+
result.style.display = "none";
|
266
|
+
}
|
267
|
+
|
268
|
+
if (controls) result.insertBefore(controls);
|
269
|
+
else container.appendChild(result);
|
270
|
+
var button = result.querySelector(".profiler-button"),
|
271
|
+
popup = result.querySelector(".profiler-popup"); // button will appear in corner with the total profiling duration - click to show details
|
272
|
+
|
273
|
+
button.addEventListener("click", function() {
|
274
|
+
buttonClick(button, popup);
|
275
|
+
}); // small duration steps and the column with aggregate durations are hidden by default; allow toggling
|
276
|
+
|
277
|
+
toggleHidden(popup); // lightbox in the queries
|
278
|
+
|
279
|
+
toArray(popup.querySelectorAll(".profiler-queries-show")).forEach(function(
|
280
|
+
el
|
281
|
+
) {
|
282
|
+
el.addEventListener("click", function() {
|
283
|
+
queriesShow(this, result);
|
284
|
+
});
|
285
|
+
}); // limit count
|
286
|
+
|
287
|
+
if (
|
288
|
+
container.querySelectorAll(".profiler-result").length >
|
289
|
+
options.maxTracesToShow
|
290
|
+
) {
|
291
|
+
var elem = container.querySelector(".profiler-result");
|
292
|
+
|
293
|
+
if (elem) {
|
294
|
+
elem.parentElement.removeChild(elem);
|
295
|
+
}
|
296
|
+
}
|
297
|
+
|
298
|
+
button.style.display = "block";
|
299
|
+
};
|
300
|
+
|
301
|
+
var toggleHidden = function toggleHidden(popup) {
|
302
|
+
var trivial = popup.querySelector(".profiler-toggle-trivial");
|
303
|
+
var childrenTime = popup.querySelector(
|
304
|
+
".profiler-toggle-duration-with-children"
|
305
|
+
);
|
306
|
+
var trivialGaps = popup.parentNode.querySelector(
|
307
|
+
".profiler-toggle-trivial-gaps"
|
308
|
+
);
|
309
|
+
|
310
|
+
var toggleIt = function toggleIt(node) {
|
311
|
+
var link = node,
|
312
|
+
klass =
|
313
|
+
"profiler-" +
|
314
|
+
link.getAttribute("class").substr("profiler-toggle-".length),
|
315
|
+
isHidden = link.textContent.indexOf("show") > -1;
|
316
|
+
var elements = toArray(popup.parentNode.querySelectorAll("." + klass));
|
317
|
+
|
318
|
+
if (isHidden) {
|
319
|
+
elements.forEach(function(el) {
|
320
|
+
return (el.style.display = "table-row");
|
321
|
+
});
|
322
|
+
} else {
|
323
|
+
elements.forEach(function(el) {
|
324
|
+
return (el.style.display = "none");
|
325
|
+
});
|
326
|
+
}
|
327
|
+
|
328
|
+
var text = link.textContent;
|
329
|
+
link.textContent = text.replace(
|
330
|
+
isHidden ? "show" : "hide",
|
331
|
+
isHidden ? "hide" : "show"
|
332
|
+
);
|
333
|
+
popupPreventHorizontalScroll(popup);
|
304
334
|
};
|
305
335
|
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
336
|
+
[childrenTime, trivial, trivialGaps].forEach(function(el) {
|
337
|
+
if (el) {
|
338
|
+
el.addEventListener("click", function() {
|
339
|
+
toggleIt(this);
|
340
|
+
});
|
341
|
+
}
|
342
|
+
}); // if option is set or all our timings are trivial, go ahead and show them
|
343
|
+
|
344
|
+
if (
|
345
|
+
trivial &&
|
346
|
+
(options.showTrivial || trivial.getAttribute("show-on-load"))
|
347
|
+
) {
|
348
|
+
toggleIt(trivial);
|
349
|
+
} // if option is set, go ahead and show time with children
|
350
|
+
|
351
|
+
if (childrenTime && options.showChildrenTime) {
|
352
|
+
toggleIt(childrenTime);
|
353
|
+
}
|
354
|
+
};
|
355
|
+
|
356
|
+
var toArray = function toArray(list) {
|
357
|
+
var arr = [];
|
358
|
+
|
359
|
+
if (!list) {
|
360
|
+
return arr;
|
361
|
+
}
|
362
|
+
|
363
|
+
for (var i = 0; i < list.length; i++) {
|
364
|
+
arr.push(list[i]);
|
365
|
+
}
|
366
|
+
|
367
|
+
return arr;
|
368
|
+
};
|
369
|
+
|
370
|
+
var buttonClick = function buttonClick(button, popup) {
|
371
|
+
// we're toggling this button/popup
|
372
|
+
if (popup.offsetWidth > 0 || popup.offsetHeight > 0) {
|
373
|
+
// if visible
|
374
|
+
popupHide(button, popup);
|
375
|
+
} else {
|
376
|
+
var visiblePopups = toArray(
|
377
|
+
container.querySelectorAll(".profiler-popup")
|
378
|
+
).filter(function(el) {
|
379
|
+
return el.offsetWidth > 0 || el.offsetHeight > 0;
|
380
|
+
}); // theirButtons = visiblePopups.siblings(".profiler-button");
|
381
|
+
|
382
|
+
var theirButtons = [];
|
383
|
+
visiblePopups.forEach(function(el) {
|
384
|
+
theirButtons.push(el.parentNode.querySelector(".profiler-button"));
|
385
|
+
}); // hide any other popups
|
386
|
+
|
387
|
+
popupHide(theirButtons, visiblePopups); // before showing the one we clicked
|
388
|
+
|
389
|
+
popupShow(button, popup);
|
390
|
+
}
|
391
|
+
};
|
392
|
+
|
393
|
+
var popupShow = function popupShow(button, popup) {
|
394
|
+
button.classList.add("profiler-button-active");
|
395
|
+
popupSetDimensions(button, popup);
|
396
|
+
popup.style.display = "block";
|
397
|
+
popupPreventHorizontalScroll(popup);
|
398
|
+
};
|
399
|
+
|
400
|
+
var popupSetDimensions = function popupSetDimensions(button, popup) {
|
401
|
+
var px = button.offsetTop - 1,
|
402
|
+
// position next to the button we clicked
|
403
|
+
windowHeight = window.innerHeight,
|
404
|
+
maxHeight = windowHeight - px - 40; // make sure the popup doesn't extend below the fold
|
405
|
+
|
406
|
+
popup.style[options.renderVerticalPosition] = "".concat(px, "px");
|
407
|
+
popup.style.maxHeight = "".concat(maxHeight, "px");
|
408
|
+
popup.style[options.renderHorizontalPosition] = "".concat(
|
409
|
+
button.offsetWidth - 3,
|
410
|
+
"px"
|
411
|
+
); // move left or right, based on config
|
412
|
+
};
|
413
|
+
|
414
|
+
var popupPreventHorizontalScroll = function popupPreventHorizontalScroll(
|
415
|
+
popup
|
416
|
+
) {
|
417
|
+
var childrenHeight = 0;
|
418
|
+
toArray(popup.children).forEach(function(el) {
|
419
|
+
childrenHeight += el.offsetHeight;
|
420
|
+
});
|
421
|
+
popup.style.paddingRight = "".concat(
|
422
|
+
childrenHeight > popup.offsetHeight ? 40 : 10,
|
423
|
+
"px"
|
424
|
+
);
|
425
|
+
};
|
426
|
+
|
427
|
+
var popupHide = function popupHide(button, popup) {
|
428
|
+
if (button) {
|
429
|
+
if (Array.isArray(button)) {
|
430
|
+
button.forEach(function(el) {
|
431
|
+
return el.classList.remove("profiler-button-active");
|
432
|
+
});
|
433
|
+
} else {
|
434
|
+
button.classList.remove("profiler-button-active");
|
435
|
+
}
|
436
|
+
}
|
437
|
+
|
438
|
+
if (popup) {
|
439
|
+
if (Array.isArray(popup)) {
|
440
|
+
popup.forEach(function(el) {
|
441
|
+
return (el.style.display = "none");
|
330
442
|
});
|
443
|
+
} else {
|
444
|
+
popup.style.display = "none";
|
445
|
+
}
|
446
|
+
}
|
447
|
+
};
|
448
|
+
|
449
|
+
var queriesShow = function queriesShow(link, result) {
|
450
|
+
result = result;
|
451
|
+
var px = 30,
|
452
|
+
win = window,
|
453
|
+
width = win.innerWidth - 2 * px,
|
454
|
+
height = win.innerHeight - 2 * px,
|
455
|
+
queries = result.querySelector(".profiler-queries"); // opaque background
|
456
|
+
|
457
|
+
var background = document.createElement("div");
|
458
|
+
background.classList.add("profiler-queries-bg");
|
459
|
+
document.body.appendChild(background);
|
460
|
+
background.style.height = "".concat(window.innerHeight, "px");
|
461
|
+
background.style.display = "block"; // center the queries and ensure long content is scrolled
|
462
|
+
|
463
|
+
queries.style[options.renderVerticalPosition] = "".concat(px, "px");
|
464
|
+
queries.style.maxHeight = "".concat(height, "px");
|
465
|
+
queries.style.width = "".concat(width, "px");
|
466
|
+
queries.style[options.renderHorizontalPosition] = "".concat(px, "px");
|
467
|
+
queries.querySelector("table").style.width = "".concat(width, "px"); // have to show everything before we can get a position for the first query
|
468
|
+
|
469
|
+
queries.style.display = "block";
|
470
|
+
queriesScrollIntoView(link, queries, queries); // syntax highlighting
|
471
|
+
|
472
|
+
prettyPrint();
|
473
|
+
};
|
474
|
+
|
475
|
+
var queriesScrollIntoView = function queriesScrollIntoView(
|
476
|
+
link,
|
477
|
+
queries,
|
478
|
+
whatToScroll
|
479
|
+
) {
|
480
|
+
var id = elementClosest(link, "tr").getAttribute("data-timing-id"),
|
481
|
+
cells = toArray(
|
482
|
+
queries.querySelectorAll('tr[data-timing-id="' + id + '"]')
|
483
|
+
); // ensure they're in view
|
484
|
+
|
485
|
+
whatToScroll.scrollTop =
|
486
|
+
(whatToScroll.scrollTop || 0) + cells[0].offsetTop - 100; // highlight and then fade back to original bg color; do it ourselves to prevent any conflicts w/ jquery.UI or other implementations of Resig's color plugin
|
487
|
+
|
488
|
+
cells.forEach(function(el) {
|
489
|
+
el.classList.add("higlight-animate");
|
490
|
+
});
|
491
|
+
setTimeout(function() {
|
492
|
+
cells.forEach(function(el) {
|
493
|
+
return el.classList.remove("higlight-animate");
|
494
|
+
});
|
495
|
+
}, 3000);
|
496
|
+
};
|
497
|
+
|
498
|
+
var onTurboBeforeVisit = function onTurboBeforeVisit(e) {
|
499
|
+
if(!e.defaultPrevented) {
|
500
|
+
window.MiniProfilerContainer = document.querySelector('body > .profiler-results')
|
501
|
+
window.MiniProfiler.pageTransition()
|
502
|
+
}
|
503
|
+
}
|
504
|
+
|
505
|
+
var onTurboLoad = function onTurboLoad(e) {
|
506
|
+
if(window.MiniProfilerContainer) {
|
507
|
+
document.body.appendChild(window.MiniProfilerContainer)
|
508
|
+
}
|
509
|
+
}
|
510
|
+
|
511
|
+
var onClickEvents = function onClickEvents(e) {
|
512
|
+
// this happens on every keystroke, and :visible is crazy expensive in IE <9
|
513
|
+
// and in this case, the display:none check is sufficient.
|
514
|
+
var popup = toArray(document.querySelectorAll(".profiler-popup")).filter(
|
515
|
+
function(el) {
|
516
|
+
return el.style.display === "block";
|
517
|
+
}
|
518
|
+
);
|
519
|
+
|
520
|
+
if (!popup.length) {
|
521
|
+
return;
|
522
|
+
}
|
523
|
+
|
524
|
+
popup = popup[0];
|
525
|
+
var button = popup.parentNode.querySelector(".profiler-button"),
|
526
|
+
queries = elementClosest(popup, ".profiler-result").querySelector(
|
527
|
+
".profiler-queries"
|
528
|
+
),
|
529
|
+
bg = document.querySelector(".profiler-queries-bg"),
|
530
|
+
isEscPress = e.type == "keyup" && e.which == 27,
|
531
|
+
hidePopup = false,
|
532
|
+
hideQueries = false;
|
533
|
+
|
534
|
+
if (bg && bg.style.display === "block") {
|
535
|
+
hideQueries =
|
536
|
+
isEscPress ||
|
537
|
+
(e.type == "click" &&
|
538
|
+
!(queries !== e.target && queries.contains(e.target)) &&
|
539
|
+
!(popup !== e.target && popup.contains(e.target)));
|
540
|
+
} else if (popup.style.display === "block") {
|
541
|
+
hidePopup =
|
542
|
+
isEscPress ||
|
543
|
+
(e.type == "click" &&
|
544
|
+
!(popup !== e.target && popup.contains(e.target)) &&
|
545
|
+
!(button !== e.target && button.contains(e.target)) &&
|
546
|
+
button != e.target);
|
547
|
+
}
|
548
|
+
|
549
|
+
if (hideQueries) {
|
550
|
+
bg.parentElement.removeChild(bg);
|
551
|
+
queries.style.display = "none";
|
552
|
+
}
|
553
|
+
|
554
|
+
if (hidePopup) {
|
555
|
+
popupHide(button, popup);
|
556
|
+
}
|
557
|
+
};
|
558
|
+
|
559
|
+
var keydownEvent = function keydownEvent() {
|
560
|
+
var results = document.querySelector(".profiler-results");
|
561
|
+
|
562
|
+
if (results.style.display === "none") {
|
563
|
+
results.style.display = "block";
|
564
|
+
} else {
|
565
|
+
results.style.display = "none";
|
566
|
+
}
|
567
|
+
|
568
|
+
sessionStorage["rack-mini-profiler-start-hidden"] =
|
569
|
+
results.style.display === "none";
|
570
|
+
};
|
571
|
+
|
572
|
+
var toggleShortcutEvent = function toggleShortcutEvent(e) {
|
573
|
+
// simplified version of https://github.com/jeresig/jquery.hotkeys/blob/master/jquery.hotkeys.js
|
574
|
+
var shortcut = options.toggleShortcut.toLowerCase();
|
575
|
+
var modifier = "";
|
576
|
+
["alt", "ctrl", "shift"].forEach(function(k) {
|
577
|
+
if (e[k + "Key"]) {
|
578
|
+
modifier += "".concat(k, "+");
|
579
|
+
}
|
580
|
+
});
|
581
|
+
var specialKeys = {
|
582
|
+
8: "backspace",
|
583
|
+
9: "tab",
|
584
|
+
10: "return",
|
585
|
+
13: "return",
|
586
|
+
16: "shift",
|
587
|
+
17: "ctrl",
|
588
|
+
18: "alt",
|
589
|
+
27: "esc",
|
590
|
+
32: "space",
|
591
|
+
59: ";",
|
592
|
+
61: "=",
|
593
|
+
96: "0",
|
594
|
+
97: "1",
|
595
|
+
98: "2",
|
596
|
+
99: "3",
|
597
|
+
100: "4",
|
598
|
+
101: "5",
|
599
|
+
102: "6",
|
600
|
+
103: "7",
|
601
|
+
104: "8",
|
602
|
+
105: "9",
|
603
|
+
106: "*",
|
604
|
+
107: "+",
|
605
|
+
109: "-",
|
606
|
+
110: ".",
|
607
|
+
173: "-",
|
608
|
+
186: ";",
|
609
|
+
187: "="
|
331
610
|
};
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
// Look for #fff
|
353
|
-
if (result = /#([a-fA-F0-9])([a-fA-F0-9])([a-fA-F0-9])/.exec(color)) return [parseInt(result[1] + result[1], 16), parseInt(result[2] + result[2], 16), parseInt(result[3] + result[3], 16)];
|
354
|
-
|
355
|
-
// Look for rgba(0, 0, 0, 0) == transparent in Safari 3
|
356
|
-
if (result = /rgba\(0, 0, 0, 0\)/.exec(color)) return [0,0,0,0];
|
357
|
-
|
358
|
-
return null;
|
611
|
+
var shiftNums = {
|
612
|
+
"`": "~",
|
613
|
+
"1": "!",
|
614
|
+
"2": "@",
|
615
|
+
"3": "#",
|
616
|
+
"4": "$",
|
617
|
+
"5": "%",
|
618
|
+
"6": "^",
|
619
|
+
"7": "&",
|
620
|
+
"8": "*",
|
621
|
+
"9": "(",
|
622
|
+
"0": ")",
|
623
|
+
"-": "_",
|
624
|
+
"=": "+",
|
625
|
+
";": ": ",
|
626
|
+
"'": '"',
|
627
|
+
",": "<",
|
628
|
+
".": ">",
|
629
|
+
"/": "?",
|
630
|
+
"\\": "|"
|
359
631
|
};
|
360
|
-
|
361
|
-
var
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
632
|
+
var character = String.fromCharCode(e.which).toLowerCase();
|
633
|
+
var special = specialKeys[e.which];
|
634
|
+
var keys = [];
|
635
|
+
|
636
|
+
if (special) {
|
637
|
+
keys.push(special);
|
638
|
+
} else {
|
639
|
+
keys.push(character);
|
640
|
+
keys.push(shiftNums[character]);
|
641
|
+
}
|
642
|
+
|
643
|
+
for (var i = 0; i < keys.length; i++) {
|
644
|
+
if (modifier + keys[i] === shortcut) {
|
645
|
+
keydownEvent();
|
646
|
+
break;
|
647
|
+
}
|
648
|
+
}
|
649
|
+
};
|
650
|
+
|
651
|
+
var turbolinksSkipResultsFetch = function turbolinksSkipResultsFetch(event) {
|
652
|
+
event.data.xhr.__miniProfilerSkipResultsFetch = true;
|
653
|
+
};
|
654
|
+
|
655
|
+
var bindDocumentEvents = function bindDocumentEvents() {
|
656
|
+
document.addEventListener("click", onClickEvents);
|
657
|
+
document.addEventListener("keyup", onClickEvents);
|
658
|
+
document.addEventListener("keyup", toggleShortcutEvent);
|
659
|
+
|
660
|
+
if (typeof Turbolinks !== "undefined" && Turbolinks.supported) {
|
661
|
+
document.addEventListener("page:change", unbindDocumentEvents);
|
662
|
+
document.addEventListener("turbolinks:load", unbindDocumentEvents);
|
663
|
+
document.addEventListener(
|
664
|
+
"turbolinks:request-start",
|
665
|
+
turbolinksSkipResultsFetch
|
666
|
+
);
|
667
|
+
}
|
668
|
+
|
669
|
+
if (options.hotwireTurboDriveSupport) {
|
670
|
+
document.addEventListener("turbo:before-visit", onTurboBeforeVisit)
|
671
|
+
document.addEventListener("turbo:load", onTurboLoad)
|
672
|
+
}
|
673
|
+
};
|
674
|
+
|
675
|
+
var unbindDocumentEvents = function unbindDocumentEvents() {
|
676
|
+
document.removeEventListener("click", onClickEvents);
|
677
|
+
document.removeEventListener("keyup", onClickEvents);
|
678
|
+
document.removeEventListener("keyup", toggleShortcutEvent);
|
679
|
+
document.removeEventListener("page:change", unbindDocumentEvents);
|
680
|
+
document.removeEventListener("turbolinks:load", unbindDocumentEvents);
|
681
|
+
document.removeEventListener(
|
682
|
+
"turbolinks:request-start",
|
683
|
+
turbolinksSkipResultsFetch
|
684
|
+
);
|
685
|
+
document.removeEventListener("turbo:before-visit", onTurboBeforeVisit);
|
686
|
+
document.removeEventListener("turbo:load", onTurboLoad);
|
687
|
+
};
|
688
|
+
|
689
|
+
var initFullView = function initFullView() {
|
690
|
+
// profiler will be defined in the full page's head
|
691
|
+
container[0].appendChild(renderTemplate(profiler));
|
692
|
+
var popup = document.querySelector(".profiler-popup");
|
693
|
+
toggleHidden(popup);
|
694
|
+
prettyPrint(); // since queries are already shown, just highlight and scroll when clicking a "1 sql" link
|
695
|
+
|
696
|
+
toArray(popup.querySelectorAll(".profiler-queries-show")).forEach(function(
|
697
|
+
el
|
698
|
+
) {
|
699
|
+
el.addEventListener("click", function() {
|
700
|
+
queriesScrollIntoView(
|
701
|
+
this,
|
702
|
+
document.querySelector(".profiler-queries"),
|
703
|
+
document.body
|
704
|
+
);
|
705
|
+
});
|
706
|
+
});
|
707
|
+
};
|
708
|
+
|
709
|
+
var initSnapshots = function initSnapshots(dataElement) {
|
710
|
+
var data = JSON.parse(dataElement.textContent);
|
711
|
+
var temp = document.createElement("DIV");
|
712
|
+
if (data.page === "overview") {
|
713
|
+
temp.innerHTML = MiniProfiler.templates.snapshotsGroupsList(data);
|
714
|
+
} else if (data.group_name) {
|
715
|
+
var allCustomFieldsNames = [];
|
716
|
+
data.list.forEach(function(snapshot) {
|
717
|
+
Object.keys(snapshot.custom_fields).forEach(function(k) {
|
718
|
+
if (
|
719
|
+
allCustomFieldsNames.indexOf(k) === -1 &&
|
720
|
+
options.hiddenCustomFields.indexOf(k.toLowerCase()) === -1
|
721
|
+
) {
|
722
|
+
allCustomFieldsNames.push(k);
|
723
|
+
}
|
724
|
+
});
|
725
|
+
});
|
726
|
+
allCustomFieldsNames.sort();
|
727
|
+
temp.innerHTML = MiniProfiler.templates.snapshotsList({
|
728
|
+
data: data,
|
729
|
+
allCustomFieldsNames: allCustomFieldsNames
|
730
|
+
});
|
731
|
+
}
|
732
|
+
Array.from(temp.children).forEach(function(child) {
|
733
|
+
document.body.appendChild(child);
|
734
|
+
});
|
735
|
+
};
|
736
|
+
|
737
|
+
var initControls = function initControls(container) {
|
738
|
+
if (options.showControls) {
|
739
|
+
var _controls = document.createElement("div");
|
740
|
+
|
741
|
+
_controls.classList.add("profiler-controls");
|
742
|
+
|
743
|
+
_controls.innerHTML =
|
744
|
+
'<span class="profiler-min-max">m</span><span class="profiler-clear">c</span>';
|
745
|
+
container.appendChild(_controls);
|
746
|
+
document
|
747
|
+
.querySelector(".profiler-controls .profiler-min-max")
|
748
|
+
.addEventListener("click", function() {
|
749
|
+
return toggleClass(container, "profiler-min");
|
750
|
+
});
|
751
|
+
container.addEventListener("mouseenter", function() {
|
752
|
+
if (this.classList.contains("profiler-min")) {
|
753
|
+
this.querySelector(".profiler-min-max").style.display = "block";
|
754
|
+
}
|
755
|
+
});
|
756
|
+
container.addEventListener("mouseleave", function() {
|
757
|
+
if (this.classList.contains("profiler-min")) {
|
758
|
+
this.querySelector(".profiler-min-max").style.display = "none";
|
759
|
+
}
|
760
|
+
});
|
761
|
+
document
|
762
|
+
.querySelector(".profiler-controls .profiler-clear")
|
763
|
+
.addEventListener("click", function() {
|
764
|
+
toArray(container.querySelectorAll(".profiler-result")).forEach(
|
765
|
+
function(el) {
|
766
|
+
return el.parentElement.removeChild(el);
|
370
767
|
}
|
768
|
+
);
|
769
|
+
});
|
770
|
+
} else {
|
771
|
+
container.classList.add("profiler-no-controls");
|
772
|
+
}
|
773
|
+
};
|
774
|
+
|
775
|
+
var toggleClass = function toggleClass(el, className) {
|
776
|
+
if (el.classList) {
|
777
|
+
el.classList.toggle(className);
|
778
|
+
} else {
|
779
|
+
var classes = el.className.split(" ");
|
780
|
+
var existingIndex = classes.indexOf(className);
|
781
|
+
if (existingIndex >= 0) classes.splice(existingIndex, 1);
|
782
|
+
else classes.push(className);
|
783
|
+
el.className = classes.join(" ");
|
784
|
+
}
|
785
|
+
};
|
786
|
+
|
787
|
+
var initPopupView = function initPopupView() {
|
788
|
+
if (options.authorized) {
|
789
|
+
// all fetched profilings will go in here
|
790
|
+
container = document.createElement("div");
|
791
|
+
container.className = "profiler-results";
|
792
|
+
document.querySelector(options.htmlContainer).appendChild(container); // MiniProfiler.RenderIncludes() sets which corner to render in - default is upper left
|
793
|
+
|
794
|
+
container.classList.add("profiler-" + options.renderHorizontalPosition);
|
795
|
+
container.classList.add("profiler-" + options.renderVerticalPosition); //initialize the controls
|
796
|
+
|
797
|
+
initControls(container);
|
798
|
+
fetchResults(options.ids);
|
799
|
+
|
800
|
+
if (options.startHidden) container.style.display = "none";
|
801
|
+
} else {
|
802
|
+
fetchResults(options.ids);
|
803
|
+
}
|
804
|
+
|
805
|
+
if (!window.MiniProfiler || !window.MiniProfiler.patchesApplied) {
|
806
|
+
var send = XMLHttpRequest.prototype.send;
|
807
|
+
|
808
|
+
XMLHttpRequest.prototype.send = function(data) {
|
809
|
+
ajaxStartTime = new Date();
|
810
|
+
this.addEventListener("load", function() {
|
811
|
+
// responseURL isn't available in IE11
|
812
|
+
if (
|
813
|
+
this.responseURL &&
|
814
|
+
this.responseURL.indexOf(window.location.origin) !== 0
|
815
|
+
) {
|
816
|
+
return;
|
817
|
+
}
|
818
|
+
if (this.__miniProfilerSkipResultsFetch) {
|
819
|
+
return;
|
820
|
+
}
|
821
|
+
// getAllResponseHeaders isn't available in Edge.
|
822
|
+
var allHeaders = this.getAllResponseHeaders
|
823
|
+
? this.getAllResponseHeaders()
|
824
|
+
: null;
|
825
|
+
if (
|
826
|
+
allHeaders &&
|
827
|
+
allHeaders.toLowerCase().indexOf("x-miniprofiler-ids") === -1
|
828
|
+
) {
|
829
|
+
return;
|
830
|
+
}
|
831
|
+
// should be a string of comma-separated ids
|
832
|
+
var stringIds = this.getResponseHeader("X-MiniProfiler-Ids");
|
371
833
|
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
834
|
+
if (stringIds) {
|
835
|
+
var ids = stringIds.split(",");
|
836
|
+
fetchResults(ids);
|
837
|
+
}
|
838
|
+
});
|
839
|
+
send.call(this, data);
|
840
|
+
}; // fetch results after ASP Ajax calls
|
841
|
+
|
842
|
+
if (
|
843
|
+
typeof Sys != "undefined" &&
|
844
|
+
typeof Sys.WebForms != "undefined" &&
|
845
|
+
typeof Sys.WebForms.PageRequestManager != "undefined"
|
846
|
+
) {
|
847
|
+
// Get the instance of PageRequestManager.
|
848
|
+
var PageRequestManager = Sys.WebForms.PageRequestManager.getInstance();
|
849
|
+
PageRequestManager.add_endRequest(function(sender, args) {
|
850
|
+
if (args) {
|
851
|
+
var response = args.get_response();
|
852
|
+
|
853
|
+
if (
|
854
|
+
response.get_responseAvailable() &&
|
855
|
+
response._xmlHttpRequest !== null
|
856
|
+
) {
|
857
|
+
var stringIds = args
|
858
|
+
.get_response()
|
859
|
+
.getResponseHeader("X-MiniProfiler-Ids");
|
378
860
|
|
379
|
-
|
380
|
-
|
861
|
+
if (stringIds) {
|
862
|
+
var ids = stringIds.split(",");
|
863
|
+
fetchResults(ids);
|
864
|
+
}
|
381
865
|
}
|
382
|
-
|
383
|
-
|
866
|
+
}
|
867
|
+
});
|
868
|
+
} // more Asp.Net callbacks
|
869
|
+
|
870
|
+
if (typeof WebForm_ExecuteCallback == "function") {
|
871
|
+
WebForm_ExecuteCallback = (function(callbackObject) {
|
872
|
+
// Store original function
|
873
|
+
var original = WebForm_ExecuteCallback;
|
874
|
+
return function(callbackObject) {
|
875
|
+
original(callbackObject);
|
876
|
+
var stringIds = callbackObject.xmlRequest.getResponseHeader(
|
877
|
+
"X-MiniProfiler-Ids"
|
878
|
+
);
|
879
|
+
|
880
|
+
if (stringIds) {
|
881
|
+
var ids = stringIds.split(",");
|
882
|
+
fetchResults(ids);
|
384
883
|
}
|
884
|
+
};
|
885
|
+
})();
|
886
|
+
} // also fetch results after ExtJS requests, in case it is being used
|
887
|
+
|
888
|
+
if (
|
889
|
+
typeof Ext != "undefined" &&
|
890
|
+
typeof Ext.Ajax != "undefined" &&
|
891
|
+
typeof Ext.Ajax.on != "undefined"
|
892
|
+
) {
|
893
|
+
// Ext.Ajax is a singleton, so we just have to attach to its 'requestcomplete' event
|
894
|
+
Ext.Ajax.on("requestcomplete", function(e, xhr, settings) {
|
895
|
+
//iframed file uploads don't have headers
|
896
|
+
if (!xhr || !xhr.getResponseHeader) {
|
897
|
+
return;
|
898
|
+
}
|
385
899
|
|
386
|
-
|
387
|
-
bg.remove();
|
388
|
-
queries.hide();
|
389
|
-
}
|
900
|
+
var stringIds = xhr.getResponseHeader("X-MiniProfiler-Ids");
|
390
901
|
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
$(document).on('keydown.mini-profiler', null, options.toggleShortcut, function(e) {
|
396
|
-
$('.profiler-results').toggle();
|
397
|
-
sessionStorage['rack-mini-profiler-start-hidden'] = $('.profiler-results').is(':hidden');
|
902
|
+
if (stringIds) {
|
903
|
+
var ids = stringIds.split(",");
|
904
|
+
fetchResults(ids);
|
905
|
+
}
|
398
906
|
});
|
907
|
+
}
|
399
908
|
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
}
|
405
|
-
};
|
406
|
-
|
407
|
-
var unbindDocumentEvents = function() {
|
408
|
-
$(document).off('.mini-profiler');
|
409
|
-
};
|
410
|
-
|
411
|
-
var initFullView = function () {
|
412
|
-
|
413
|
-
// first, get jquery tmpl, then render and bind handlers
|
414
|
-
fetchTemplates(function () {
|
415
|
-
|
416
|
-
// profiler will be defined in the full page's head
|
417
|
-
renderTemplate(profiler).appendTo(container);
|
418
|
-
|
419
|
-
var popup = $('.profiler-popup');
|
909
|
+
if (typeof MooTools != "undefined" && typeof Request != "undefined") {
|
910
|
+
Request.prototype.addEvents({
|
911
|
+
onComplete: function onComplete() {
|
912
|
+
var stringIds = this.xhr.getResponseHeader("X-MiniProfiler-Ids");
|
420
913
|
|
421
|
-
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
popup.find('.profiler-queries-show').on('click', function () {
|
427
|
-
queriesScrollIntoView($(this), $('.profiler-queries'), $(document));
|
428
|
-
});
|
914
|
+
if (stringIds) {
|
915
|
+
var ids = stringIds.split(",");
|
916
|
+
fetchResults(ids);
|
917
|
+
}
|
918
|
+
}
|
429
919
|
});
|
430
|
-
|
431
|
-
|
432
|
-
|
433
|
-
|
434
|
-
|
920
|
+
} // add support for AngularJS, which use the basic XMLHttpRequest object.
|
921
|
+
|
922
|
+
if (window.angular && typeof XMLHttpRequest != "undefined") {
|
923
|
+
var _send = XMLHttpRequest.prototype.send;
|
924
|
+
|
925
|
+
XMLHttpRequest.prototype.send = function sendReplacement(data) {
|
926
|
+
if (this.onreadystatechange) {
|
927
|
+
if (
|
928
|
+
typeof this.miniprofiler == "undefined" ||
|
929
|
+
typeof this.miniprofiler.prev_onreadystatechange == "undefined"
|
930
|
+
) {
|
931
|
+
this.miniprofiler = {
|
932
|
+
prev_onreadystatechange: this.onreadystatechange
|
933
|
+
};
|
934
|
+
|
935
|
+
this.onreadystatechange = function onReadyStateChangeReplacement() {
|
936
|
+
if (this.readyState == 4) {
|
937
|
+
var stringIds = this.getResponseHeader("X-MiniProfiler-Ids");
|
938
|
+
|
939
|
+
if (stringIds) {
|
940
|
+
var ids = stringIds.split(",");
|
941
|
+
fetchResults(ids);
|
942
|
+
}
|
943
|
+
}
|
435
944
|
|
436
|
-
|
437
|
-
|
438
|
-
|
945
|
+
if (this.miniprofiler.prev_onreadystatechange !== null)
|
946
|
+
return this.miniprofiler.prev_onreadystatechange.apply(
|
947
|
+
this,
|
948
|
+
arguments
|
949
|
+
);
|
950
|
+
};
|
951
|
+
}
|
952
|
+
}
|
439
953
|
|
440
|
-
|
441
|
-
|
442
|
-
|
954
|
+
return _send.apply(this, arguments);
|
955
|
+
};
|
956
|
+
} // https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API
|
957
|
+
|
958
|
+
if (typeof window.fetch === "function") {
|
959
|
+
var __originalFetch = window.fetch;
|
960
|
+
|
961
|
+
window.fetch = function(input, init) {
|
962
|
+
var originalFetchRun = __originalFetch(input, init);
|
963
|
+
|
964
|
+
originalFetchRun.then(function(response) {
|
965
|
+
try {
|
966
|
+
// look for x-mini-profile-ids
|
967
|
+
var entries = response.headers.entries();
|
968
|
+
var _iteratorNormalCompletion = true;
|
969
|
+
var _didIteratorError = false;
|
970
|
+
var _iteratorError = undefined;
|
971
|
+
|
972
|
+
try {
|
973
|
+
for (
|
974
|
+
var _iterator = entries[Symbol.iterator](), _step;
|
975
|
+
!(_iteratorNormalCompletion = (_step = _iterator.next())
|
976
|
+
.done);
|
977
|
+
_iteratorNormalCompletion = true
|
978
|
+
) {
|
979
|
+
var pair = _step.value;
|
980
|
+
|
981
|
+
if (
|
982
|
+
pair[0] &&
|
983
|
+
pair[0].toLowerCase() == "x-miniprofiler-ids"
|
984
|
+
) {
|
985
|
+
var ids = pair[1].split(",");
|
986
|
+
fetchResults(ids);
|
987
|
+
}
|
443
988
|
}
|
444
|
-
|
445
|
-
|
446
|
-
|
447
|
-
|
989
|
+
} catch (err) {
|
990
|
+
_didIteratorError = true;
|
991
|
+
_iteratorError = err;
|
992
|
+
} finally {
|
993
|
+
try {
|
994
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
995
|
+
_iterator.return();
|
996
|
+
}
|
997
|
+
} finally {
|
998
|
+
if (_didIteratorError) {
|
999
|
+
throw _iteratorError;
|
1000
|
+
}
|
448
1001
|
}
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
|
456
|
-
|
1002
|
+
}
|
1003
|
+
} catch (e) {
|
1004
|
+
console.error(e);
|
1005
|
+
}
|
1006
|
+
});
|
1007
|
+
return originalFetchRun;
|
1008
|
+
};
|
1009
|
+
}
|
1010
|
+
window.MiniProfiler.patchesApplied = true;
|
1011
|
+
}
|
1012
|
+
|
1013
|
+
bindDocumentEvents();
|
1014
|
+
};
|
1015
|
+
|
1016
|
+
return {
|
1017
|
+
fetchedIds: fetchedIds,
|
1018
|
+
fetchingIds: fetchingIds,
|
1019
|
+
init: function init() {
|
1020
|
+
var script = document.getElementById("mini-profiler");
|
1021
|
+
if (!script || !script.getAttribute) return;
|
1022
|
+
|
1023
|
+
this.options = options = (function() {
|
1024
|
+
var version = script.getAttribute("data-version");
|
1025
|
+
var path = script.getAttribute("data-path");
|
1026
|
+
var currentId = script.getAttribute("data-current-id");
|
1027
|
+
var ids = script.getAttribute("data-ids");
|
1028
|
+
if (ids) ids = ids.split(",");
|
1029
|
+
var horizontal_position = script.getAttribute(
|
1030
|
+
"data-horizontal-position"
|
1031
|
+
);
|
1032
|
+
var vertical_position = script.getAttribute("data-vertical-position");
|
1033
|
+
var toggleShortcut = script.getAttribute("data-toggle-shortcut");
|
1034
|
+
|
1035
|
+
if (script.getAttribute("data-max-traces")) {
|
1036
|
+
var maxTraces = parseInt(script.getAttribute("data-max-traces"), 10);
|
457
1037
|
}
|
458
|
-
};
|
459
1038
|
|
460
|
-
|
1039
|
+
var collapseResults =
|
1040
|
+
script.getAttribute("data-collapse-results") === "true";
|
1041
|
+
var trivial = script.getAttribute("data-trivial") === "true";
|
1042
|
+
var children = script.getAttribute("data-children") === "true";
|
1043
|
+
var controls = script.getAttribute("data-controls") === "true";
|
1044
|
+
var totalSqlCount =
|
1045
|
+
script.getAttribute("data-total-sql-count") === "true";
|
1046
|
+
var authorized = script.getAttribute("data-authorized") === "true";
|
1047
|
+
var startHidden =
|
1048
|
+
script.getAttribute("data-start-hidden") === "true" ||
|
1049
|
+
sessionStorage["rack-mini-profiler-start-hidden"] === "true";
|
1050
|
+
var htmlContainer = script.getAttribute("data-html-container");
|
1051
|
+
var cssUrl = script.getAttribute("data-css-url");
|
1052
|
+
var hiddenCustomFields = script
|
1053
|
+
.getAttribute("data-hidden-custom-fields")
|
1054
|
+
.toLowerCase()
|
1055
|
+
.split(",");
|
1056
|
+
var hotwireTurboDriveSupport = script
|
1057
|
+
.getAttribute('data-turbo-permanent') === "true";
|
1058
|
+
return {
|
1059
|
+
ids: ids,
|
1060
|
+
path: path,
|
1061
|
+
version: version,
|
1062
|
+
renderHorizontalPosition: horizontal_position,
|
1063
|
+
renderVerticalPosition: vertical_position,
|
1064
|
+
showTrivial: trivial,
|
1065
|
+
showChildrenTime: children,
|
1066
|
+
maxTracesToShow: maxTraces,
|
1067
|
+
showControls: controls,
|
1068
|
+
showTotalSqlCount: totalSqlCount,
|
1069
|
+
currentId: currentId,
|
1070
|
+
authorized: authorized,
|
1071
|
+
toggleShortcut: toggleShortcut,
|
1072
|
+
startHidden: startHidden,
|
1073
|
+
collapseResults: collapseResults,
|
1074
|
+
htmlContainer: htmlContainer,
|
1075
|
+
cssUrl: cssUrl,
|
1076
|
+
hiddenCustomFields: hiddenCustomFields,
|
1077
|
+
hotwireTurboDriveSupport: hotwireTurboDriveSupport
|
1078
|
+
};
|
1079
|
+
})();
|
461
1080
|
|
462
|
-
|
463
|
-
|
464
|
-
|
1081
|
+
var doInit = function doInit() {
|
1082
|
+
var snapshotsElement = document.getElementById("snapshots-data");
|
1083
|
+
if (snapshotsElement != null) {
|
1084
|
+
initSnapshots(snapshotsElement);
|
1085
|
+
return;
|
1086
|
+
}
|
465
1087
|
|
466
|
-
|
467
|
-
|
468
|
-
container.addClass("profiler-" + options.renderVerticalPosition);
|
1088
|
+
// when rendering a shared, full page, this div will exist
|
1089
|
+
container = document.querySelectorAll(".profiler-result-full");
|
469
1090
|
|
470
|
-
|
471
|
-
|
1091
|
+
if (container.length) {
|
1092
|
+
if (window.location.href.indexOf("&trivial=1") > 0) {
|
1093
|
+
options.showTrivial = true;
|
1094
|
+
}
|
472
1095
|
|
473
|
-
|
474
|
-
|
475
|
-
|
476
|
-
fetchResults(options.ids);
|
477
|
-
});
|
478
|
-
if (options.startHidden) container.hide();
|
1096
|
+
initFullView();
|
1097
|
+
} else {
|
1098
|
+
initPopupView();
|
479
1099
|
}
|
480
|
-
|
481
|
-
|
482
|
-
|
483
|
-
|
484
|
-
|
485
|
-
|
486
|
-
|
487
|
-
|
488
|
-
|
489
|
-
|
490
|
-
|
491
|
-
|
1100
|
+
}; // this preserves debugging
|
1101
|
+
|
1102
|
+
var load = function load(s, f) {
|
1103
|
+
var sc = document.createElement("script");
|
1104
|
+
sc.async = "async";
|
1105
|
+
sc.type = "text/javascript";
|
1106
|
+
sc.src = s;
|
1107
|
+
var done = false;
|
1108
|
+
|
1109
|
+
sc.onload = sc.onreadystatechange = function(_, abort) {
|
1110
|
+
if (!sc.readyState || /loaded|complete/.test(sc.readyState)) {
|
1111
|
+
if (!abort && !done) {
|
1112
|
+
done = true;
|
1113
|
+
f();
|
492
1114
|
}
|
1115
|
+
}
|
493
1116
|
};
|
494
1117
|
|
495
|
-
|
496
|
-
|
497
|
-
|
498
|
-
|
1118
|
+
document.getElementsByTagName("head")[0].appendChild(sc);
|
1119
|
+
};
|
1120
|
+
|
1121
|
+
var wait = 0;
|
1122
|
+
var finish = false;
|
1123
|
+
|
1124
|
+
var deferInit = function deferInit() {
|
1125
|
+
if (finish) return;
|
1126
|
+
|
1127
|
+
if (
|
1128
|
+
window.performance &&
|
1129
|
+
window.performance.timing &&
|
1130
|
+
window.performance.timing.loadEventEnd === 0 &&
|
1131
|
+
wait < 10000
|
1132
|
+
) {
|
1133
|
+
setTimeout(deferInit, 100);
|
1134
|
+
wait += 100;
|
1135
|
+
} else {
|
1136
|
+
finish = true;
|
1137
|
+
init();
|
499
1138
|
}
|
1139
|
+
};
|
500
1140
|
|
501
|
-
|
502
|
-
|
503
|
-
|
504
|
-
|
505
|
-
|
506
|
-
|
507
|
-
|
508
|
-
|
509
|
-
|
510
|
-
|
511
|
-
|
512
|
-
|
513
|
-
|
514
|
-
|
515
|
-
var ids = typeof JSON != 'undefined' ? JSON.parse(stringIds) : eval(stringIds);
|
516
|
-
fetchResults(ids);
|
517
|
-
}
|
518
|
-
}
|
519
|
-
}
|
520
|
-
});
|
521
|
-
}
|
522
|
-
|
523
|
-
// more Asp.Net callbacks
|
524
|
-
if (typeof (WebForm_ExecuteCallback) == "function") {
|
525
|
-
WebForm_ExecuteCallback = (function (callbackObject) {
|
526
|
-
// Store original function
|
527
|
-
var original = WebForm_ExecuteCallback;
|
528
|
-
|
529
|
-
return function (callbackObject) {
|
530
|
-
original(callbackObject);
|
531
|
-
|
532
|
-
var stringIds = callbackObject.xmlRequest.getResponseHeader('X-MiniProfiler-Ids');
|
533
|
-
if (stringIds) {
|
534
|
-
var ids = typeof JSON != 'undefined' ? JSON.parse(stringIds) : eval(stringIds);
|
535
|
-
fetchResults(ids);
|
536
|
-
}
|
537
|
-
};
|
1141
|
+
var init = function init() {
|
1142
|
+
if (options.authorized) {
|
1143
|
+
var url = options.cssUrl;
|
1144
|
+
|
1145
|
+
if (document.createStyleSheet) {
|
1146
|
+
document.createStyleSheet(url);
|
1147
|
+
} else {
|
1148
|
+
var head = document.querySelector("head");
|
1149
|
+
var link = document.createElement("link");
|
1150
|
+
link.rel = "stylesheet";
|
1151
|
+
link.type = "text/css";
|
1152
|
+
link.href = url;
|
1153
|
+
head.appendChild(link);
|
1154
|
+
}
|
538
1155
|
|
539
|
-
|
1156
|
+
if (!MiniProfiler.loadedVendor) {
|
1157
|
+
load(options.path + "vendor.js?v=" + options.version, doInit);
|
1158
|
+
} else {
|
1159
|
+
doInit();
|
1160
|
+
}
|
1161
|
+
} else {
|
1162
|
+
doInit();
|
540
1163
|
}
|
541
|
-
|
542
|
-
|
543
|
-
|
544
|
-
|
545
|
-
|
546
|
-
|
547
|
-
|
548
|
-
|
549
|
-
|
550
|
-
|
551
|
-
|
552
|
-
|
553
|
-
|
554
|
-
|
555
|
-
|
556
|
-
|
1164
|
+
};
|
1165
|
+
|
1166
|
+
deferInit();
|
1167
|
+
},
|
1168
|
+
cleanUp: function cleanUp() {
|
1169
|
+
unbindDocumentEvents();
|
1170
|
+
},
|
1171
|
+
pageTransition: function pageTransition() {
|
1172
|
+
if (totalsControl) {
|
1173
|
+
if (totalsControl.parentElement) {
|
1174
|
+
totalsControl.parentElement.removeChild(totalsControl);
|
1175
|
+
}
|
1176
|
+
totalsControl = null;
|
1177
|
+
}
|
1178
|
+
|
1179
|
+
reqs = 0;
|
1180
|
+
totalTime = 0;
|
1181
|
+
expandedResults = false;
|
1182
|
+
toArray(
|
1183
|
+
document.querySelectorAll(".profiler-results .profiler-result")
|
1184
|
+
).forEach(function(el) {
|
1185
|
+
return el.parentElement.removeChild(el);
|
1186
|
+
});
|
1187
|
+
},
|
1188
|
+
getClientTimingByName: function getClientTimingByName(clientTiming, name) {
|
1189
|
+
for (var i = 0; i < clientTiming.timings.length; i++) {
|
1190
|
+
if (clientTiming.timings[i].name == name) {
|
1191
|
+
return clientTiming.timings[i];
|
557
1192
|
}
|
1193
|
+
}
|
1194
|
+
|
1195
|
+
return {
|
1196
|
+
Name: name,
|
1197
|
+
Duration: "",
|
1198
|
+
Start: ""
|
1199
|
+
};
|
1200
|
+
},
|
1201
|
+
renderDate: function renderDate(jsonDate) {
|
1202
|
+
// JavaScriptSerializer sends dates as /Date(1308024322065)/
|
1203
|
+
if (jsonDate) {
|
1204
|
+
return typeof jsonDate === "string"
|
1205
|
+
? new Date(
|
1206
|
+
parseInt(jsonDate.replace("/Date(", "").replace(")/", ""), 10)
|
1207
|
+
).toUTCString()
|
1208
|
+
: jsonDate;
|
1209
|
+
}
|
1210
|
+
},
|
1211
|
+
renderIndent: function renderIndent(depth) {
|
1212
|
+
var result = "";
|
1213
|
+
|
1214
|
+
for (var i = 0; i < depth; i++) {
|
1215
|
+
result += " ";
|
1216
|
+
}
|
1217
|
+
|
1218
|
+
return result;
|
1219
|
+
},
|
1220
|
+
renderExecuteType: function renderExecuteType(typeId) {
|
1221
|
+
// see StackExchange.Profiling.ExecuteType enum
|
1222
|
+
switch (typeId) {
|
1223
|
+
case 0:
|
1224
|
+
return "None";
|
1225
|
+
|
1226
|
+
case 1:
|
1227
|
+
return "NonQuery";
|
1228
|
+
|
1229
|
+
case 2:
|
1230
|
+
return "Scalar";
|
1231
|
+
|
1232
|
+
case 3:
|
1233
|
+
return "Reader";
|
1234
|
+
}
|
1235
|
+
},
|
1236
|
+
shareUrl: function shareUrl(id) {
|
1237
|
+
return options.path + "results?id=" + id;
|
1238
|
+
},
|
1239
|
+
flamegraphUrl: function flamegrapgUrl(id) {
|
1240
|
+
return options.path + "flamegraph?id=" + id;
|
1241
|
+
},
|
1242
|
+
moreUrl: function moreUrl(requestName) {
|
1243
|
+
var requestParts = requestName.split(" ");
|
1244
|
+
var linkSrc =
|
1245
|
+
requestParts[0] == "GET" ? requestParts[1] : window.location.href;
|
1246
|
+
var linkSuffix = linkSrc.indexOf("?") > 0 ? "&pp=help" : "?pp=help";
|
1247
|
+
return linkSrc + linkSuffix;
|
1248
|
+
},
|
1249
|
+
getClientTimings: function getClientTimings(clientTimings) {
|
1250
|
+
var list = [];
|
1251
|
+
var t;
|
1252
|
+
if (!clientTimings.timings) return [];
|
1253
|
+
|
1254
|
+
for (var i = 0; i < clientTimings.timings.length; i++) {
|
1255
|
+
t = clientTimings.timings[i];
|
1256
|
+
var trivial = t.Name != "Dom Complete" && t.Name != "Response";
|
1257
|
+
trivial = t.Duration < 2 ? trivial : false;
|
1258
|
+
list.push({
|
1259
|
+
isTrivial: trivial,
|
1260
|
+
name: t.Name,
|
1261
|
+
duration: t.Duration,
|
1262
|
+
start: t.Start
|
1263
|
+
});
|
1264
|
+
} // Use the Paint Timing API for render performance.
|
558
1265
|
|
559
|
-
|
560
|
-
|
561
|
-
|
562
|
-
|
563
|
-
|
564
|
-
|
565
|
-
|
566
|
-
|
567
|
-
|
1266
|
+
if (window.performance && window.performance.getEntriesByName) {
|
1267
|
+
var firstPaint = window.performance.getEntriesByName("first-paint");
|
1268
|
+
|
1269
|
+
if (firstPaint !== undefined && firstPaint.length >= 1) {
|
1270
|
+
list.push({
|
1271
|
+
isTrivial: false,
|
1272
|
+
name: "First Paint Time",
|
1273
|
+
duration: firstPaint[0].duration,
|
1274
|
+
start: firstPaint[0].startTime
|
568
1275
|
});
|
569
1276
|
}
|
1277
|
+
}
|
1278
|
+
|
1279
|
+
list.sort(function(a, b) {
|
1280
|
+
return a.start - b.start;
|
1281
|
+
});
|
1282
|
+
return list;
|
1283
|
+
},
|
1284
|
+
getSqlTimings: function getSqlTimings(root) {
|
1285
|
+
var result = [],
|
1286
|
+
addToResults = function addToResults(timing) {
|
1287
|
+
if (timing.sql_timings) {
|
1288
|
+
for (var i = 0, sqlTiming; i < timing.sql_timings.length; i++) {
|
1289
|
+
sqlTiming = timing.sql_timings[i]; // HACK: add info about the parent Timing to each SqlTiming so UI can render
|
1290
|
+
|
1291
|
+
sqlTiming.parent_timing_name = timing.name;
|
1292
|
+
|
1293
|
+
if (sqlTiming.duration_milliseconds > 50) {
|
1294
|
+
sqlTiming.row_class = "slow";
|
1295
|
+
}
|
570
1296
|
|
571
|
-
|
572
|
-
|
573
|
-
var _send = XMLHttpRequest.prototype.send;
|
574
|
-
|
575
|
-
XMLHttpRequest.prototype.send = function sendReplacement(data) {
|
576
|
-
if (this.onreadystatechange) {
|
577
|
-
if (typeof (this.miniprofiler) == 'undefined' || typeof (this.miniprofiler.prev_onreadystatechange) == 'undefined') {
|
578
|
-
this.miniprofiler = { prev_onreadystatechange: this.onreadystatechange };
|
579
|
-
|
580
|
-
this.onreadystatechange = function onReadyStateChangeReplacement() {
|
581
|
-
if (this.readyState == 4) {
|
582
|
-
var stringIds = this.getResponseHeader('X-MiniProfiler-Ids');
|
583
|
-
if (stringIds) {
|
584
|
-
var ids = typeof JSON != 'undefined' ? JSON.parse(stringIds) : eval(stringIds);
|
585
|
-
fetchResults(ids);
|
586
|
-
}
|
587
|
-
}
|
588
|
-
|
589
|
-
if (this.miniprofiler.prev_onreadystatechange !== null)
|
590
|
-
return this.miniprofiler.prev_onreadystatechange.apply(this, arguments);
|
591
|
-
};
|
1297
|
+
if (sqlTiming.duration_milliseconds > 200) {
|
1298
|
+
sqlTiming.row_class = "very-slow";
|
592
1299
|
}
|
593
|
-
}
|
594
1300
|
|
595
|
-
|
596
|
-
|
597
|
-
|
1301
|
+
if (sqlTiming.duration_milliseconds > 400) {
|
1302
|
+
sqlTiming.row_class = "very-very-slow";
|
1303
|
+
}
|
598
1304
|
|
599
|
-
|
600
|
-
|
601
|
-
var __originalFetch = window.fetch;
|
602
|
-
|
603
|
-
window.fetch = function(input,init) {
|
604
|
-
return new Promise(function(resolve,reject) {
|
605
|
-
__originalFetch(input,init).then(function(response) {
|
606
|
-
// look for x-mini-profile-ids
|
607
|
-
var entries = response.headers.entries();
|
608
|
-
for (var i = 0; i < entries.length; i++) {
|
609
|
-
var pair = entries[i];
|
610
|
-
if(pair[0] && (pair[0].toLowerCase() == 'x-miniprofiler-ids')) {
|
611
|
-
var ids = JSON.parse(pair[1]);
|
612
|
-
fetchResults(ids);
|
613
|
-
}
|
614
|
-
}
|
615
|
-
resolve(response);
|
616
|
-
}).catch(function(error) {
|
617
|
-
reject(error);
|
618
|
-
});
|
619
|
-
});
|
1305
|
+
result.push(sqlTiming);
|
1306
|
+
}
|
620
1307
|
}
|
621
|
-
window.fetch.__patchedByMiniProfiler = true;
|
622
|
-
}
|
623
|
-
|
624
|
-
// some elements want to be hidden on certain doc events
|
625
|
-
bindDocumentEvents();
|
626
|
-
};
|
627
|
-
|
628
|
-
return {
|
629
|
-
|
630
|
-
init: function () {
|
631
|
-
var script = document.getElementById('mini-profiler');
|
632
|
-
if (!script || !script.getAttribute) return;
|
633
|
-
|
634
|
-
options = (function () {
|
635
|
-
var version = script.getAttribute('data-version');
|
636
|
-
var path = script.getAttribute('data-path');
|
637
|
-
|
638
|
-
var currentId = script.getAttribute('data-current-id');
|
639
|
-
|
640
|
-
var ids = script.getAttribute('data-ids');
|
641
|
-
if (ids) ids = ids.split(',');
|
642
|
-
|
643
|
-
var horizontal_position = script.getAttribute('data-horizontal-position');
|
644
|
-
var vertical_position = script.getAttribute('data-vertical-position');
|
645
|
-
|
646
|
-
var toggleShortcut = script.getAttribute('data-toggle-shortcut');
|
647
|
-
|
648
|
-
if (script.getAttribute('data-max-traces')) {
|
649
|
-
var maxTraces = parseInt(script.getAttribute('data-max-traces'), 10);
|
650
|
-
}
|
651
|
-
|
652
|
-
var collapseResults = script.getAttribute('data-collapse-results') === 'true';
|
653
|
-
var trivial = script.getAttribute('data-trivial') === 'true';
|
654
|
-
var children = script.getAttribute('data-children') === 'true';
|
655
|
-
var controls = script.getAttribute('data-controls') === 'true';
|
656
|
-
var totalSqlCount = script.getAttribute('data-total-sql-count') === 'true';
|
657
|
-
var authorized = script.getAttribute('data-authorized') === 'true';
|
658
|
-
var startHidden = script.getAttribute('data-start-hidden') === 'true' || sessionStorage['rack-mini-profiler-start-hidden'] === 'true';
|
659
|
-
var htmlContainer = script.getAttribute('data-html-container');
|
660
|
-
|
661
|
-
return {
|
662
|
-
ids: ids,
|
663
|
-
path: path,
|
664
|
-
version: version,
|
665
|
-
renderHorizontalPosition: horizontal_position,
|
666
|
-
renderVerticalPosition: vertical_position,
|
667
|
-
showTrivial: trivial,
|
668
|
-
showChildrenTime: children,
|
669
|
-
maxTracesToShow: maxTraces,
|
670
|
-
showControls: controls,
|
671
|
-
showTotalSqlCount: totalSqlCount,
|
672
|
-
currentId: currentId,
|
673
|
-
authorized: authorized,
|
674
|
-
toggleShortcut: toggleShortcut,
|
675
|
-
startHidden: startHidden,
|
676
|
-
collapseResults: collapseResults,
|
677
|
-
htmlContainer: htmlContainer
|
678
|
-
};
|
679
|
-
})();
|
680
|
-
|
681
|
-
var doInit = function () {
|
682
|
-
// when rendering a shared, full page, this div will exist
|
683
|
-
container = $('.profiler-result-full');
|
684
|
-
if (container.length) {
|
685
|
-
if (window.location.href.indexOf("&trivial=1") > 0) {
|
686
|
-
options.showTrivial = true;
|
687
|
-
}
|
688
|
-
initFullView();
|
689
|
-
}
|
690
|
-
else {
|
691
|
-
initPopupView();
|
692
|
-
}
|
693
|
-
};
|
694
|
-
|
695
|
-
// this preserves debugging
|
696
|
-
var load = function (s, f) {
|
697
|
-
var sc = document.createElement("script");
|
698
|
-
sc.async = "async";
|
699
|
-
sc.type = "text/javascript";
|
700
|
-
sc.src = s;
|
701
|
-
var done = false;
|
702
|
-
sc.onload = sc.onreadystatechange = function (_, abort) {
|
703
|
-
if (!sc.readyState || /loaded|complete/.test(sc.readyState)) {
|
704
|
-
if (!abort && !done) { done = true; f(); }
|
705
|
-
}
|
706
|
-
};
|
707
|
-
document.getElementsByTagName('head')[0].appendChild(sc);
|
708
|
-
};
|
709
|
-
|
710
|
-
var wait = 0;
|
711
|
-
var finish = false;
|
712
|
-
var deferInit = function() {
|
713
|
-
if (finish) return;
|
714
|
-
if (window.performance && window.performance.timing && window.performance.timing.loadEventEnd === 0 && wait < 10000) {
|
715
|
-
setTimeout(deferInit, 100);
|
716
|
-
wait += 100;
|
717
|
-
} else {
|
718
|
-
finish = true;
|
719
|
-
init();
|
720
|
-
}
|
721
|
-
};
|
722
1308
|
|
723
|
-
|
1309
|
+
if (timing.children) {
|
1310
|
+
for (var i = 0; i < timing.children.length; i++) {
|
1311
|
+
addToResults(timing.children[i]);
|
1312
|
+
}
|
1313
|
+
}
|
1314
|
+
}; // start adding at the root and recurse down
|
724
1315
|
|
725
|
-
|
726
|
-
// https://github.com/jeresig/jquery.hotkeys/blob/master/jquery.hotkeys.js
|
1316
|
+
addToResults(root);
|
727
1317
|
|
728
|
-
|
729
|
-
|
730
|
-
!0:(f[a+e]=!0,f[a+d.hotkeys.shiftNums[e]]=!0,"shift+"===a&&(f[d.hotkeys.shiftNums[e]]=!0));c=0;for(e=j.length;c<e;c++)if(f[j[c]])return h.apply(this,arguments)}}}}d.hotkeys={version:"0.8",specialKeys:{8:"backspace",9:"tab",13:"return",16:"shift",17:"ctrl",18:"alt",19:"pause",20:"capslock",27:"esc",32:"space",33:"pageup",34:"pagedown",35:"end",36:"home",37:"left",38:"up",39:"right",40:"down",45:"insert",46:"del",96:"0",97:"1",98:"2",99:"3",100:"4",101:"5",102:"6",103:"7",104:"8",105:"9",106:"*",107:"+",
|
731
|
-
109:"-",110:".",111:"/",112:"f1",113:"f2",114:"f3",115:"f4",116:"f5",117:"f6",118:"f7",119:"f8",120:"f9",121:"f10",122:"f11",123:"f12",144:"numlock",145:"scroll",191:"/",224:"meta"},shiftNums:{"`":"~",1:"!",2:"@",3:"#",4:"$",5:"%",6:"^",7:"&",8:"*",9:"(","0":")","-":"_","=":"+",";":": ","'":'"',",":"<",".":">","/":"?","\\":"|"}};d.each(["keydown","keyup","keypress"],function(){d.event.special[this]={add:h}})})(MiniProfiler.jQuery);
|
732
|
-
}
|
1318
|
+
var removeDuration = function removeDuration(list, duration) {
|
1319
|
+
var newList = [];
|
733
1320
|
|
734
|
-
|
735
|
-
|
736
|
-
if (document.createStyleSheet) {
|
737
|
-
document.createStyleSheet(url);
|
738
|
-
} else {
|
739
|
-
$('head').append($('<link rel="stylesheet" type="text/css" href="' + url + '" />'));
|
740
|
-
}
|
741
|
-
if (!$.tmpl) {
|
742
|
-
load(options.path + 'jquery.tmpl.js?v=' + options.version, doInit);
|
743
|
-
} else {
|
744
|
-
doInit();
|
745
|
-
}
|
746
|
-
} else {
|
747
|
-
doInit();
|
748
|
-
}
|
749
|
-
|
750
|
-
};
|
1321
|
+
for (var i = 0; i < list.length; i++) {
|
1322
|
+
var item = list[i];
|
751
1323
|
|
752
|
-
|
753
|
-
if (
|
754
|
-
|
755
|
-
|
756
|
-
minor = parseInt(jQueryVersion[1], 10);
|
1324
|
+
if (duration.start > item.start) {
|
1325
|
+
if (duration.start > item.finish) {
|
1326
|
+
newList.push(item);
|
1327
|
+
continue;
|
757
1328
|
}
|
758
1329
|
|
759
|
-
|
760
|
-
|
761
|
-
|
762
|
-
|
763
|
-
} else {
|
764
|
-
load(options.path + "jquery.1.7.1.js?v=" + options.version, function() {
|
765
|
-
MiniProfiler.jQuery = $ = jQuery.noConflict(true);
|
766
|
-
$(deferInit);
|
767
|
-
});
|
768
|
-
}
|
769
|
-
},
|
770
|
-
|
771
|
-
cleanUp: function() {
|
772
|
-
unbindDocumentEvents();
|
773
|
-
},
|
774
|
-
|
775
|
-
pageTransition: function() {
|
776
|
-
if (totalsControl) {
|
777
|
-
totalsControl.remove();
|
778
|
-
totalsControl = null;
|
1330
|
+
newList.push({
|
1331
|
+
start: item.start,
|
1332
|
+
finish: duration.start
|
1333
|
+
});
|
779
1334
|
}
|
780
|
-
reqs = 0;
|
781
|
-
totalTime = 0;
|
782
|
-
expandedResults = false;
|
783
|
-
$('.profiler-results .profiler-result').remove();
|
784
|
-
},
|
785
|
-
|
786
|
-
getClientTimingByName: function (clientTiming, name) {
|
787
1335
|
|
788
|
-
|
789
|
-
|
790
|
-
|
791
|
-
|
1336
|
+
if (duration.finish < item.finish) {
|
1337
|
+
if (duration.finish < item.start) {
|
1338
|
+
newList.push(item);
|
1339
|
+
continue;
|
792
1340
|
}
|
793
|
-
return { Name: name, Duration: "", Start: "" };
|
794
|
-
},
|
795
1341
|
|
796
|
-
|
797
|
-
|
798
|
-
|
799
|
-
}
|
800
|
-
|
1342
|
+
newList.push({
|
1343
|
+
start: duration.finish,
|
1344
|
+
finish: item.finish
|
1345
|
+
});
|
1346
|
+
}
|
1347
|
+
}
|
801
1348
|
|
802
|
-
|
803
|
-
|
804
|
-
for (var i = 0; i < depth; i++) {
|
805
|
-
result += ' ';
|
806
|
-
}
|
807
|
-
return result;
|
808
|
-
},
|
809
|
-
|
810
|
-
renderExecuteType: function (typeId) {
|
811
|
-
// see StackExchange.Profiling.ExecuteType enum
|
812
|
-
switch (typeId) {
|
813
|
-
case 0: return 'None';
|
814
|
-
case 1: return 'NonQuery';
|
815
|
-
case 2: return 'Scalar';
|
816
|
-
case 3: return 'Reader';
|
817
|
-
}
|
818
|
-
},
|
819
|
-
|
820
|
-
shareUrl: function (id) {
|
821
|
-
return options.path + 'results?id=' + id;
|
822
|
-
},
|
823
|
-
|
824
|
-
moreUrl: function () {
|
825
|
-
var loc = window.location.href;
|
826
|
-
loc = loc.indexOf("?") > 0 ? loc + "&pp=help" : "?pp=help";
|
827
|
-
return loc;
|
828
|
-
},
|
829
|
-
|
830
|
-
getClientTimings: function (clientTimings) {
|
831
|
-
var list = [];
|
832
|
-
var t;
|
833
|
-
|
834
|
-
if (!clientTimings.timings) return [];
|
835
|
-
|
836
|
-
for (var i = 0; i < clientTimings.timings.length; i++) {
|
837
|
-
t = clientTimings.timings[i];
|
838
|
-
var trivial = t.Name != "Dom Complete" && t.Name != "Response"
|
839
|
-
trivial = t.Duration < 2 ? trivial : false;
|
840
|
-
list.push(
|
841
|
-
{
|
842
|
-
isTrivial: trivial,
|
843
|
-
name: t.Name,
|
844
|
-
duration: t.Duration,
|
845
|
-
start: t.Start
|
846
|
-
});
|
847
|
-
}
|
1349
|
+
return newList;
|
1350
|
+
};
|
848
1351
|
|
1352
|
+
var processTimes = function processTimes(elem, parent) {
|
1353
|
+
var duration = {
|
1354
|
+
start: elem.start_milliseconds,
|
1355
|
+
finish: elem.start_milliseconds + elem.duration_milliseconds
|
1356
|
+
};
|
1357
|
+
elem.richTiming = [duration];
|
1358
|
+
|
1359
|
+
if (parent !== null) {
|
1360
|
+
elem.parent = parent;
|
1361
|
+
elem.parent.richTiming = removeDuration(
|
1362
|
+
elem.parent.richTiming,
|
1363
|
+
duration
|
1364
|
+
);
|
1365
|
+
}
|
849
1366
|
|
850
|
-
|
851
|
-
|
852
|
-
|
1367
|
+
if (elem.children) {
|
1368
|
+
for (var i = 0; i < elem.children.length; i++) {
|
1369
|
+
processTimes(elem.children[i], elem);
|
1370
|
+
}
|
1371
|
+
}
|
1372
|
+
};
|
853
1373
|
|
854
|
-
|
855
|
-
list.push(
|
856
|
-
{
|
857
|
-
isTrivial: false,
|
858
|
-
name: "First Paint Time",
|
859
|
-
duration: firstPaint[0].duration,
|
860
|
-
start: firstPaint[0].startTime
|
861
|
-
});
|
862
|
-
}
|
863
|
-
}
|
1374
|
+
processTimes(root, null); // sort results by time
|
864
1375
|
|
865
|
-
|
866
|
-
|
867
|
-
|
868
|
-
|
869
|
-
getSqlTimings: function (root) {
|
870
|
-
var result = [],
|
871
|
-
addToResults = function (timing) {
|
872
|
-
if (timing.sql_timings) {
|
873
|
-
for (var i = 0, sqlTiming; i < timing.sql_timings.length; i++) {
|
874
|
-
sqlTiming = timing.sql_timings[i];
|
875
|
-
|
876
|
-
// HACK: add info about the parent Timing to each SqlTiming so UI can render
|
877
|
-
sqlTiming.parent_timing_name = timing.name;
|
878
|
-
|
879
|
-
if(sqlTiming.duration_milliseconds > 50) {
|
880
|
-
sqlTiming.row_class = "slow";
|
881
|
-
}
|
882
|
-
|
883
|
-
if(sqlTiming.duration_milliseconds > 200) {
|
884
|
-
sqlTiming.row_class = "very-slow";
|
885
|
-
}
|
886
|
-
|
887
|
-
if(sqlTiming.duration_milliseconds > 400) {
|
888
|
-
sqlTiming.row_class = "very-very-slow";
|
889
|
-
}
|
890
|
-
|
891
|
-
result.push(sqlTiming);
|
892
|
-
}
|
893
|
-
}
|
894
|
-
|
895
|
-
if (timing.children) {
|
896
|
-
for (var i = 0; i < timing.children.length; i++) {
|
897
|
-
addToResults(timing.children[i]);
|
898
|
-
}
|
899
|
-
}
|
900
|
-
};
|
901
|
-
|
902
|
-
// start adding at the root and recurse down
|
903
|
-
addToResults(root);
|
904
|
-
|
905
|
-
var removeDuration = function(list, duration) {
|
906
|
-
|
907
|
-
var newList = [];
|
908
|
-
for (var i = 0; i < list.length; i++) {
|
909
|
-
|
910
|
-
var item = list[i];
|
911
|
-
if (duration.start > item.start) {
|
912
|
-
if (duration.start > item.finish) {
|
913
|
-
newList.push(item);
|
914
|
-
continue;
|
915
|
-
}
|
916
|
-
newList.push({ start: item.start, finish: duration.start });
|
917
|
-
}
|
918
|
-
|
919
|
-
if (duration.finish < item.finish) {
|
920
|
-
if (duration.finish < item.start) {
|
921
|
-
newList.push(item);
|
922
|
-
continue;
|
923
|
-
}
|
924
|
-
newList.push({ start: duration.finish, finish: item.finish });
|
925
|
-
}
|
926
|
-
}
|
1376
|
+
result.sort(function(a, b) {
|
1377
|
+
return a.start_milliseconds - b.start_milliseconds;
|
1378
|
+
});
|
927
1379
|
|
928
|
-
|
929
|
-
|
1380
|
+
var determineOverlap = function determineOverlap(gap, node) {
|
1381
|
+
var overlap = 0;
|
930
1382
|
|
931
|
-
|
932
|
-
|
933
|
-
elem.richTiming = [duration];
|
934
|
-
if (parent !== null) {
|
935
|
-
elem.parent = parent;
|
936
|
-
elem.parent.richTiming = removeDuration(elem.parent.richTiming, duration);
|
937
|
-
}
|
1383
|
+
for (var i = 0; i < node.richTiming.length; i++) {
|
1384
|
+
var current = node.richTiming[i];
|
938
1385
|
|
939
|
-
|
940
|
-
|
941
|
-
|
942
|
-
}
|
943
|
-
}
|
944
|
-
};
|
1386
|
+
if (current.start > gap.finish) {
|
1387
|
+
break;
|
1388
|
+
}
|
945
1389
|
|
946
|
-
|
1390
|
+
if (current.finish < gap.start) {
|
1391
|
+
continue;
|
1392
|
+
}
|
947
1393
|
|
948
|
-
|
949
|
-
|
1394
|
+
overlap +=
|
1395
|
+
Math.min(gap.finish, current.finish) -
|
1396
|
+
Math.max(gap.start, current.start);
|
1397
|
+
}
|
950
1398
|
|
951
|
-
|
952
|
-
|
953
|
-
for (var i = 0; i < node.richTiming.length; i++) {
|
954
|
-
var current = node.richTiming[i];
|
955
|
-
if (current.start > gap.finish) {
|
956
|
-
break;
|
957
|
-
}
|
958
|
-
if (current.finish < gap.start) {
|
959
|
-
continue;
|
960
|
-
}
|
1399
|
+
return overlap;
|
1400
|
+
};
|
961
1401
|
|
962
|
-
|
963
|
-
|
964
|
-
return overlap;
|
965
|
-
};
|
1402
|
+
var determineGap = function determineGap(gap, node, match) {
|
1403
|
+
var overlap = determineOverlap(gap, node);
|
966
1404
|
|
967
|
-
|
968
|
-
|
969
|
-
|
970
|
-
|
971
|
-
|
972
|
-
|
973
|
-
|
974
|
-
|
1405
|
+
if (match === null || overlap > match.duration) {
|
1406
|
+
match = {
|
1407
|
+
name: node.name,
|
1408
|
+
duration: overlap
|
1409
|
+
};
|
1410
|
+
} else if (match.name == node.name) {
|
1411
|
+
match.duration += overlap;
|
1412
|
+
}
|
975
1413
|
|
976
|
-
|
977
|
-
|
978
|
-
|
979
|
-
|
980
|
-
|
981
|
-
return match;
|
982
|
-
};
|
983
|
-
|
984
|
-
var time = 0;
|
985
|
-
var prev = null;
|
986
|
-
$.each(result, function () {
|
987
|
-
this.prevGap = {
|
988
|
-
duration: (this.start_milliseconds - time).toFixed(2),
|
989
|
-
start: time,
|
990
|
-
finish: this.start_milliseconds
|
991
|
-
};
|
992
|
-
|
993
|
-
this.prevGap.topReason = determineGap(this.prevGap, root, null);
|
994
|
-
|
995
|
-
time = this.start_milliseconds + this.duration_milliseconds;
|
996
|
-
prev = this;
|
997
|
-
});
|
1414
|
+
if (node.children) {
|
1415
|
+
for (var i = 0; i < node.children.length; i++) {
|
1416
|
+
match = determineGap(gap, node.children[i], match);
|
1417
|
+
}
|
1418
|
+
}
|
998
1419
|
|
1420
|
+
return match;
|
1421
|
+
};
|
999
1422
|
|
1000
|
-
|
1001
|
-
|
1002
|
-
|
1003
|
-
|
1004
|
-
|
1005
|
-
|
1006
|
-
|
1007
|
-
|
1008
|
-
|
1423
|
+
var time = 0;
|
1424
|
+
var prev = null;
|
1425
|
+
result.forEach(function(r) {
|
1426
|
+
r.prevGap = {
|
1427
|
+
duration: (r.start_milliseconds - time).toFixed(2),
|
1428
|
+
start: time,
|
1429
|
+
finish: r.start_milliseconds
|
1430
|
+
};
|
1431
|
+
r.prevGap.topReason = determineGap(r.prevGap, root, null);
|
1432
|
+
time = r.start_milliseconds + r.duration_milliseconds;
|
1433
|
+
prev = r;
|
1434
|
+
});
|
1435
|
+
|
1436
|
+
if (result.length > 0) {
|
1437
|
+
var me = result[result.length - 1];
|
1438
|
+
me.nextGap = {
|
1439
|
+
duration: (root.duration_milliseconds - time).toFixed(2),
|
1440
|
+
start: time,
|
1441
|
+
finish: root.duration_milliseconds
|
1442
|
+
};
|
1443
|
+
me.nextGap.topReason = determineGap(me.nextGap, root, null);
|
1444
|
+
}
|
1445
|
+
|
1446
|
+
return result;
|
1447
|
+
},
|
1448
|
+
getSqlTimingsCount: function getSqlTimingsCount(root) {
|
1449
|
+
var result = 0,
|
1450
|
+
countSql = function countSql(timing) {
|
1451
|
+
if (timing.sql_timings) {
|
1452
|
+
result += timing.sql_timings.length;
|
1453
|
+
}
|
1009
1454
|
|
1010
|
-
|
1011
|
-
|
1012
|
-
|
1013
|
-
getSqlTimingsCount: function (root) {
|
1014
|
-
var result = 0,
|
1015
|
-
countSql = function (timing) {
|
1016
|
-
if (timing.sql_timings) {
|
1017
|
-
result += timing.sql_timings.length;
|
1018
|
-
}
|
1019
|
-
|
1020
|
-
if (timing.children) {
|
1021
|
-
for (var i = 0; i < timing.children.length; i++) {
|
1022
|
-
countSql(timing.children[i]);
|
1023
|
-
}
|
1024
|
-
}
|
1025
|
-
};
|
1026
|
-
countSql(root);
|
1027
|
-
return result;
|
1028
|
-
},
|
1029
|
-
|
1030
|
-
fetchResultsExposed: function (ids) {
|
1031
|
-
return fetchResults(ids);
|
1032
|
-
},
|
1033
|
-
|
1034
|
-
formatParameters: function (parameters) {
|
1035
|
-
if (parameters != null) {
|
1036
|
-
return parameters.map(function(item, index){ return "["+item[0]+", "+ item[1] +"]";}).join(', ');
|
1037
|
-
}
|
1038
|
-
else {
|
1039
|
-
return '';
|
1455
|
+
if (timing.children) {
|
1456
|
+
for (var i = 0; i < timing.children.length; i++) {
|
1457
|
+
countSql(timing.children[i]);
|
1040
1458
|
}
|
1041
|
-
|
1042
|
-
|
1043
|
-
formatDuration: function (duration) {
|
1044
|
-
return (duration || 0).toFixed(1);
|
1045
|
-
},
|
1459
|
+
}
|
1460
|
+
};
|
1046
1461
|
|
1047
|
-
|
1048
|
-
|
1462
|
+
countSql(root);
|
1463
|
+
return result;
|
1464
|
+
},
|
1465
|
+
fetchResultsExposed: function fetchResultsExposed(ids) {
|
1466
|
+
return fetchResults(ids);
|
1467
|
+
},
|
1468
|
+
formatParameters: function formatParameters(parameters) {
|
1469
|
+
if (parameters != null) {
|
1470
|
+
return parameters
|
1471
|
+
.map(function(item, index) {
|
1472
|
+
return "[" + item[0] + ", " + item[1] + "]";
|
1473
|
+
})
|
1474
|
+
.join(", ");
|
1475
|
+
} else {
|
1476
|
+
return "";
|
1477
|
+
}
|
1478
|
+
},
|
1479
|
+
formatDuration: function formatDuration(duration) {
|
1480
|
+
return (duration || 0).toFixed(1);
|
1481
|
+
},
|
1482
|
+
showTotalSqlCount: function showTotalSqlCount() {
|
1483
|
+
return options.showTotalSqlCount;
|
1484
|
+
},
|
1485
|
+
timestampToRelative: function timestampToRelative(timestamp) {
|
1486
|
+
var now = Math.round(new Date().getTime() / 1000);
|
1487
|
+
timestamp = Math.round(timestamp / 1000);
|
1488
|
+
var diff = now - timestamp;
|
1489
|
+
if (diff < 60) {
|
1490
|
+
return "< 1 minute";
|
1491
|
+
}
|
1492
|
+
var buildDisplayTime = function buildDisplayTime(num, unit) {
|
1493
|
+
var res = num + " " + unit;
|
1494
|
+
if (num !== 1) {
|
1495
|
+
res += "s";
|
1049
1496
|
}
|
1050
|
-
|
1497
|
+
return res;
|
1498
|
+
};
|
1499
|
+
diff = Math.round(diff / 60);
|
1500
|
+
if (diff <= 60) {
|
1501
|
+
return buildDisplayTime(diff, "minute");
|
1502
|
+
}
|
1503
|
+
diff = Math.round(diff / 60);
|
1504
|
+
if (diff <= 24) {
|
1505
|
+
return buildDisplayTime(diff, "hour");
|
1506
|
+
}
|
1507
|
+
diff = Math.round(diff / 24);
|
1508
|
+
return buildDisplayTime(diff, "day");
|
1509
|
+
}
|
1510
|
+
};
|
1051
1511
|
})();
|
1052
1512
|
|
1053
|
-
MiniProfiler
|
1054
|
-
|
1055
|
-
if (typeof prettyPrint === "undefined") {
|
1056
|
-
|
1057
|
-
// prettify.js
|
1058
|
-
// http://code.google.com/p/google-code-prettify/
|
1059
|
-
|
1060
|
-
window.PR_SHOULD_USE_CONTINUATION=true;window.PR_TAB_WIDTH=8;window.PR_normalizedHtml=window.PR=window.prettyPrintOne=window.prettyPrint=void 0;window._pr_isIE6=function(){var y=navigator&&navigator.userAgent&&navigator.userAgent.match(/\bMSIE ([678])\./);y=y?+y[1]:false;window._pr_isIE6=function(){return y};return y};
|
1061
|
-
(function(){function y(b){return b.replace(L,"&").replace(M,"<").replace(N,">")}function H(b,f,i){switch(b.nodeType){case 1:var o=b.tagName.toLowerCase();f.push("<",o);var l=b.attributes,n=l.length;if(n){if(i){for(var r=[],j=n;--j>=0;)r[j]=l[j];r.sort(function(q,m){return q.name<m.name?-1:q.name===m.name?0:1});l=r}for(j=0;j<n;++j){r=l[j];r.specified&&f.push(" ",r.name.toLowerCase(),'="',r.value.replace(L,"&").replace(M,"<").replace(N,">").replace(X,"""),'"')}}f.push(">");
|
1062
|
-
for(l=b.firstChild;l;l=l.nextSibling)H(l,f,i);if(b.firstChild||!/^(?:br|link|img)$/.test(o))f.push("</",o,">");break;case 3:case 4:f.push(y(b.nodeValue));break}}function O(b){function f(c){if(c.charAt(0)!=="\\")return c.charCodeAt(0);switch(c.charAt(1)){case "b":return 8;case "t":return 9;case "n":return 10;case "v":return 11;case "f":return 12;case "r":return 13;case "u":case "x":return parseInt(c.substring(2),16)||c.charCodeAt(1);case "0":case "1":case "2":case "3":case "4":case "5":case "6":case "7":return parseInt(c.substring(1),
|
1063
|
-
8);default:return c.charCodeAt(1)}}function i(c){if(c<32)return(c<16?"\\x0":"\\x")+c.toString(16);c=String.fromCharCode(c);if(c==="\\"||c==="-"||c==="["||c==="]")c="\\"+c;return c}function o(c){var d=c.substring(1,c.length-1).match(RegExp("\\\\u[0-9A-Fa-f]{4}|\\\\x[0-9A-Fa-f]{2}|\\\\[0-3][0-7]{0,2}|\\\\[0-7]{1,2}|\\\\[\\s\\S]|-|[^-\\\\]","g"));c=[];for(var a=[],k=d[0]==="^",e=k?1:0,h=d.length;e<h;++e){var g=d[e];switch(g){case "\\B":case "\\b":case "\\D":case "\\d":case "\\S":case "\\s":case "\\W":case "\\w":c.push(g);
|
1064
|
-
continue}g=f(g);var s;if(e+2<h&&"-"===d[e+1]){s=f(d[e+2]);e+=2}else s=g;a.push([g,s]);if(!(s<65||g>122)){s<65||g>90||a.push([Math.max(65,g)|32,Math.min(s,90)|32]);s<97||g>122||a.push([Math.max(97,g)&-33,Math.min(s,122)&-33])}}a.sort(function(v,w){return v[0]-w[0]||w[1]-v[1]});d=[];g=[NaN,NaN];for(e=0;e<a.length;++e){h=a[e];if(h[0]<=g[1]+1)g[1]=Math.max(g[1],h[1]);else d.push(g=h)}a=["["];k&&a.push("^");a.push.apply(a,c);for(e=0;e<d.length;++e){h=d[e];a.push(i(h[0]));if(h[1]>h[0]){h[1]+1>h[0]&&a.push("-");
|
1065
|
-
a.push(i(h[1]))}}a.push("]");return a.join("")}function l(c){for(var d=c.source.match(RegExp("(?:\\[(?:[^\\x5C\\x5D]|\\\\[\\s\\S])*\\]|\\\\u[A-Fa-f0-9]{4}|\\\\x[A-Fa-f0-9]{2}|\\\\[0-9]+|\\\\[^ux0-9]|\\(\\?[:!=]|[\\(\\)\\^]|[^\\x5B\\x5C\\(\\)\\^]+)","g")),a=d.length,k=[],e=0,h=0;e<a;++e){var g=d[e];if(g==="(")++h;else if("\\"===g.charAt(0))if((g=+g.substring(1))&&g<=h)k[g]=-1}for(e=1;e<k.length;++e)if(-1===k[e])k[e]=++n;for(h=e=0;e<a;++e){g=d[e];if(g==="("){++h;if(k[h]===undefined)d[e]="(?:"}else if("\\"===
|
1066
|
-
g.charAt(0))if((g=+g.substring(1))&&g<=h)d[e]="\\"+k[h]}for(h=e=0;e<a;++e)if("^"===d[e]&&"^"!==d[e+1])d[e]="";if(c.ignoreCase&&r)for(e=0;e<a;++e){g=d[e];c=g.charAt(0);if(g.length>=2&&c==="[")d[e]=o(g);else if(c!=="\\")d[e]=g.replace(/[a-zA-Z]/g,function(s){s=s.charCodeAt(0);return"["+String.fromCharCode(s&-33,s|32)+"]"})}return d.join("")}for(var n=0,r=false,j=false,q=0,m=b.length;q<m;++q){var t=b[q];if(t.ignoreCase)j=true;else if(/[a-z]/i.test(t.source.replace(/\\u[0-9a-f]{4}|\\x[0-9a-f]{2}|\\[^ux]/gi,
|
1067
|
-
""))){r=true;j=false;break}}var p=[];q=0;for(m=b.length;q<m;++q){t=b[q];if(t.global||t.multiline)throw Error(""+t);p.push("(?:"+l(t)+")")}return RegExp(p.join("|"),j?"gi":"g")}function Y(b){var f=0;return function(i){for(var o=null,l=0,n=0,r=i.length;n<r;++n)switch(i.charAt(n)){case "\t":o||(o=[]);o.push(i.substring(l,n));l=b-f%b;for(f+=l;l>=0;l-=16)o.push(" ".substring(0,l));l=n+1;break;case "\n":f=0;break;default:++f}if(!o)return i;o.push(i.substring(l));return o.join("")}}function I(b,
|
1068
|
-
f,i,o){if(f){b={source:f,c:b};i(b);o.push.apply(o,b.d)}}function B(b,f){var i={},o;(function(){for(var r=b.concat(f),j=[],q={},m=0,t=r.length;m<t;++m){var p=r[m],c=p[3];if(c)for(var d=c.length;--d>=0;)i[c.charAt(d)]=p;p=p[1];c=""+p;if(!q.hasOwnProperty(c)){j.push(p);q[c]=null}}j.push(/[\0-\uffff]/);o=O(j)})();var l=f.length;function n(r){for(var j=r.c,q=[j,z],m=0,t=r.source.match(o)||[],p={},c=0,d=t.length;c<d;++c){var a=t[c],k=p[a],e=void 0,h;if(typeof k==="string")h=false;else{var g=i[a.charAt(0)];
|
1069
|
-
if(g){e=a.match(g[1]);k=g[0]}else{for(h=0;h<l;++h){g=f[h];if(e=a.match(g[1])){k=g[0];break}}e||(k=z)}if((h=k.length>=5&&"lang-"===k.substring(0,5))&&!(e&&typeof e[1]==="string")){h=false;k=P}h||(p[a]=k)}g=m;m+=a.length;if(h){h=e[1];var s=a.indexOf(h),v=s+h.length;if(e[2]){v=a.length-e[2].length;s=v-h.length}k=k.substring(5);I(j+g,a.substring(0,s),n,q);I(j+g+s,h,Q(k,h),q);I(j+g+v,a.substring(v),n,q)}else q.push(j+g,k)}r.d=q}return n}function x(b){var f=[],i=[];if(b.tripleQuotedStrings)f.push([A,/^(?:\'\'\'(?:[^\'\\]|\\[\s\S]|\'{1,2}(?=[^\']))*(?:\'\'\'|$)|\"\"\"(?:[^\"\\]|\\[\s\S]|\"{1,2}(?=[^\"]))*(?:\"\"\"|$)|\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$))/,
|
1070
|
-
null,"'\""]);else b.multiLineStrings?f.push([A,/^(?:\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$)|\`(?:[^\\\`]|\\[\s\S])*(?:\`|$))/,null,"'\"`"]):f.push([A,/^(?:\'(?:[^\\\'\r\n]|\\.)*(?:\'|$)|\"(?:[^\\\"\r\n]|\\.)*(?:\"|$))/,null,"\"'"]);b.verbatimStrings&&i.push([A,/^@\"(?:[^\"]|\"\")*(?:\"|$)/,null]);if(b.hashComments)if(b.cStyleComments){f.push([C,/^#(?:(?:define|elif|else|endif|error|ifdef|include|ifndef|line|pragma|undef|warning)\b|[^\r\n]*)/,null,"#"]);i.push([A,/^<(?:(?:(?:\.\.\/)*|\/?)(?:[\w-]+(?:\/[\w-]+)+)?[\w-]+\.h|[a-z]\w*)>/,
|
1071
|
-
null])}else f.push([C,/^#[^\r\n]*/,null,"#"]);if(b.cStyleComments){i.push([C,/^\/\/[^\r\n]*/,null]);i.push([C,/^\/\*[\s\S]*?(?:\*\/|$)/,null])}b.regexLiterals&&i.push(["lang-regex",RegExp("^"+Z+"(/(?=[^/*])(?:[^/\\x5B\\x5C]|\\x5C[\\s\\S]|\\x5B(?:[^\\x5C\\x5D]|\\x5C[\\s\\S])*(?:\\x5D|$))+/)")]);b=b.keywords.replace(/^\s+|\s+$/g,"");b.length&&i.push([R,RegExp("^(?:"+b.replace(/\s+/g,"|")+")\\b"),null]);f.push([z,/^\s+/,null," \r\n\t\u00a0"]);i.push([J,/^@[a-z_$][a-z_$@0-9]*/i,null],[S,/^@?[A-Z]+[a-z][A-Za-z_$@0-9]*/,
|
1072
|
-
null],[z,/^[a-z_$][a-z_$@0-9]*/i,null],[J,/^(?:0x[a-f0-9]+|(?:\d(?:_\d+)*\d*(?:\.\d*)?|\.\d\+)(?:e[+\-]?\d+)?)[a-z]*/i,null,"0123456789"],[E,/^.[^\s\w\.$@\'\"\`\/\#]*/,null]);return B(f,i)}function $(b){function f(D){if(D>r){if(j&&j!==q){n.push("</span>");j=null}if(!j&&q){j=q;n.push('<span class="',j,'">')}var T=y(p(i.substring(r,D))).replace(e?d:c,"$1 ");e=k.test(T);n.push(T.replace(a,s));r=D}}var i=b.source,o=b.g,l=b.d,n=[],r=0,j=null,q=null,m=0,t=0,p=Y(window.PR_TAB_WIDTH),c=/([\r\n ]) /g,
|
1073
|
-
d=/(^| ) /gm,a=/\r\n?|\n/g,k=/[ \r\n]$/,e=true,h=window._pr_isIE6();h=h?b.b.tagName==="PRE"?h===6?" \r\n":h===7?" <br>\r":" \r":" <br />":"<br />";var g=b.b.className.match(/\blinenums\b(?::(\d+))?/),s;if(g){for(var v=[],w=0;w<10;++w)v[w]=h+'</li><li class="L'+w+'">';var F=g[1]&&g[1].length?g[1]-1:0;n.push('<ol class="linenums"><li class="L',F%10,'"');F&&n.push(' value="',F+1,'"');n.push(">");s=function(){var D=v[++F%10];return j?"</span>"+D+'<span class="'+j+'">':D}}else s=h;
|
1074
|
-
for(;;)if(m<o.length?t<l.length?o[m]<=l[t]:true:false){f(o[m]);if(j){n.push("</span>");j=null}n.push(o[m+1]);m+=2}else if(t<l.length){f(l[t]);q=l[t+1];t+=2}else break;f(i.length);j&&n.push("</span>");g&&n.push("</li></ol>");b.a=n.join("")}function u(b,f){for(var i=f.length;--i>=0;){var o=f[i];if(G.hasOwnProperty(o))"console"in window&&console.warn("cannot override language handler %s",o);else G[o]=b}}function Q(b,f){b&&G.hasOwnProperty(b)||(b=/^\s*</.test(f)?"default-markup":"default-code");return G[b]}
|
1075
|
-
function U(b){var f=b.f,i=b.e;b.a=f;try{var o,l=f.match(aa);f=[];var n=0,r=[];if(l)for(var j=0,q=l.length;j<q;++j){var m=l[j];if(m.length>1&&m.charAt(0)==="<"){if(!ba.test(m))if(ca.test(m)){f.push(m.substring(9,m.length-3));n+=m.length-12}else if(da.test(m)){f.push("\n");++n}else if(m.indexOf(V)>=0&&m.replace(/\s(\w+)\s*=\s*(?:\"([^\"]*)\"|'([^\']*)'|(\S+))/g,' $1="$2$3$4"').match(/[cC][lL][aA][sS][sS]=\"[^\"]*\bnocode\b/)){var t=m.match(W)[2],p=1,c;c=j+1;a:for(;c<q;++c){var d=l[c].match(W);if(d&&
|
1076
|
-
d[2]===t)if(d[1]==="/"){if(--p===0)break a}else++p}if(c<q){r.push(n,l.slice(j,c+1).join(""));j=c}else r.push(n,m)}else r.push(n,m)}else{var a;p=m;var k=p.indexOf("&");if(k<0)a=p;else{for(--k;(k=p.indexOf("&#",k+1))>=0;){var e=p.indexOf(";",k);if(e>=0){var h=p.substring(k+3,e),g=10;if(h&&h.charAt(0)==="x"){h=h.substring(1);g=16}var s=parseInt(h,g);isNaN(s)||(p=p.substring(0,k)+String.fromCharCode(s)+p.substring(e+1))}}a=p.replace(ea,"<").replace(fa,">").replace(ga,"'").replace(ha,'"').replace(ia," ").replace(ja,
|
1077
|
-
"&")}f.push(a);n+=a.length}}o={source:f.join(""),h:r};var v=o.source;b.source=v;b.c=0;b.g=o.h;Q(i,v)(b);$(b)}catch(w){if("console"in window)console.log(w&&w.stack?w.stack:w)}}var A="str",R="kwd",C="com",S="typ",J="lit",E="pun",z="pln",P="src",V="nocode",Z=function(){for(var b=["!","!=","!==","#","%","%=","&","&&","&&=","&=","(","*","*=","+=",",","-=","->","/","/=",":","::",";","<","<<","<<=","<=","=","==","===",">",">=",">>",">>=",">>>",">>>=","?","@","[","^","^=","^^","^^=","{","|","|=","||","||=",
|
1078
|
-
"~","break","case","continue","delete","do","else","finally","instanceof","return","throw","try","typeof"],f="(?:^^|[+-]",i=0;i<b.length;++i)f+="|"+b[i].replace(/([^=<>:&a-z])/g,"\\$1");f+=")\\s*";return f}(),L=/&/g,M=/</g,N=/>/g,X=/\"/g,ea=/</g,fa=/>/g,ga=/'/g,ha=/"/g,ja=/&/g,ia=/ /g,ka=/[\r\n]/g,K=null,aa=RegExp("[^<]+|<!--[\\s\\S]*?--\>|<!\\[CDATA\\[[\\s\\S]*?\\]\\]>|</?[a-zA-Z](?:[^>\"']|'[^']*'|\"[^\"]*\")*>|<","g"),ba=/^<\!--/,ca=/^<!\[CDATA\[/,da=/^<br\b/i,W=/^<(\/?)([a-zA-Z][a-zA-Z0-9]*)/,
|
1079
|
-
la=x({keywords:"break continue do else for if return while auto case char const default double enum extern float goto int long register short signed sizeof static struct switch typedef union unsigned void volatile catch class delete false import new operator private protected public this throw true try typeof alignof align_union asm axiom bool concept concept_map const_cast constexpr decltype dynamic_cast explicit export friend inline late_check mutable namespace nullptr reinterpret_cast static_assert static_cast template typeid typename using virtual wchar_t where break continue do else for if return while auto case char const default double enum extern float goto int long register short signed sizeof static struct switch typedef union unsigned void volatile catch class delete false import new operator private protected public this throw true try typeof abstract boolean byte extends final finally implements import instanceof null native package strictfp super synchronized throws transient as base by checked decimal delegate descending event fixed foreach from group implicit in interface internal into is lock object out override orderby params partial readonly ref sbyte sealed stackalloc string select uint ulong unchecked unsafe ushort var break continue do else for if return while auto case char const default double enum extern float goto int long register short signed sizeof static struct switch typedef union unsigned void volatile catch class delete false import new operator private protected public this throw true try typeof debugger eval export function get null set undefined var with Infinity NaN caller delete die do dump elsif eval exit foreach for goto if import last local my next no our print package redo require sub undef unless until use wantarray while BEGIN END break continue do else for if return while and as assert class def del elif except exec finally from global import in is lambda nonlocal not or pass print raise try with yield False True None break continue do else for if return while alias and begin case class def defined elsif end ensure false in module next nil not or redo rescue retry self super then true undef unless until when yield BEGIN END break continue do else for if return while case done elif esac eval fi function in local set then until ",
|
1080
|
-
hashComments:true,cStyleComments:true,multiLineStrings:true,regexLiterals:true}),G={};u(la,["default-code"]);u(B([],[[z,/^[^<?]+/],["dec",/^<!\w[^>]*(?:>|$)/],[C,/^<\!--[\s\S]*?(?:-\->|$)/],["lang-",/^<\?([\s\S]+?)(?:\?>|$)/],["lang-",/^<%([\s\S]+?)(?:%>|$)/],[E,/^(?:<[%?]|[%?]>)/],["lang-",/^<xmp\b[^>]*>([\s\S]+?)<\/xmp\b[^>]*>/i],["lang-js",/^<script\b[^>]*>([\s\S]*?)(<\/script\b[^>]*>)/i],["lang-css",/^<style\b[^>]*>([\s\S]*?)(<\/style\b[^>]*>)/i],["lang-in.tag",/^(<\/?[a-z][^<>]*>)/i]]),["default-markup",
|
1081
|
-
"htm","html","mxml","xhtml","xml","xsl"]);u(B([[z,/^[\s]+/,null," \t\r\n"],["atv",/^(?:\"[^\"]*\"?|\'[^\']*\'?)/,null,"\"'"]],[["tag",/^^<\/?[a-z](?:[\w.:-]*\w)?|\/?>$/i],["atn",/^(?!style[\s=]|on)[a-z](?:[\w:-]*\w)?/i],["lang-uq.val",/^=\s*([^>\'\"\s]*(?:[^>\'\"\s\/]|\/(?=\s)))/],[E,/^[=<>\/]+/],["lang-js",/^on\w+\s*=\s*\"([^\"]+)\"/i],["lang-js",/^on\w+\s*=\s*\'([^\']+)\'/i],["lang-js",/^on\w+\s*=\s*([^\"\'>\s]+)/i],["lang-css",/^style\s*=\s*\"([^\"]+)\"/i],["lang-css",/^style\s*=\s*\'([^\']+)\'/i],
|
1082
|
-
["lang-css",/^style\s*=\s*([^\"\'>\s]+)/i]]),["in.tag"]);u(B([],[["atv",/^[\s\S]+/]]),["uq.val"]);u(x({keywords:"break continue do else for if return while auto case char const default double enum extern float goto int long register short signed sizeof static struct switch typedef union unsigned void volatile catch class delete false import new operator private protected public this throw true try typeof alignof align_union asm axiom bool concept concept_map const_cast constexpr decltype dynamic_cast explicit export friend inline late_check mutable namespace nullptr reinterpret_cast static_assert static_cast template typeid typename using virtual wchar_t where ",
|
1083
|
-
hashComments:true,cStyleComments:true}),["c","cc","cpp","cxx","cyc","m"]);u(x({keywords:"null true false"}),["json"]);u(x({keywords:"break continue do else for if return while auto case char const default double enum extern float goto int long register short signed sizeof static struct switch typedef union unsigned void volatile catch class delete false import new operator private protected public this throw true try typeof abstract boolean byte extends final finally implements import instanceof null native package strictfp super synchronized throws transient as base by checked decimal delegate descending event fixed foreach from group implicit in interface internal into is lock object out override orderby params partial readonly ref sbyte sealed stackalloc string select uint ulong unchecked unsafe ushort var ",
|
1084
|
-
hashComments:true,cStyleComments:true,verbatimStrings:true}),["cs"]);u(x({keywords:"break continue do else for if return while auto case char const default double enum extern float goto int long register short signed sizeof static struct switch typedef union unsigned void volatile catch class delete false import new operator private protected public this throw true try typeof abstract boolean byte extends final finally implements import instanceof null native package strictfp super synchronized throws transient ",
|
1085
|
-
cStyleComments:true}),["java"]);u(x({keywords:"break continue do else for if return while case done elif esac eval fi function in local set then until ",hashComments:true,multiLineStrings:true}),["bsh","csh","sh"]);u(x({keywords:"break continue do else for if return while and as assert class def del elif except exec finally from global import in is lambda nonlocal not or pass print raise try with yield False True None ",hashComments:true,multiLineStrings:true,tripleQuotedStrings:true}),["cv","py"]);
|
1086
|
-
u(x({keywords:"caller delete die do dump elsif eval exit foreach for goto if import last local my next no our print package redo require sub undef unless until use wantarray while BEGIN END ",hashComments:true,multiLineStrings:true,regexLiterals:true}),["perl","pl","pm"]);u(x({keywords:"break continue do else for if return while alias and begin case class def defined elsif end ensure false in module next nil not or redo rescue retry self super then true undef unless until when yield BEGIN END ",hashComments:true,
|
1087
|
-
multiLineStrings:true,regexLiterals:true}),["rb"]);u(x({keywords:"break continue do else for if return while auto case char const default double enum extern float goto int long register short signed sizeof static struct switch typedef union unsigned void volatile catch class delete false import new operator private protected public this throw true try typeof debugger eval export function get null set undefined var with Infinity NaN ",cStyleComments:true,regexLiterals:true}),["js"]);u(B([],[[A,/^[\s\S]+/]]),
|
1088
|
-
["regex"]);window.PR_normalizedHtml=H;window.prettyPrintOne=function(b,f){var i={f:b,e:f};U(i);return i.a};window.prettyPrint=function(b){function f(){for(var t=window.PR_SHOULD_USE_CONTINUATION?j.now()+250:Infinity;q<o.length&&j.now()<t;q++){var p=o[q];if(p.className&&p.className.indexOf("prettyprint")>=0){var c=p.className.match(/\blang-(\w+)\b/);if(c)c=c[1];for(var d=false,a=p.parentNode;a;a=a.parentNode)if((a.tagName==="pre"||a.tagName==="code"||a.tagName==="xmp")&&a.className&&a.className.indexOf("prettyprint")>=
|
1089
|
-
0){d=true;break}if(!d){a=p;if(null===K){d=document.createElement("PRE");d.appendChild(document.createTextNode('<!DOCTYPE foo PUBLIC "foo bar">\n<foo />'));K=!/</.test(d.innerHTML)}if(K){d=a.innerHTML;if("XMP"===a.tagName)d=y(d);else{a=a;if("PRE"===a.tagName)a=true;else if(ka.test(d)){var k="";if(a.currentStyle)k=a.currentStyle.whiteSpace;else if(window.getComputedStyle)k=window.getComputedStyle(a,null).whiteSpace;a=!k||k==="pre"}else a=true;a||(d=d.replace(/(<br\s*\/?>)[\r\n]+/g,"$1").replace(/(?:[\r\n]+[ \t]*)+/g,
|
1090
|
-
" "))}d=d}else{d=[];for(a=a.firstChild;a;a=a.nextSibling)H(a,d);d=d.join("")}d=d.replace(/(?:\r\n?|\n)$/,"");m={f:d,e:c,b:p};U(m);if(p=m.a){c=m.b;if("XMP"===c.tagName){d=document.createElement("PRE");for(a=0;a<c.attributes.length;++a){k=c.attributes[a];if(k.specified)if(k.name.toLowerCase()==="class")d.className=k.value;else d.setAttribute(k.name,k.value)}d.innerHTML=p;c.parentNode.replaceChild(d,c)}else c.innerHTML=p}}}}if(q<o.length)setTimeout(f,250);else b&&b()}for(var i=[document.getElementsByTagName("pre"),
|
1091
|
-
document.getElementsByTagName("code"),document.getElementsByTagName("xmp")],o=[],l=0;l<i.length;++l)for(var n=0,r=i[l].length;n<r;++n)o.push(i[l][n]);i=null;var j=Date;j.now||(j={now:function(){return(new Date).getTime()}});var q=0,m;f()};window.PR={combinePrefixPatterns:O,createSimpleLexer:B,registerLangHandler:u,sourceDecorator:x,PR_ATTRIB_NAME:"atn",PR_ATTRIB_VALUE:"atv",PR_COMMENT:C,PR_DECLARATION:"dec",PR_KEYWORD:R,PR_LITERAL:J,PR_NOCODE:V,PR_PLAIN:z,PR_PUNCTUATION:E,PR_SOURCE:P,PR_STRING:A,
|
1092
|
-
PR_TAG:"tag",PR_TYPE:S}})()
|
1093
|
-
|
1094
|
-
;
|
1095
|
-
|
1096
|
-
// lang-sql.js
|
1097
|
-
// http://code.google.com/p/google-code-prettify/
|
1098
|
-
|
1099
|
-
PR.registerLangHandler(PR.createSimpleLexer([["pln",/^[\t\n\r \xA0]+/,null,"\t\n\r \u00a0"],["str",/^(?:"(?:[^\"\\]|\\.)*"|'(?:[^\'\\]|\\.)*')/,null,"\"'"]],[["com",/^(?:--[^\r\n]*|\/\*[\s\S]*?(?:\*\/|$))/],["kwd",/^(?:ADD|ALL|ALTER|AND|ANY|AS|ASC|AUTHORIZATION|BACKUP|BEGIN|BETWEEN|BREAK|BROWSE|BULK|BY|CASCADE|CASE|CHECK|CHECKPOINT|CLOSE|CLUSTERED|COALESCE|COLLATE|COLUMN|COMMIT|COMPUTE|CONSTRAINT|CONTAINS|CONTAINSTABLE|CONTINUE|CONVERT|CREATE|CROSS|CURRENT|CURRENT_DATE|CURRENT_TIME|CURRENT_TIMESTAMP|CURRENT_USER|CURSOR|DATABASE|DBCC|DEALLOCATE|DECLARE|DEFAULT|DELETE|DENY|DESC|DISK|DISTINCT|DISTRIBUTED|DOUBLE|DROP|DUMMY|DUMP|ELSE|END|ERRLVL|ESCAPE|EXCEPT|EXEC|EXECUTE|EXISTS|EXIT|FETCH|FILE|FILLFACTOR|FOR|FOREIGN|FREETEXT|FREETEXTTABLE|FROM|FULL|FUNCTION|GOTO|GRANT|GROUP|HAVING|HOLDLOCK|IDENTITY|IDENTITYCOL|IDENTITY_INSERT|IF|IN|INDEX|INNER|INSERT|INTERSECT|INTO|IS|JOIN|KEY|KILL|LEFT|LIKE|LINENO|LOAD|NATIONAL|NOCHECK|NONCLUSTERED|NOT|NULL|NULLIF|OF|OFF|OFFSETS|ON|OPEN|OPENDATASOURCE|OPENQUERY|OPENROWSET|OPENXML|OPTION|OR|ORDER|OUTER|OVER|PERCENT|PLAN|PRECISION|PRIMARY|PRINT|PROC|PROCEDURE|PUBLIC|RAISERROR|READ|READTEXT|RECONFIGURE|REFERENCES|REPLICATION|RESTORE|RESTRICT|RETURN|REVOKE|RIGHT|ROLLBACK|ROWCOUNT|ROWGUIDCOL|RULE|SAVE|SCHEMA|SELECT|SESSION_USER|SET|SETUSER|SHUTDOWN|SOME|STATISTICS|SYSTEM_USER|TABLE|TEXTSIZE|THEN|TO|TOP|TRAN|TRANSACTION|TRIGGER|TRUNCATE|TSEQUAL|UNION|UNIQUE|UPDATE|UPDATETEXT|USE|USER|VALUES|VARYING|VIEW|WAITFOR|WHEN|WHERE|WHILE|WITH|WRITETEXT)(?=[^\w-]|$)/i,
|
1100
|
-
null],["lit",/^[+-]?(?:0x[\da-f]+|(?:(?:\.\d+|\d+(?:\.\d*)?)(?:e[+\-]?\d+)?))/i],["pln",/^[a-z_][\w-]*/i],["pun",/^[^\w\t\n\r \xA0\"\'][^\w\t\n\r \xA0+\-\"\']*/]]),["sql"])
|
1101
|
-
|
1102
|
-
;
|
1513
|
+
if (window.MiniProfiler) {
|
1514
|
+
_MiniProfiler.patchesApplied = window.MiniProfiler.patchesApplied;
|
1103
1515
|
}
|
1516
|
+
window.MiniProfiler = _MiniProfiler;
|
1517
|
+
_MiniProfiler.init();
|