rack-mini-profiler 0.10.6 → 2.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/CHANGELOG.md +129 -16
- data/README.md +116 -63
- data/lib/enable_rails_patches.rb +5 -0
- data/lib/generators/rack_profiler/install_generator.rb +2 -0
- data/lib/generators/rack_profiler/templates/rack_profiler.rb +2 -0
- data/lib/html/dot.1.1.2.min.js +2 -0
- data/lib/html/includes.css +141 -40
- data/lib/html/includes.js +1398 -970
- data/lib/html/includes.scss +547 -442
- data/lib/html/includes.tmpl +227 -142
- 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/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 +27 -16
- data/lib/mini_profiler/config.rb +73 -46
- data/lib/mini_profiler/context.rb +5 -3
- data/lib/mini_profiler/gc_profiler.rb +17 -16
- data/lib/mini_profiler/profiler.rb +332 -94
- data/lib/mini_profiler/profiling_methods.rb +20 -15
- data/lib/mini_profiler/snapshots_transporter.rb +109 -0
- data/lib/mini_profiler/storage/abstract_store.rb +80 -0
- data/lib/mini_profiler/storage/file_store.rb +18 -13
- data/lib/mini_profiler/storage/memcache_store.rb +10 -7
- data/lib/mini_profiler/storage/memory_store.rb +63 -13
- data/lib/mini_profiler/storage/redis_store.rb +143 -7
- data/lib/mini_profiler/timer_struct/base.rb +4 -2
- data/lib/mini_profiler/timer_struct/client.rb +9 -8
- data/lib/mini_profiler/timer_struct/custom.rb +8 -5
- data/lib/mini_profiler/timer_struct/page.rb +79 -24
- data/lib/mini_profiler/timer_struct/request.rb +83 -38
- data/lib/mini_profiler/timer_struct/sql.rb +25 -22
- data/lib/mini_profiler/version.rb +3 -1
- data/lib/mini_profiler_rails/railtie.rb +91 -8
- data/lib/mini_profiler_rails/railtie_methods.rb +61 -0
- data/lib/patches/db/activerecord.rb +5 -14
- data/lib/patches/db/mongo.rb +3 -1
- data/lib/patches/db/moped.rb +5 -3
- data/lib/patches/db/mysql2.rb +8 -6
- data/lib/patches/db/neo4j.rb +3 -1
- data/lib/patches/db/nobrainer.rb +4 -2
- data/lib/patches/db/oracle_enhanced.rb +4 -2
- data/lib/patches/db/pg.rb +41 -21
- data/lib/patches/db/plucky.rb +7 -5
- data/lib/patches/db/riak.rb +15 -13
- data/lib/patches/db/rsolr.rb +6 -4
- data/lib/patches/db/sequel.rb +2 -0
- data/lib/patches/net_patches.rb +20 -8
- data/lib/patches/sql_patches.rb +17 -7
- data/lib/prepend_net_http_patch.rb +5 -0
- data/lib/rack-mini-profiler.rb +3 -3
- data/rack-mini-profiler.gemspec +23 -9
- metadata +146 -31
- 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,1063 +1,1491 @@
|
|
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
|
-
;
|
16
|
-
|
17
|
-
var hasLocalStorage = function (keyPrefix) {
|
18
|
-
try {
|
19
|
-
// attempt to save to localStorage as Safari private windows will throw an error
|
20
|
-
localStorage[keyPrefix+'-test'] = '1';
|
21
|
-
localStorage.removeItem(keyPrefix+'-test');
|
22
|
-
return 'localStorage' in window && window['localStorage'] !== null ;
|
23
|
-
} catch (e) {
|
24
|
-
return false;
|
25
|
-
}
|
26
|
-
};
|
27
|
-
|
28
|
-
var getVersionedKey = function (keyPrefix) {
|
29
|
-
return keyPrefix + '-' + options.version;
|
30
|
-
};
|
31
|
-
|
32
|
-
var save = function (keyPrefix, value) {
|
33
|
-
if (!hasLocalStorage(keyPrefix)) { return; }
|
34
2
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
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();
|
40
100
|
}
|
41
101
|
|
42
|
-
|
43
|
-
|
44
|
-
};
|
102
|
+
mPt.flush();
|
103
|
+
}
|
45
104
|
|
46
|
-
|
47
|
-
|
105
|
+
if (id == options.currentId) {
|
106
|
+
clientPerformance = getClientPerformance();
|
48
107
|
|
49
|
-
|
50
|
-
|
108
|
+
if (clientPerformance !== null) {
|
109
|
+
// ie is buggy strip out functions
|
110
|
+
var copy = {
|
111
|
+
navigation: {},
|
112
|
+
timing: clientPerformance.timing.toJSON()
|
113
|
+
};
|
51
114
|
|
52
|
-
|
53
|
-
|
54
|
-
|
115
|
+
if (clientPerformance.navigation) {
|
116
|
+
copy.navigation.redirectCount =
|
117
|
+
clientPerformance.navigation.redirectCount;
|
118
|
+
}
|
55
119
|
|
56
|
-
|
57
|
-
$('body').append(cached);
|
58
|
-
success();
|
59
|
-
}
|
60
|
-
else {
|
61
|
-
$.get(options.path + 'includes.tmpl?v=' + options.version, function (data) {
|
62
|
-
if (data) {
|
63
|
-
save(key, data);
|
64
|
-
$('body').append(data);
|
65
|
-
success();
|
66
|
-
}
|
67
|
-
}, "text");
|
120
|
+
clientPerformance = copy;
|
68
121
|
}
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
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);
|
80
149
|
|
81
|
-
|
82
|
-
|
150
|
+
request.onload = function() {
|
151
|
+
if (request.status >= 200 && request.status < 400) {
|
152
|
+
var json = JSON.parse(request.responseText);
|
153
|
+
fetchedIds.push(id);
|
83
154
|
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
clientProbes[j].d = clientProbes[j].d.getTime();
|
88
|
-
}
|
89
|
-
mPt.flush();
|
155
|
+
if (json != "hidden" && MiniProfiler.templates) {
|
156
|
+
buttonShow(json);
|
157
|
+
}
|
90
158
|
}
|
91
159
|
|
92
|
-
|
93
|
-
|
94
|
-
clientPerformance = getClientPerformance();
|
95
|
-
|
96
|
-
if (clientPerformance !== null) {
|
97
|
-
// ie is buggy strip out functions
|
98
|
-
var copy = { navigation: {}, timing: {} };
|
99
|
-
|
100
|
-
var timing = $.extend({}, clientPerformance.timing);
|
101
|
-
|
102
|
-
for (p in timing) {
|
103
|
-
if (timing.hasOwnProperty(p) && !$.isFunction(timing[p])) {
|
104
|
-
copy.timing[p] = timing[p];
|
105
|
-
}
|
106
|
-
}
|
107
|
-
if (clientPerformance.navigation) {
|
108
|
-
copy.navigation.redirectCount = clientPerformance.navigation.redirectCount;
|
109
|
-
}
|
110
|
-
clientPerformance = copy;
|
111
|
-
|
112
|
-
// hack to add chrome timings
|
113
|
-
if (window.chrome && window.chrome.loadTimes) {
|
114
|
-
var chromeTimes = window.chrome.loadTimes();
|
115
|
-
if (chromeTimes.firstPaintTime) {
|
116
|
-
clientPerformance.timing["First Paint Time"] = Math.round(chromeTimes.firstPaintTime * 1000);
|
117
|
-
}
|
118
|
-
if (chromeTimes.firstPaintTime) {
|
119
|
-
clientPerformance.timing["First Paint After Load Time"] = Math.round(chromeTimes.firstPaintAfterLoadTime * 1000);
|
120
|
-
}
|
121
|
-
|
122
|
-
}
|
123
|
-
}
|
124
|
-
} else if (ajaxStartTime !== null && clientProbes && clientProbes.length > 0) {
|
125
|
-
clientPerformance = { timing: { navigationStart: ajaxStartTime.getTime() } };
|
126
|
-
ajaxStartTime = null;
|
127
|
-
}
|
160
|
+
fetchingIds.splice(idx, 1);
|
161
|
+
};
|
128
162
|
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
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());
|
149
200
|
}
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
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");
|
176
228
|
}
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
var button = result.find('.profiler-button'),
|
192
|
-
popup = result.find('.profiler-popup');
|
193
|
-
|
194
|
-
// button will appear in corner with the total profiling duration - click to show details
|
195
|
-
button.click(function () { buttonClick(button, popup); });
|
196
|
-
|
197
|
-
// small duration steps and the column with aggregate durations are hidden by default; allow toggling
|
198
|
-
toggleHidden(popup);
|
199
|
-
|
200
|
-
// lightbox in the queries
|
201
|
-
popup.find('.profiler-queries-show').click(function () { queriesShow($(this), result); });
|
202
|
-
|
203
|
-
// limit count
|
204
|
-
if (container.find('.profiler-result').length > options.maxTracesToShow)
|
205
|
-
container.find('.profiler-result').first().remove();
|
206
|
-
button.show();
|
207
|
-
};
|
208
|
-
|
209
|
-
var toggleHidden = function (popup) {
|
210
|
-
var trivial = popup.find('.profiler-toggle-trivial');
|
211
|
-
var childrenTime = popup.find('.profiler-toggle-duration-with-children');
|
212
|
-
var trivialGaps = popup.parent().find('.profiler-toggle-trivial-gaps');
|
213
|
-
|
214
|
-
var toggleIt = function (node) {
|
215
|
-
var link = $(node),
|
216
|
-
klass = "profiler-" + link.attr('class').substr('profiler-toggle-'.length),
|
217
|
-
isHidden = link.text().indexOf('show') > -1;
|
218
|
-
|
219
|
-
popup.parent().find('.' + klass).toggle(isHidden);
|
220
|
-
link.text(link.text().replace(isHidden ? 'show' : 'hide', isHidden ? 'hide' : 'show'));
|
221
|
-
|
222
|
-
popupPreventHorizontalScroll(popup);
|
223
|
-
};
|
224
|
-
|
225
|
-
childrenTime.add(trivial).add(trivialGaps).click(function () {
|
226
|
-
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;
|
227
243
|
});
|
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
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
var
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
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);
|
312
334
|
};
|
313
335
|
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
// ensure they're in view
|
319
|
-
whatToScroll.scrollTop(whatToScroll.scrollTop() + cells.first().position().top - 100);
|
320
|
-
|
321
|
-
// 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
|
322
|
-
cells.each(function () {
|
323
|
-
var cell = $(this),
|
324
|
-
highlightHex = '#FFFFBB',
|
325
|
-
highlightRgb = getRGB(highlightHex),
|
326
|
-
originalRgb = getRGB(cell.css('background-color')),
|
327
|
-
getColorDiff = function (fx, i) {
|
328
|
-
// adapted from John Resig's color plugin: http://plugins.jquery.com/project/color
|
329
|
-
return Math.max(Math.min(parseInt((fx.pos * (originalRgb[i] - highlightRgb[i])) + highlightRgb[i], 10), 255), 0);
|
330
|
-
};
|
331
|
-
|
332
|
-
// we need to animate some other property to piggy-back on the step function, so I choose you, opacity!
|
333
|
-
cell.css({ 'opacity': 1, 'background-color': highlightHex })
|
334
|
-
.animate({ 'opacity': 1 }, { duration: 2000, step: function (now, fx) {
|
335
|
-
fx.elem.style.backgroundColor = "rgb(" + [getColorDiff(fx, 0), getColorDiff(fx, 1), getColorDiff(fx, 2)].join(",") + ")";
|
336
|
-
}
|
337
|
-
});
|
336
|
+
[childrenTime, trivial, trivialGaps].forEach(function(el) {
|
337
|
+
if (el) {
|
338
|
+
el.addEventListener("click", function() {
|
339
|
+
toggleIt(this);
|
338
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 - 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");
|
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 onClickEvents = function onClickEvents(e) {
|
499
|
+
// this happens on every keystroke, and :visible is crazy expensive in IE <9
|
500
|
+
// and in this case, the display:none check is sufficient.
|
501
|
+
var popup = toArray(document.querySelectorAll(".profiler-popup")).filter(
|
502
|
+
function(el) {
|
503
|
+
return el.style.display === "block";
|
504
|
+
}
|
505
|
+
);
|
506
|
+
|
507
|
+
if (!popup.length) {
|
508
|
+
return;
|
509
|
+
}
|
510
|
+
|
511
|
+
popup = popup[0];
|
512
|
+
var button = popup.parentNode.querySelector(".profiler-button"),
|
513
|
+
queries = elementClosest(popup, ".profiler-result").querySelector(
|
514
|
+
".profiler-queries"
|
515
|
+
),
|
516
|
+
bg = document.querySelector(".profiler-queries-bg"),
|
517
|
+
isEscPress = e.type == "keyup" && e.which == 27,
|
518
|
+
hidePopup = false,
|
519
|
+
hideQueries = false;
|
520
|
+
|
521
|
+
if (bg && bg.style.display === "block") {
|
522
|
+
hideQueries =
|
523
|
+
isEscPress ||
|
524
|
+
(e.type == "click" &&
|
525
|
+
!(queries !== e.target && queries.contains(e.target)) &&
|
526
|
+
!(popup !== e.target && popup.contains(e.target)));
|
527
|
+
} else if (popup.style.display === "block") {
|
528
|
+
hidePopup =
|
529
|
+
isEscPress ||
|
530
|
+
(e.type == "click" &&
|
531
|
+
!(popup !== e.target && popup.contains(e.target)) &&
|
532
|
+
!(button !== e.target && button.contains(e.target)) &&
|
533
|
+
button != e.target);
|
534
|
+
}
|
535
|
+
|
536
|
+
if (hideQueries) {
|
537
|
+
bg.parentElement.removeChild(bg);
|
538
|
+
queries.style.display = "none";
|
539
|
+
}
|
540
|
+
|
541
|
+
if (hidePopup) {
|
542
|
+
popupHide(button, popup);
|
543
|
+
}
|
544
|
+
};
|
545
|
+
|
546
|
+
var keydownEvent = function keydownEvent() {
|
547
|
+
var results = document.querySelector(".profiler-results");
|
548
|
+
|
549
|
+
if (results.style.display === "none") {
|
550
|
+
results.style.display = "block";
|
551
|
+
} else {
|
552
|
+
results.style.display = "none";
|
553
|
+
}
|
554
|
+
|
555
|
+
sessionStorage["rack-mini-profiler-start-hidden"] =
|
556
|
+
results.style.display === "none";
|
557
|
+
};
|
558
|
+
|
559
|
+
var toggleShortcutEvent = function toggleShortcutEvent(e) {
|
560
|
+
// simplified version of https://github.com/jeresig/jquery.hotkeys/blob/master/jquery.hotkeys.js
|
561
|
+
var shortcut = options.toggleShortcut.toLowerCase();
|
562
|
+
var modifier = "";
|
563
|
+
["alt", "ctrl", "shift"].forEach(function(k) {
|
564
|
+
if (e[k + "Key"]) {
|
565
|
+
modifier += "".concat(k, "+");
|
566
|
+
}
|
567
|
+
});
|
568
|
+
var specialKeys = {
|
569
|
+
8: "backspace",
|
570
|
+
9: "tab",
|
571
|
+
10: "return",
|
572
|
+
13: "return",
|
573
|
+
16: "shift",
|
574
|
+
17: "ctrl",
|
575
|
+
18: "alt",
|
576
|
+
27: "esc",
|
577
|
+
32: "space",
|
578
|
+
59: ";",
|
579
|
+
61: "=",
|
580
|
+
96: "0",
|
581
|
+
97: "1",
|
582
|
+
98: "2",
|
583
|
+
99: "3",
|
584
|
+
100: "4",
|
585
|
+
101: "5",
|
586
|
+
102: "6",
|
587
|
+
103: "7",
|
588
|
+
104: "8",
|
589
|
+
105: "9",
|
590
|
+
106: "*",
|
591
|
+
107: "+",
|
592
|
+
109: "-",
|
593
|
+
110: ".",
|
594
|
+
173: "-",
|
595
|
+
186: ";",
|
596
|
+
187: "="
|
339
597
|
};
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
// Look for #fff
|
361
|
-
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)];
|
362
|
-
|
363
|
-
// Look for rgba(0, 0, 0, 0) == transparent in Safari 3
|
364
|
-
if (result = /rgba\(0, 0, 0, 0\)/.exec(color)) return [0,0,0,0];
|
365
|
-
|
366
|
-
return null;
|
598
|
+
var shiftNums = {
|
599
|
+
"`": "~",
|
600
|
+
"1": "!",
|
601
|
+
"2": "@",
|
602
|
+
"3": "#",
|
603
|
+
"4": "$",
|
604
|
+
"5": "%",
|
605
|
+
"6": "^",
|
606
|
+
"7": "&",
|
607
|
+
"8": "*",
|
608
|
+
"9": "(",
|
609
|
+
"0": ")",
|
610
|
+
"-": "_",
|
611
|
+
"=": "+",
|
612
|
+
";": ": ",
|
613
|
+
"'": '"',
|
614
|
+
",": "<",
|
615
|
+
".": ">",
|
616
|
+
"/": "?",
|
617
|
+
"\\": "|"
|
367
618
|
};
|
368
|
-
|
369
|
-
var
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
619
|
+
var character = String.fromCharCode(e.which).toLowerCase();
|
620
|
+
var special = specialKeys[e.which];
|
621
|
+
var keys = [];
|
622
|
+
|
623
|
+
if (special) {
|
624
|
+
keys.push(special);
|
625
|
+
} else {
|
626
|
+
keys.push(character);
|
627
|
+
keys.push(shiftNums[character]);
|
628
|
+
}
|
629
|
+
|
630
|
+
for (var i = 0; i < keys.length; i++) {
|
631
|
+
if (modifier + keys[i] === shortcut) {
|
632
|
+
keydownEvent();
|
633
|
+
break;
|
634
|
+
}
|
635
|
+
}
|
636
|
+
};
|
637
|
+
|
638
|
+
var turbolinksSkipResultsFetch = function turbolinksSkipResultsFetch(event) {
|
639
|
+
event.data.xhr.__miniProfilerSkipResultsFetch = true;
|
640
|
+
};
|
641
|
+
|
642
|
+
var bindDocumentEvents = function bindDocumentEvents() {
|
643
|
+
document.addEventListener("click", onClickEvents);
|
644
|
+
document.addEventListener("keyup", onClickEvents);
|
645
|
+
document.addEventListener("keyup", toggleShortcutEvent);
|
646
|
+
|
647
|
+
if (typeof Turbolinks !== "undefined" && Turbolinks.supported) {
|
648
|
+
document.addEventListener("page:change", unbindDocumentEvents);
|
649
|
+
document.addEventListener("turbolinks:load", unbindDocumentEvents);
|
650
|
+
document.addEventListener(
|
651
|
+
"turbolinks:request-start",
|
652
|
+
turbolinksSkipResultsFetch
|
653
|
+
);
|
654
|
+
}
|
655
|
+
};
|
656
|
+
|
657
|
+
var unbindDocumentEvents = function unbindDocumentEvents() {
|
658
|
+
document.removeEventListener("click", onClickEvents);
|
659
|
+
document.removeEventListener("keyup", onClickEvents);
|
660
|
+
document.removeEventListener("keyup", toggleShortcutEvent);
|
661
|
+
document.removeEventListener("page:change", unbindDocumentEvents);
|
662
|
+
document.removeEventListener("turbolinks:load", unbindDocumentEvents);
|
663
|
+
document.removeEventListener(
|
664
|
+
"turbolinks:request-start",
|
665
|
+
turbolinksSkipResultsFetch
|
666
|
+
);
|
667
|
+
};
|
668
|
+
|
669
|
+
var initFullView = function initFullView() {
|
670
|
+
// profiler will be defined in the full page's head
|
671
|
+
container[0].appendChild(renderTemplate(profiler));
|
672
|
+
var popup = document.querySelector(".profiler-popup");
|
673
|
+
toggleHidden(popup);
|
674
|
+
prettyPrint(); // since queries are already shown, just highlight and scroll when clicking a "1 sql" link
|
675
|
+
|
676
|
+
toArray(popup.querySelectorAll(".profiler-queries-show")).forEach(function(
|
677
|
+
el
|
678
|
+
) {
|
679
|
+
el.addEventListener("click", function() {
|
680
|
+
queriesScrollIntoView(
|
681
|
+
this,
|
682
|
+
document.querySelector(".profiler-queries"),
|
683
|
+
document.body
|
684
|
+
);
|
685
|
+
});
|
686
|
+
});
|
687
|
+
};
|
688
|
+
|
689
|
+
var initSnapshots = function initSnapshots(dataElement) {
|
690
|
+
var data = JSON.parse(dataElement.textContent);
|
691
|
+
var temp = document.createElement("DIV");
|
692
|
+
if (data.page === "overview") {
|
693
|
+
temp.innerHTML = MiniProfiler.templates.snapshotsGroupsList(data);
|
694
|
+
} else if (data.group_name) {
|
695
|
+
var allCustomFieldsNames = [];
|
696
|
+
data.list.forEach(function(snapshot) {
|
697
|
+
Object.keys(snapshot.custom_fields).forEach(function(k) {
|
698
|
+
if (
|
699
|
+
allCustomFieldsNames.indexOf(k) === -1 &&
|
700
|
+
options.hiddenCustomFields.indexOf(k.toLowerCase()) === -1
|
701
|
+
) {
|
702
|
+
allCustomFieldsNames.push(k);
|
703
|
+
}
|
704
|
+
});
|
705
|
+
});
|
706
|
+
allCustomFieldsNames.sort();
|
707
|
+
temp.innerHTML = MiniProfiler.templates.snapshotsList({
|
708
|
+
data: data,
|
709
|
+
allCustomFieldsNames: allCustomFieldsNames
|
710
|
+
});
|
711
|
+
}
|
712
|
+
Array.from(temp.children).forEach(function(child) {
|
713
|
+
document.body.appendChild(child);
|
714
|
+
});
|
715
|
+
};
|
716
|
+
|
717
|
+
var initControls = function initControls(container) {
|
718
|
+
if (options.showControls) {
|
719
|
+
var _controls = document.createElement("div");
|
720
|
+
|
721
|
+
_controls.classList.add("profiler-controls");
|
722
|
+
|
723
|
+
_controls.innerHTML =
|
724
|
+
'<span class="profiler-min-max">m</span><span class="profiler-clear">c</span>';
|
725
|
+
container.appendChild(_controls);
|
726
|
+
document
|
727
|
+
.querySelector(".profiler-controls .profiler-min-max")
|
728
|
+
.addEventListener("click", function() {
|
729
|
+
return toggleClass(container, "profiler-min");
|
730
|
+
});
|
731
|
+
container.addEventListener("mouseenter", function() {
|
732
|
+
if (this.classList.contains("profiler-min")) {
|
733
|
+
this.querySelector(".profiler-min-max").style.display = "block";
|
734
|
+
}
|
735
|
+
});
|
736
|
+
container.addEventListener("mouseleave", function() {
|
737
|
+
if (this.classList.contains("profiler-min")) {
|
738
|
+
this.querySelector(".profiler-min-max").style.display = "none";
|
739
|
+
}
|
740
|
+
});
|
741
|
+
document
|
742
|
+
.querySelector(".profiler-controls .profiler-clear")
|
743
|
+
.addEventListener("click", function() {
|
744
|
+
toArray(container.querySelectorAll(".profiler-result")).forEach(
|
745
|
+
function(el) {
|
746
|
+
return el.parentElement.removeChild(el);
|
378
747
|
}
|
748
|
+
);
|
749
|
+
});
|
750
|
+
} else {
|
751
|
+
container.classList.add("profiler-no-controls");
|
752
|
+
}
|
753
|
+
};
|
754
|
+
|
755
|
+
var toggleClass = function toggleClass(el, className) {
|
756
|
+
if (el.classList) {
|
757
|
+
el.classList.toggle(className);
|
758
|
+
} else {
|
759
|
+
var classes = el.className.split(" ");
|
760
|
+
var existingIndex = classes.indexOf(className);
|
761
|
+
if (existingIndex >= 0) classes.splice(existingIndex, 1);
|
762
|
+
else classes.push(className);
|
763
|
+
el.className = classes.join(" ");
|
764
|
+
}
|
765
|
+
};
|
766
|
+
|
767
|
+
var initPopupView = function initPopupView() {
|
768
|
+
if (options.authorized) {
|
769
|
+
// all fetched profilings will go in here
|
770
|
+
container = document.createElement("div");
|
771
|
+
container.className = "profiler-results";
|
772
|
+
document.querySelector(options.htmlContainer).appendChild(container); // MiniProfiler.RenderIncludes() sets which corner to render in - default is upper left
|
773
|
+
|
774
|
+
container.classList.add("profiler-" + options.renderHorizontalPosition);
|
775
|
+
container.classList.add("profiler-" + options.renderVerticalPosition); //initialize the controls
|
776
|
+
|
777
|
+
initControls(container);
|
778
|
+
fetchResults(options.ids);
|
779
|
+
|
780
|
+
if (options.startHidden) container.style.display = "none";
|
781
|
+
} else {
|
782
|
+
fetchResults(options.ids);
|
783
|
+
}
|
784
|
+
|
785
|
+
if (!window.MiniProfiler || !window.MiniProfiler.patchesApplied) {
|
786
|
+
var send = XMLHttpRequest.prototype.send;
|
787
|
+
|
788
|
+
XMLHttpRequest.prototype.send = function(data) {
|
789
|
+
ajaxStartTime = new Date();
|
790
|
+
this.addEventListener("load", function() {
|
791
|
+
// responseURL isn't available in IE11
|
792
|
+
if (
|
793
|
+
this.responseURL &&
|
794
|
+
this.responseURL.indexOf(window.location.origin) !== 0
|
795
|
+
) {
|
796
|
+
return;
|
797
|
+
}
|
798
|
+
if (this.__miniProfilerSkipResultsFetch) {
|
799
|
+
return;
|
800
|
+
}
|
801
|
+
// getAllResponseHeaders isn't available in Edge.
|
802
|
+
var allHeaders = this.getAllResponseHeaders
|
803
|
+
? this.getAllResponseHeaders()
|
804
|
+
: null;
|
805
|
+
if (
|
806
|
+
allHeaders &&
|
807
|
+
allHeaders.toLowerCase().indexOf("x-miniprofiler-ids") === -1
|
808
|
+
) {
|
809
|
+
return;
|
810
|
+
}
|
811
|
+
// should be a string of comma-separated ids
|
812
|
+
var stringIds = this.getResponseHeader("X-MiniProfiler-Ids");
|
379
813
|
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
814
|
+
if (stringIds) {
|
815
|
+
var ids = stringIds.split(",");
|
816
|
+
fetchResults(ids);
|
817
|
+
}
|
818
|
+
});
|
819
|
+
send.call(this, data);
|
820
|
+
}; // fetch results after ASP Ajax calls
|
821
|
+
|
822
|
+
if (
|
823
|
+
typeof Sys != "undefined" &&
|
824
|
+
typeof Sys.WebForms != "undefined" &&
|
825
|
+
typeof Sys.WebForms.PageRequestManager != "undefined"
|
826
|
+
) {
|
827
|
+
// Get the instance of PageRequestManager.
|
828
|
+
var PageRequestManager = Sys.WebForms.PageRequestManager.getInstance();
|
829
|
+
PageRequestManager.add_endRequest(function(sender, args) {
|
830
|
+
if (args) {
|
831
|
+
var response = args.get_response();
|
832
|
+
|
833
|
+
if (
|
834
|
+
response.get_responseAvailable() &&
|
835
|
+
response._xmlHttpRequest !== null
|
836
|
+
) {
|
837
|
+
var stringIds = args
|
838
|
+
.get_response()
|
839
|
+
.getResponseHeader("X-MiniProfiler-Ids");
|
386
840
|
|
387
|
-
|
388
|
-
|
841
|
+
if (stringIds) {
|
842
|
+
var ids = stringIds.split(",");
|
843
|
+
fetchResults(ids);
|
844
|
+
}
|
389
845
|
}
|
390
|
-
|
391
|
-
|
846
|
+
}
|
847
|
+
});
|
848
|
+
} // more Asp.Net callbacks
|
849
|
+
|
850
|
+
if (typeof WebForm_ExecuteCallback == "function") {
|
851
|
+
WebForm_ExecuteCallback = (function(callbackObject) {
|
852
|
+
// Store original function
|
853
|
+
var original = WebForm_ExecuteCallback;
|
854
|
+
return function(callbackObject) {
|
855
|
+
original(callbackObject);
|
856
|
+
var stringIds = callbackObject.xmlRequest.getResponseHeader(
|
857
|
+
"X-MiniProfiler-Ids"
|
858
|
+
);
|
859
|
+
|
860
|
+
if (stringIds) {
|
861
|
+
var ids = stringIds.split(",");
|
862
|
+
fetchResults(ids);
|
392
863
|
}
|
864
|
+
};
|
865
|
+
})();
|
866
|
+
} // also fetch results after ExtJS requests, in case it is being used
|
867
|
+
|
868
|
+
if (
|
869
|
+
typeof Ext != "undefined" &&
|
870
|
+
typeof Ext.Ajax != "undefined" &&
|
871
|
+
typeof Ext.Ajax.on != "undefined"
|
872
|
+
) {
|
873
|
+
// Ext.Ajax is a singleton, so we just have to attach to its 'requestcomplete' event
|
874
|
+
Ext.Ajax.on("requestcomplete", function(e, xhr, settings) {
|
875
|
+
//iframed file uploads don't have headers
|
876
|
+
if (!xhr || !xhr.getResponseHeader) {
|
877
|
+
return;
|
878
|
+
}
|
393
879
|
|
394
|
-
|
395
|
-
bg.remove();
|
396
|
-
queries.hide();
|
397
|
-
}
|
880
|
+
var stringIds = xhr.getResponseHeader("X-MiniProfiler-Ids");
|
398
881
|
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
$(document).on('keydown.mini-profiler', null, options.toggleShortcut, function(e) {
|
404
|
-
$('.profiler-results').toggle();
|
882
|
+
if (stringIds) {
|
883
|
+
var ids = stringIds.split(",");
|
884
|
+
fetchResults(ids);
|
885
|
+
}
|
405
886
|
});
|
887
|
+
}
|
406
888
|
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
}
|
412
|
-
};
|
413
|
-
|
414
|
-
var unbindDocumentEvents = function() {
|
415
|
-
$(document).off('.mini-profiler');
|
416
|
-
};
|
417
|
-
|
418
|
-
var initFullView = function () {
|
419
|
-
|
420
|
-
// first, get jquery tmpl, then render and bind handlers
|
421
|
-
fetchTemplates(function () {
|
422
|
-
|
423
|
-
// profiler will be defined in the full page's head
|
424
|
-
renderTemplate(profiler).appendTo(container);
|
425
|
-
|
426
|
-
var popup = $('.profiler-popup');
|
427
|
-
|
428
|
-
toggleHidden(popup);
|
889
|
+
if (typeof MooTools != "undefined" && typeof Request != "undefined") {
|
890
|
+
Request.prototype.addEvents({
|
891
|
+
onComplete: function onComplete() {
|
892
|
+
var stringIds = this.xhr.getResponseHeader("X-MiniProfiler-Ids");
|
429
893
|
|
430
|
-
|
431
|
-
|
432
|
-
|
433
|
-
|
434
|
-
|
435
|
-
});
|
894
|
+
if (stringIds) {
|
895
|
+
var ids = stringIds.split(",");
|
896
|
+
fetchResults(ids);
|
897
|
+
}
|
898
|
+
}
|
436
899
|
});
|
437
|
-
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
|
900
|
+
} // add support for AngularJS, which use the basic XMLHttpRequest object.
|
901
|
+
|
902
|
+
if (window.angular && typeof XMLHttpRequest != "undefined") {
|
903
|
+
var _send = XMLHttpRequest.prototype.send;
|
904
|
+
|
905
|
+
XMLHttpRequest.prototype.send = function sendReplacement(data) {
|
906
|
+
if (this.onreadystatechange) {
|
907
|
+
if (
|
908
|
+
typeof this.miniprofiler == "undefined" ||
|
909
|
+
typeof this.miniprofiler.prev_onreadystatechange == "undefined"
|
910
|
+
) {
|
911
|
+
this.miniprofiler = {
|
912
|
+
prev_onreadystatechange: this.onreadystatechange
|
913
|
+
};
|
914
|
+
|
915
|
+
this.onreadystatechange = function onReadyStateChangeReplacement() {
|
916
|
+
if (this.readyState == 4) {
|
917
|
+
var stringIds = this.getResponseHeader("X-MiniProfiler-Ids");
|
918
|
+
|
919
|
+
if (stringIds) {
|
920
|
+
var ids = stringIds.split(",");
|
921
|
+
fetchResults(ids);
|
922
|
+
}
|
923
|
+
}
|
442
924
|
|
443
|
-
|
444
|
-
|
445
|
-
|
925
|
+
if (this.miniprofiler.prev_onreadystatechange !== null)
|
926
|
+
return this.miniprofiler.prev_onreadystatechange.apply(
|
927
|
+
this,
|
928
|
+
arguments
|
929
|
+
);
|
930
|
+
};
|
931
|
+
}
|
932
|
+
}
|
446
933
|
|
447
|
-
|
448
|
-
|
449
|
-
|
934
|
+
return _send.apply(this, arguments);
|
935
|
+
};
|
936
|
+
} // https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API
|
937
|
+
|
938
|
+
if (typeof window.fetch === "function") {
|
939
|
+
var __originalFetch = window.fetch;
|
940
|
+
|
941
|
+
window.fetch = function(input, init) {
|
942
|
+
var originalFetchRun = __originalFetch(input, init);
|
943
|
+
|
944
|
+
originalFetchRun.then(function(response) {
|
945
|
+
try {
|
946
|
+
// look for x-mini-profile-ids
|
947
|
+
var entries = response.headers.entries();
|
948
|
+
var _iteratorNormalCompletion = true;
|
949
|
+
var _didIteratorError = false;
|
950
|
+
var _iteratorError = undefined;
|
951
|
+
|
952
|
+
try {
|
953
|
+
for (
|
954
|
+
var _iterator = entries[Symbol.iterator](), _step;
|
955
|
+
!(_iteratorNormalCompletion = (_step = _iterator.next())
|
956
|
+
.done);
|
957
|
+
_iteratorNormalCompletion = true
|
958
|
+
) {
|
959
|
+
var pair = _step.value;
|
960
|
+
|
961
|
+
if (
|
962
|
+
pair[0] &&
|
963
|
+
pair[0].toLowerCase() == "x-miniprofiler-ids"
|
964
|
+
) {
|
965
|
+
var ids = pair[1].split(",");
|
966
|
+
fetchResults(ids);
|
967
|
+
}
|
450
968
|
}
|
451
|
-
|
452
|
-
|
453
|
-
|
454
|
-
|
969
|
+
} catch (err) {
|
970
|
+
_didIteratorError = true;
|
971
|
+
_iteratorError = err;
|
972
|
+
} finally {
|
973
|
+
try {
|
974
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
975
|
+
_iterator.return();
|
976
|
+
}
|
977
|
+
} finally {
|
978
|
+
if (_didIteratorError) {
|
979
|
+
throw _iteratorError;
|
980
|
+
}
|
455
981
|
}
|
456
|
-
|
457
|
-
|
458
|
-
|
459
|
-
|
460
|
-
|
461
|
-
|
462
|
-
|
463
|
-
|
982
|
+
}
|
983
|
+
} catch (e) {
|
984
|
+
console.error(e);
|
985
|
+
}
|
986
|
+
});
|
987
|
+
return originalFetchRun;
|
988
|
+
};
|
989
|
+
}
|
990
|
+
window.MiniProfiler.patchesApplied = true;
|
991
|
+
}
|
992
|
+
|
993
|
+
bindDocumentEvents();
|
994
|
+
};
|
995
|
+
|
996
|
+
return {
|
997
|
+
fetchedIds: fetchedIds,
|
998
|
+
fetchingIds: fetchingIds,
|
999
|
+
init: function init() {
|
1000
|
+
var script = document.getElementById("mini-profiler");
|
1001
|
+
if (!script || !script.getAttribute) return;
|
1002
|
+
|
1003
|
+
this.options = options = (function() {
|
1004
|
+
var version = script.getAttribute("data-version");
|
1005
|
+
var path = script.getAttribute("data-path");
|
1006
|
+
var currentId = script.getAttribute("data-current-id");
|
1007
|
+
var ids = script.getAttribute("data-ids");
|
1008
|
+
if (ids) ids = ids.split(",");
|
1009
|
+
var horizontal_position = script.getAttribute(
|
1010
|
+
"data-horizontal-position"
|
1011
|
+
);
|
1012
|
+
var vertical_position = script.getAttribute("data-vertical-position");
|
1013
|
+
var toggleShortcut = script.getAttribute("data-toggle-shortcut");
|
1014
|
+
|
1015
|
+
if (script.getAttribute("data-max-traces")) {
|
1016
|
+
var maxTraces = parseInt(script.getAttribute("data-max-traces"), 10);
|
464
1017
|
}
|
465
|
-
};
|
466
1018
|
|
467
|
-
|
1019
|
+
var collapseResults =
|
1020
|
+
script.getAttribute("data-collapse-results") === "true";
|
1021
|
+
var trivial = script.getAttribute("data-trivial") === "true";
|
1022
|
+
var children = script.getAttribute("data-children") === "true";
|
1023
|
+
var controls = script.getAttribute("data-controls") === "true";
|
1024
|
+
var totalSqlCount =
|
1025
|
+
script.getAttribute("data-total-sql-count") === "true";
|
1026
|
+
var authorized = script.getAttribute("data-authorized") === "true";
|
1027
|
+
var startHidden =
|
1028
|
+
script.getAttribute("data-start-hidden") === "true" ||
|
1029
|
+
sessionStorage["rack-mini-profiler-start-hidden"] === "true";
|
1030
|
+
var htmlContainer = script.getAttribute("data-html-container");
|
1031
|
+
var cssUrl = script.getAttribute("data-css-url");
|
1032
|
+
var hiddenCustomFields = script
|
1033
|
+
.getAttribute("data-hidden-custom-fields")
|
1034
|
+
.toLowerCase()
|
1035
|
+
.split(",");
|
1036
|
+
return {
|
1037
|
+
ids: ids,
|
1038
|
+
path: path,
|
1039
|
+
version: version,
|
1040
|
+
renderHorizontalPosition: horizontal_position,
|
1041
|
+
renderVerticalPosition: vertical_position,
|
1042
|
+
showTrivial: trivial,
|
1043
|
+
showChildrenTime: children,
|
1044
|
+
maxTracesToShow: maxTraces,
|
1045
|
+
showControls: controls,
|
1046
|
+
showTotalSqlCount: totalSqlCount,
|
1047
|
+
currentId: currentId,
|
1048
|
+
authorized: authorized,
|
1049
|
+
toggleShortcut: toggleShortcut,
|
1050
|
+
startHidden: startHidden,
|
1051
|
+
collapseResults: collapseResults,
|
1052
|
+
htmlContainer: htmlContainer,
|
1053
|
+
cssUrl: cssUrl,
|
1054
|
+
hiddenCustomFields: hiddenCustomFields
|
1055
|
+
};
|
1056
|
+
})();
|
468
1057
|
|
469
|
-
|
470
|
-
|
471
|
-
|
1058
|
+
var doInit = function doInit() {
|
1059
|
+
var snapshotsElement = document.getElementById("snapshots-data");
|
1060
|
+
if (snapshotsElement != null) {
|
1061
|
+
initSnapshots(snapshotsElement);
|
1062
|
+
return;
|
1063
|
+
}
|
472
1064
|
|
473
|
-
|
474
|
-
|
475
|
-
container.addClass("profiler-" + options.renderVerticalPosition);
|
1065
|
+
// when rendering a shared, full page, this div will exist
|
1066
|
+
container = document.querySelectorAll(".profiler-result-full");
|
476
1067
|
|
477
|
-
|
478
|
-
|
1068
|
+
if (container.length) {
|
1069
|
+
if (window.location.href.indexOf("&trivial=1") > 0) {
|
1070
|
+
options.showTrivial = true;
|
1071
|
+
}
|
479
1072
|
|
480
|
-
|
481
|
-
|
482
|
-
|
483
|
-
fetchResults(options.ids);
|
484
|
-
});
|
485
|
-
if (options.startHidden) container.hide();
|
486
|
-
}
|
487
|
-
else {
|
488
|
-
fetchResults(options.ids);
|
1073
|
+
initFullView();
|
1074
|
+
} else {
|
1075
|
+
initPopupView();
|
489
1076
|
}
|
490
|
-
|
491
|
-
|
492
|
-
|
493
|
-
|
494
|
-
|
495
|
-
|
496
|
-
|
497
|
-
|
498
|
-
|
1077
|
+
}; // this preserves debugging
|
1078
|
+
|
1079
|
+
var load = function load(s, f) {
|
1080
|
+
var sc = document.createElement("script");
|
1081
|
+
sc.async = "async";
|
1082
|
+
sc.type = "text/javascript";
|
1083
|
+
sc.src = s;
|
1084
|
+
var done = false;
|
1085
|
+
|
1086
|
+
sc.onload = sc.onreadystatechange = function(_, abort) {
|
1087
|
+
if (!sc.readyState || /loaded|complete/.test(sc.readyState)) {
|
1088
|
+
if (!abort && !done) {
|
1089
|
+
done = true;
|
1090
|
+
f();
|
499
1091
|
}
|
1092
|
+
}
|
500
1093
|
};
|
501
1094
|
|
502
|
-
|
503
|
-
|
504
|
-
|
505
|
-
|
1095
|
+
document.getElementsByTagName("head")[0].appendChild(sc);
|
1096
|
+
};
|
1097
|
+
|
1098
|
+
var wait = 0;
|
1099
|
+
var finish = false;
|
1100
|
+
|
1101
|
+
var deferInit = function deferInit() {
|
1102
|
+
if (finish) return;
|
1103
|
+
|
1104
|
+
if (
|
1105
|
+
window.performance &&
|
1106
|
+
window.performance.timing &&
|
1107
|
+
window.performance.timing.loadEventEnd === 0 &&
|
1108
|
+
wait < 10000
|
1109
|
+
) {
|
1110
|
+
setTimeout(deferInit, 100);
|
1111
|
+
wait += 100;
|
1112
|
+
} else {
|
1113
|
+
finish = true;
|
1114
|
+
init();
|
506
1115
|
}
|
1116
|
+
};
|
507
1117
|
|
508
|
-
|
509
|
-
|
510
|
-
|
511
|
-
|
512
|
-
|
513
|
-
|
514
|
-
|
515
|
-
|
516
|
-
|
517
|
-
|
518
|
-
|
519
|
-
|
520
|
-
|
521
|
-
|
522
|
-
var ids = typeof JSON != 'undefined' ? JSON.parse(stringIds) : eval(stringIds);
|
523
|
-
fetchResults(ids);
|
524
|
-
}
|
525
|
-
}
|
526
|
-
}
|
527
|
-
});
|
528
|
-
}
|
529
|
-
|
530
|
-
// more Asp.Net callbacks
|
531
|
-
if (typeof (WebForm_ExecuteCallback) == "function") {
|
532
|
-
WebForm_ExecuteCallback = (function (callbackObject) {
|
533
|
-
// Store original function
|
534
|
-
var original = WebForm_ExecuteCallback;
|
535
|
-
|
536
|
-
return function (callbackObject) {
|
537
|
-
original(callbackObject);
|
538
|
-
|
539
|
-
var stringIds = callbackObject.xmlRequest.getResponseHeader('X-MiniProfiler-Ids');
|
540
|
-
if (stringIds) {
|
541
|
-
var ids = typeof JSON != 'undefined' ? JSON.parse(stringIds) : eval(stringIds);
|
542
|
-
fetchResults(ids);
|
543
|
-
}
|
544
|
-
};
|
1118
|
+
var init = function init() {
|
1119
|
+
if (options.authorized) {
|
1120
|
+
var url = options.cssUrl;
|
1121
|
+
|
1122
|
+
if (document.createStyleSheet) {
|
1123
|
+
document.createStyleSheet(url);
|
1124
|
+
} else {
|
1125
|
+
var head = document.querySelector("head");
|
1126
|
+
var link = document.createElement("link");
|
1127
|
+
link.rel = "stylesheet";
|
1128
|
+
link.type = "text/css";
|
1129
|
+
link.href = url;
|
1130
|
+
head.appendChild(link);
|
1131
|
+
}
|
545
1132
|
|
546
|
-
|
1133
|
+
if (!MiniProfiler.loadedVendor) {
|
1134
|
+
load(options.path + "vendor.js?v=" + options.version, doInit);
|
1135
|
+
} else {
|
1136
|
+
doInit();
|
1137
|
+
}
|
1138
|
+
} else {
|
1139
|
+
doInit();
|
547
1140
|
}
|
548
|
-
|
549
|
-
|
550
|
-
|
551
|
-
|
552
|
-
|
553
|
-
|
554
|
-
|
555
|
-
|
556
|
-
|
557
|
-
|
558
|
-
|
559
|
-
if (stringIds) {
|
560
|
-
var ids = typeof JSON != 'undefined' ? JSON.parse(stringIds) : eval(stringIds);
|
561
|
-
fetchResults(ids);
|
562
|
-
}
|
563
|
-
});
|
1141
|
+
};
|
1142
|
+
|
1143
|
+
deferInit();
|
1144
|
+
},
|
1145
|
+
cleanUp: function cleanUp() {
|
1146
|
+
unbindDocumentEvents();
|
1147
|
+
},
|
1148
|
+
pageTransition: function pageTransition() {
|
1149
|
+
if (totalsControl) {
|
1150
|
+
if (totalsControl.parentElement) {
|
1151
|
+
totalsControl.parentElement.removeChild(totalsControl);
|
564
1152
|
}
|
565
|
-
|
566
|
-
|
567
|
-
|
568
|
-
|
569
|
-
|
570
|
-
|
571
|
-
|
572
|
-
|
573
|
-
|
574
|
-
|
575
|
-
|
1153
|
+
totalsControl = null;
|
1154
|
+
}
|
1155
|
+
|
1156
|
+
reqs = 0;
|
1157
|
+
totalTime = 0;
|
1158
|
+
expandedResults = false;
|
1159
|
+
toArray(
|
1160
|
+
document.querySelectorAll(".profiler-results .profiler-result")
|
1161
|
+
).forEach(function(el) {
|
1162
|
+
return el.parentElement.removeChild(el);
|
1163
|
+
});
|
1164
|
+
},
|
1165
|
+
getClientTimingByName: function getClientTimingByName(clientTiming, name) {
|
1166
|
+
for (var i = 0; i < clientTiming.timings.length; i++) {
|
1167
|
+
if (clientTiming.timings[i].name == name) {
|
1168
|
+
return clientTiming.timings[i];
|
576
1169
|
}
|
1170
|
+
}
|
1171
|
+
|
1172
|
+
return {
|
1173
|
+
Name: name,
|
1174
|
+
Duration: "",
|
1175
|
+
Start: ""
|
1176
|
+
};
|
1177
|
+
},
|
1178
|
+
renderDate: function renderDate(jsonDate) {
|
1179
|
+
// JavaScriptSerializer sends dates as /Date(1308024322065)/
|
1180
|
+
if (jsonDate) {
|
1181
|
+
return typeof jsonDate === "string"
|
1182
|
+
? new Date(
|
1183
|
+
parseInt(jsonDate.replace("/Date(", "").replace(")/", ""), 10)
|
1184
|
+
).toUTCString()
|
1185
|
+
: jsonDate;
|
1186
|
+
}
|
1187
|
+
},
|
1188
|
+
renderIndent: function renderIndent(depth) {
|
1189
|
+
var result = "";
|
1190
|
+
|
1191
|
+
for (var i = 0; i < depth; i++) {
|
1192
|
+
result += " ";
|
1193
|
+
}
|
1194
|
+
|
1195
|
+
return result;
|
1196
|
+
},
|
1197
|
+
renderExecuteType: function renderExecuteType(typeId) {
|
1198
|
+
// see StackExchange.Profiling.ExecuteType enum
|
1199
|
+
switch (typeId) {
|
1200
|
+
case 0:
|
1201
|
+
return "None";
|
1202
|
+
|
1203
|
+
case 1:
|
1204
|
+
return "NonQuery";
|
1205
|
+
|
1206
|
+
case 2:
|
1207
|
+
return "Scalar";
|
1208
|
+
|
1209
|
+
case 3:
|
1210
|
+
return "Reader";
|
1211
|
+
}
|
1212
|
+
},
|
1213
|
+
shareUrl: function shareUrl(id) {
|
1214
|
+
return options.path + "results?id=" + id;
|
1215
|
+
},
|
1216
|
+
moreUrl: function moreUrl(requestName) {
|
1217
|
+
var requestParts = requestName.split(" ");
|
1218
|
+
var linkSrc =
|
1219
|
+
requestParts[0] == "GET" ? requestParts[1] : window.location.href;
|
1220
|
+
var linkSuffix = linkSrc.indexOf("?") > 0 ? "&pp=help" : "?pp=help";
|
1221
|
+
return linkSrc + linkSuffix;
|
1222
|
+
},
|
1223
|
+
getClientTimings: function getClientTimings(clientTimings) {
|
1224
|
+
var list = [];
|
1225
|
+
var t;
|
1226
|
+
if (!clientTimings.timings) return [];
|
1227
|
+
|
1228
|
+
for (var i = 0; i < clientTimings.timings.length; i++) {
|
1229
|
+
t = clientTimings.timings[i];
|
1230
|
+
var trivial = t.Name != "Dom Complete" && t.Name != "Response";
|
1231
|
+
trivial = t.Duration < 2 ? trivial : false;
|
1232
|
+
list.push({
|
1233
|
+
isTrivial: trivial,
|
1234
|
+
name: t.Name,
|
1235
|
+
duration: t.Duration,
|
1236
|
+
start: t.Start
|
1237
|
+
});
|
1238
|
+
} // Use the Paint Timing API for render performance.
|
577
1239
|
|
578
|
-
|
579
|
-
|
580
|
-
var _send = XMLHttpRequest.prototype.send;
|
581
|
-
|
582
|
-
XMLHttpRequest.prototype.send = function sendReplacement(data) {
|
583
|
-
if (this.onreadystatechange) {
|
584
|
-
if (typeof (this.miniprofiler) == 'undefined' || typeof (this.miniprofiler.prev_onreadystatechange) == 'undefined') {
|
585
|
-
this.miniprofiler = { prev_onreadystatechange: this.onreadystatechange };
|
586
|
-
|
587
|
-
this.onreadystatechange = function onReadyStateChangeReplacement() {
|
588
|
-
if (this.readyState == 4) {
|
589
|
-
var stringIds = this.getResponseHeader('X-MiniProfiler-Ids');
|
590
|
-
if (stringIds) {
|
591
|
-
var ids = typeof JSON != 'undefined' ? JSON.parse(stringIds) : eval(stringIds);
|
592
|
-
fetchResults(ids);
|
593
|
-
}
|
594
|
-
}
|
1240
|
+
if (window.performance && window.performance.getEntriesByName) {
|
1241
|
+
var firstPaint = window.performance.getEntriesByName("first-paint");
|
595
1242
|
|
596
|
-
|
597
|
-
|
598
|
-
|
599
|
-
|
600
|
-
|
601
|
-
|
602
|
-
|
603
|
-
};
|
1243
|
+
if (firstPaint !== undefined && firstPaint.length >= 1) {
|
1244
|
+
list.push({
|
1245
|
+
isTrivial: false,
|
1246
|
+
name: "First Paint Time",
|
1247
|
+
duration: firstPaint[0].duration,
|
1248
|
+
start: firstPaint[0].startTime
|
1249
|
+
});
|
604
1250
|
}
|
1251
|
+
}
|
1252
|
+
|
1253
|
+
list.sort(function(a, b) {
|
1254
|
+
return a.start - b.start;
|
1255
|
+
});
|
1256
|
+
return list;
|
1257
|
+
},
|
1258
|
+
getSqlTimings: function getSqlTimings(root) {
|
1259
|
+
var result = [],
|
1260
|
+
addToResults = function addToResults(timing) {
|
1261
|
+
if (timing.sql_timings) {
|
1262
|
+
for (var i = 0, sqlTiming; i < timing.sql_timings.length; i++) {
|
1263
|
+
sqlTiming = timing.sql_timings[i]; // HACK: add info about the parent Timing to each SqlTiming so UI can render
|
1264
|
+
|
1265
|
+
sqlTiming.parent_timing_name = timing.name;
|
1266
|
+
|
1267
|
+
if (sqlTiming.duration_milliseconds > 50) {
|
1268
|
+
sqlTiming.row_class = "slow";
|
1269
|
+
}
|
605
1270
|
|
606
|
-
|
607
|
-
|
608
|
-
|
609
|
-
|
610
|
-
return {
|
611
|
-
|
612
|
-
init: function () {
|
613
|
-
var script = document.getElementById('mini-profiler');
|
614
|
-
if (!script || !script.getAttribute) return;
|
615
|
-
|
616
|
-
options = (function () {
|
617
|
-
var version = script.getAttribute('data-version');
|
618
|
-
var path = script.getAttribute('data-path');
|
619
|
-
|
620
|
-
var currentId = script.getAttribute('data-current-id');
|
621
|
-
|
622
|
-
var ids = script.getAttribute('data-ids');
|
623
|
-
if (ids) ids = ids.split(',');
|
624
|
-
|
625
|
-
var horizontal_position = script.getAttribute('data-horizontal-position');
|
626
|
-
var vertical_position = script.getAttribute('data-vertical-position');
|
627
|
-
|
628
|
-
var toggleShortcut = script.getAttribute('data-toggle-shortcut');
|
629
|
-
|
630
|
-
if (script.getAttribute('data-max-traces')) {
|
631
|
-
var maxTraces = parseInt(script.getAttribute('data-max-traces'), 10);
|
632
|
-
}
|
1271
|
+
if (sqlTiming.duration_milliseconds > 200) {
|
1272
|
+
sqlTiming.row_class = "very-slow";
|
1273
|
+
}
|
633
1274
|
|
634
|
-
|
635
|
-
|
636
|
-
|
637
|
-
var controls = script.getAttribute('data-controls') === 'true';
|
638
|
-
var authorized = script.getAttribute('data-authorized') === 'true';
|
639
|
-
var startHidden = script.getAttribute('data-start-hidden') === 'true';
|
640
|
-
var htmlContainer = script.getAttribute('data-html-container');
|
641
|
-
|
642
|
-
return {
|
643
|
-
ids: ids,
|
644
|
-
path: path,
|
645
|
-
version: version,
|
646
|
-
renderHorizontalPosition: horizontal_position,
|
647
|
-
renderVerticalPosition: vertical_position,
|
648
|
-
showTrivial: trivial,
|
649
|
-
showChildrenTime: children,
|
650
|
-
maxTracesToShow: maxTraces,
|
651
|
-
showControls: controls,
|
652
|
-
currentId: currentId,
|
653
|
-
authorized: authorized,
|
654
|
-
toggleShortcut: toggleShortcut,
|
655
|
-
startHidden: startHidden,
|
656
|
-
collapseResults: collapseResults,
|
657
|
-
htmlContainer: htmlContainer
|
658
|
-
};
|
659
|
-
})();
|
660
|
-
|
661
|
-
var doInit = function () {
|
662
|
-
// when rendering a shared, full page, this div will exist
|
663
|
-
container = $('.profiler-result-full');
|
664
|
-
if (container.length) {
|
665
|
-
if (window.location.href.indexOf("&trivial=1") > 0) {
|
666
|
-
options.showTrivial = true;
|
667
|
-
}
|
668
|
-
initFullView();
|
669
|
-
}
|
670
|
-
else {
|
671
|
-
initPopupView();
|
672
|
-
}
|
673
|
-
};
|
674
|
-
|
675
|
-
// this preserves debugging
|
676
|
-
var load = function (s, f) {
|
677
|
-
var sc = document.createElement("script");
|
678
|
-
sc.async = "async";
|
679
|
-
sc.type = "text/javascript";
|
680
|
-
sc.src = s;
|
681
|
-
var done = false;
|
682
|
-
sc.onload = sc.onreadystatechange = function (_, abort) {
|
683
|
-
if (!sc.readyState || /loaded|complete/.test(sc.readyState)) {
|
684
|
-
if (!abort && !done) { done = true; f(); }
|
685
|
-
}
|
686
|
-
};
|
687
|
-
document.getElementsByTagName('head')[0].appendChild(sc);
|
688
|
-
};
|
689
|
-
|
690
|
-
var wait = 0;
|
691
|
-
var finish = false;
|
692
|
-
var deferInit = function() {
|
693
|
-
if (finish) return;
|
694
|
-
if (window.performance && window.performance.timing && window.performance.timing.loadEventEnd === 0 && wait < 10000) {
|
695
|
-
setTimeout(deferInit, 100);
|
696
|
-
wait += 100;
|
697
|
-
} else {
|
698
|
-
finish = true;
|
699
|
-
init();
|
700
|
-
}
|
701
|
-
};
|
1275
|
+
if (sqlTiming.duration_milliseconds > 400) {
|
1276
|
+
sqlTiming.row_class = "very-very-slow";
|
1277
|
+
}
|
702
1278
|
|
703
|
-
|
1279
|
+
result.push(sqlTiming);
|
1280
|
+
}
|
1281
|
+
}
|
704
1282
|
|
705
|
-
|
706
|
-
|
1283
|
+
if (timing.children) {
|
1284
|
+
for (var i = 0; i < timing.children.length; i++) {
|
1285
|
+
addToResults(timing.children[i]);
|
1286
|
+
}
|
1287
|
+
}
|
1288
|
+
}; // start adding at the root and recurse down
|
707
1289
|
|
708
|
-
|
709
|
-
(function(d){function h(g){if("string"===typeof g.data){var h=g.handler,j=g.data.toLowerCase().split(" ");g.handler=function(b){if(!(this!==b.target&&(/textarea|select/i.test(b.target.nodeName)||"text"===b.target.type))){var c="keypress"!==b.type&&d.hotkeys.specialKeys[b.which],e=String.fromCharCode(b.which).toLowerCase(),a="",f={};b.altKey&&"alt"!==c&&(a+="alt+");b.ctrlKey&&"ctrl"!==c&&(a+="ctrl+");b.metaKey&&(!b.ctrlKey&&"meta"!==c)&&(a+="meta+");b.shiftKey&&"shift"!==c&&(a+="shift+");c?f[a+c]=
|
710
|
-
!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:"+",
|
711
|
-
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);
|
712
|
-
}
|
1290
|
+
addToResults(root);
|
713
1291
|
|
714
|
-
|
715
|
-
|
716
|
-
if (document.createStyleSheet) {
|
717
|
-
document.createStyleSheet(url);
|
718
|
-
} else {
|
719
|
-
$('head').append($('<link rel="stylesheet" type="text/css" href="' + url + '" />'));
|
720
|
-
}
|
721
|
-
if (!$.tmpl) {
|
722
|
-
load(options.path + 'jquery.tmpl.js?v=' + options.version, doInit);
|
723
|
-
} else {
|
724
|
-
doInit();
|
725
|
-
}
|
726
|
-
} else {
|
727
|
-
doInit();
|
728
|
-
}
|
1292
|
+
var removeDuration = function removeDuration(list, duration) {
|
1293
|
+
var newList = [];
|
729
1294
|
|
730
|
-
|
1295
|
+
for (var i = 0; i < list.length; i++) {
|
1296
|
+
var item = list[i];
|
731
1297
|
|
732
|
-
|
733
|
-
if (
|
734
|
-
|
735
|
-
|
736
|
-
minor = parseInt(jQueryVersion[1], 10);
|
1298
|
+
if (duration.start > item.start) {
|
1299
|
+
if (duration.start > item.finish) {
|
1300
|
+
newList.push(item);
|
1301
|
+
continue;
|
737
1302
|
}
|
738
1303
|
|
1304
|
+
newList.push({
|
1305
|
+
start: item.start,
|
1306
|
+
finish: duration.start
|
1307
|
+
});
|
1308
|
+
}
|
739
1309
|
|
740
|
-
|
741
|
-
|
742
|
-
|
743
|
-
|
744
|
-
load(options.path + "jquery.1.7.1.js?v=" + options.version, function() {
|
745
|
-
MiniProfiler.jQuery = $ = jQuery.noConflict(true);
|
746
|
-
$(deferInit);
|
747
|
-
});
|
1310
|
+
if (duration.finish < item.finish) {
|
1311
|
+
if (duration.finish < item.start) {
|
1312
|
+
newList.push(item);
|
1313
|
+
continue;
|
748
1314
|
}
|
749
|
-
},
|
750
1315
|
|
751
|
-
|
752
|
-
|
753
|
-
|
754
|
-
|
755
|
-
pageTransition: function() {
|
756
|
-
if (totalsControl) {
|
757
|
-
totalsControl.remove();
|
758
|
-
totalsControl = null;
|
1316
|
+
newList.push({
|
1317
|
+
start: duration.finish,
|
1318
|
+
finish: item.finish
|
1319
|
+
});
|
759
1320
|
}
|
760
|
-
|
761
|
-
totalTime = 0;
|
762
|
-
expandedResults = false;
|
763
|
-
$('.profiler-results .profiler-result').remove();
|
764
|
-
},
|
1321
|
+
}
|
765
1322
|
|
766
|
-
|
1323
|
+
return newList;
|
1324
|
+
};
|
767
1325
|
|
768
|
-
|
769
|
-
|
770
|
-
|
771
|
-
|
772
|
-
|
773
|
-
|
774
|
-
|
1326
|
+
var processTimes = function processTimes(elem, parent) {
|
1327
|
+
var duration = {
|
1328
|
+
start: elem.start_milliseconds,
|
1329
|
+
finish: elem.start_milliseconds + elem.duration_milliseconds
|
1330
|
+
};
|
1331
|
+
elem.richTiming = [duration];
|
1332
|
+
|
1333
|
+
if (parent !== null) {
|
1334
|
+
elem.parent = parent;
|
1335
|
+
elem.parent.richTiming = removeDuration(
|
1336
|
+
elem.parent.richTiming,
|
1337
|
+
duration
|
1338
|
+
);
|
1339
|
+
}
|
775
1340
|
|
776
|
-
|
777
|
-
|
778
|
-
|
779
|
-
|
780
|
-
}
|
1341
|
+
if (elem.children) {
|
1342
|
+
for (var i = 0; i < elem.children.length; i++) {
|
1343
|
+
processTimes(elem.children[i], elem);
|
1344
|
+
}
|
1345
|
+
}
|
1346
|
+
};
|
781
1347
|
|
782
|
-
|
783
|
-
var result = '';
|
784
|
-
for (var i = 0; i < depth; i++) {
|
785
|
-
result += ' ';
|
786
|
-
}
|
787
|
-
return result;
|
788
|
-
},
|
789
|
-
|
790
|
-
renderExecuteType: function (typeId) {
|
791
|
-
// see StackExchange.Profiling.ExecuteType enum
|
792
|
-
switch (typeId) {
|
793
|
-
case 0: return 'None';
|
794
|
-
case 1: return 'NonQuery';
|
795
|
-
case 2: return 'Scalar';
|
796
|
-
case 3: return 'Reader';
|
797
|
-
}
|
798
|
-
},
|
799
|
-
|
800
|
-
shareUrl: function (id) {
|
801
|
-
return options.path + 'results?id=' + id;
|
802
|
-
},
|
803
|
-
|
804
|
-
moreUrl: function () {
|
805
|
-
var loc = window.location.href;
|
806
|
-
loc = loc.indexOf("?") > 0 ? loc + "&pp=help" : "?pp=help";
|
807
|
-
return loc;
|
808
|
-
},
|
809
|
-
|
810
|
-
getClientTimings: function (clientTimings) {
|
811
|
-
var list = [];
|
812
|
-
var t;
|
813
|
-
|
814
|
-
if (!clientTimings.timings) return [];
|
815
|
-
|
816
|
-
for (var i = 0; i < clientTimings.timings.length; i++) {
|
817
|
-
t = clientTimings.timings[i];
|
818
|
-
var trivial = t.Name != "Dom Complete" && t.Name != "Response" && t.Name != "First Paint Time";
|
819
|
-
trivial = t.Duration < 2 ? trivial : false;
|
820
|
-
list.push(
|
821
|
-
{
|
822
|
-
isTrivial: trivial,
|
823
|
-
name: t.Name,
|
824
|
-
duration: t.Duration,
|
825
|
-
start: t.Start
|
826
|
-
});
|
827
|
-
}
|
1348
|
+
processTimes(root, null); // sort results by time
|
828
1349
|
|
829
|
-
|
830
|
-
|
831
|
-
|
832
|
-
|
833
|
-
getSqlTimings: function (root) {
|
834
|
-
var result = [],
|
835
|
-
addToResults = function (timing) {
|
836
|
-
if (timing.sql_timings) {
|
837
|
-
for (var i = 0, sqlTiming; i < timing.sql_timings.length; i++) {
|
838
|
-
sqlTiming = timing.sql_timings[i];
|
839
|
-
|
840
|
-
// HACK: add info about the parent Timing to each SqlTiming so UI can render
|
841
|
-
sqlTiming.parent_timing_name = timing.name;
|
842
|
-
|
843
|
-
if(sqlTiming.duration_milliseconds > 50) {
|
844
|
-
sqlTiming.row_class = "slow";
|
845
|
-
}
|
846
|
-
|
847
|
-
if(sqlTiming.duration_milliseconds > 200) {
|
848
|
-
sqlTiming.row_class = "very-slow";
|
849
|
-
}
|
850
|
-
|
851
|
-
if(sqlTiming.duration_milliseconds > 400) {
|
852
|
-
sqlTiming.row_class = "very-very-slow";
|
853
|
-
}
|
854
|
-
|
855
|
-
result.push(sqlTiming);
|
856
|
-
}
|
857
|
-
}
|
858
|
-
|
859
|
-
if (timing.children) {
|
860
|
-
for (var i = 0; i < timing.children.length; i++) {
|
861
|
-
addToResults(timing.children[i]);
|
862
|
-
}
|
863
|
-
}
|
864
|
-
};
|
865
|
-
|
866
|
-
// start adding at the root and recurse down
|
867
|
-
addToResults(root);
|
868
|
-
|
869
|
-
var removeDuration = function(list, duration) {
|
870
|
-
|
871
|
-
var newList = [];
|
872
|
-
for (var i = 0; i < list.length; i++) {
|
873
|
-
|
874
|
-
var item = list[i];
|
875
|
-
if (duration.start > item.start) {
|
876
|
-
if (duration.start > item.finish) {
|
877
|
-
newList.push(item);
|
878
|
-
continue;
|
879
|
-
}
|
880
|
-
newList.push({ start: item.start, finish: duration.start });
|
881
|
-
}
|
882
|
-
|
883
|
-
if (duration.finish < item.finish) {
|
884
|
-
if (duration.finish < item.start) {
|
885
|
-
newList.push(item);
|
886
|
-
continue;
|
887
|
-
}
|
888
|
-
newList.push({ start: duration.finish, finish: item.finish });
|
889
|
-
}
|
890
|
-
}
|
1350
|
+
result.sort(function(a, b) {
|
1351
|
+
return a.start_milliseconds - b.start_milliseconds;
|
1352
|
+
});
|
891
1353
|
|
892
|
-
|
893
|
-
|
1354
|
+
var determineOverlap = function determineOverlap(gap, node) {
|
1355
|
+
var overlap = 0;
|
894
1356
|
|
895
|
-
|
896
|
-
|
897
|
-
elem.richTiming = [duration];
|
898
|
-
if (parent !== null) {
|
899
|
-
elem.parent = parent;
|
900
|
-
elem.parent.richTiming = removeDuration(elem.parent.richTiming, duration);
|
901
|
-
}
|
1357
|
+
for (var i = 0; i < node.richTiming.length; i++) {
|
1358
|
+
var current = node.richTiming[i];
|
902
1359
|
|
903
|
-
|
904
|
-
|
905
|
-
|
906
|
-
}
|
907
|
-
}
|
908
|
-
};
|
1360
|
+
if (current.start > gap.finish) {
|
1361
|
+
break;
|
1362
|
+
}
|
909
1363
|
|
910
|
-
|
1364
|
+
if (current.finish < gap.start) {
|
1365
|
+
continue;
|
1366
|
+
}
|
911
1367
|
|
912
|
-
|
913
|
-
|
1368
|
+
overlap +=
|
1369
|
+
Math.min(gap.finish, current.finish) -
|
1370
|
+
Math.max(gap.start, current.start);
|
1371
|
+
}
|
914
1372
|
|
915
|
-
|
916
|
-
|
917
|
-
for (var i = 0; i < node.richTiming.length; i++) {
|
918
|
-
var current = node.richTiming[i];
|
919
|
-
if (current.start > gap.finish) {
|
920
|
-
break;
|
921
|
-
}
|
922
|
-
if (current.finish < gap.start) {
|
923
|
-
continue;
|
924
|
-
}
|
1373
|
+
return overlap;
|
1374
|
+
};
|
925
1375
|
|
926
|
-
|
927
|
-
|
928
|
-
return overlap;
|
929
|
-
};
|
1376
|
+
var determineGap = function determineGap(gap, node, match) {
|
1377
|
+
var overlap = determineOverlap(gap, node);
|
930
1378
|
|
931
|
-
|
932
|
-
|
933
|
-
|
934
|
-
|
935
|
-
|
936
|
-
|
937
|
-
|
938
|
-
|
1379
|
+
if (match === null || overlap > match.duration) {
|
1380
|
+
match = {
|
1381
|
+
name: node.name,
|
1382
|
+
duration: overlap
|
1383
|
+
};
|
1384
|
+
} else if (match.name == node.name) {
|
1385
|
+
match.duration += overlap;
|
1386
|
+
}
|
939
1387
|
|
940
|
-
|
941
|
-
|
942
|
-
|
943
|
-
|
944
|
-
|
945
|
-
return match;
|
946
|
-
};
|
947
|
-
|
948
|
-
var time = 0;
|
949
|
-
var prev = null;
|
950
|
-
$.each(result, function () {
|
951
|
-
this.prevGap = {
|
952
|
-
duration: (this.start_milliseconds - time).toFixed(2),
|
953
|
-
start: time,
|
954
|
-
finish: this.start_milliseconds
|
955
|
-
};
|
956
|
-
|
957
|
-
this.prevGap.topReason = determineGap(this.prevGap, root, null);
|
958
|
-
|
959
|
-
time = this.start_milliseconds + this.duration_milliseconds;
|
960
|
-
prev = this;
|
961
|
-
});
|
1388
|
+
if (node.children) {
|
1389
|
+
for (var i = 0; i < node.children.length; i++) {
|
1390
|
+
match = determineGap(gap, node.children[i], match);
|
1391
|
+
}
|
1392
|
+
}
|
962
1393
|
|
1394
|
+
return match;
|
1395
|
+
};
|
963
1396
|
|
964
|
-
|
965
|
-
|
966
|
-
|
967
|
-
|
968
|
-
|
969
|
-
|
970
|
-
|
971
|
-
|
972
|
-
|
1397
|
+
var time = 0;
|
1398
|
+
var prev = null;
|
1399
|
+
result.forEach(function(r) {
|
1400
|
+
r.prevGap = {
|
1401
|
+
duration: (r.start_milliseconds - time).toFixed(2),
|
1402
|
+
start: time,
|
1403
|
+
finish: r.start_milliseconds
|
1404
|
+
};
|
1405
|
+
r.prevGap.topReason = determineGap(r.prevGap, root, null);
|
1406
|
+
time = r.start_milliseconds + r.duration_milliseconds;
|
1407
|
+
prev = r;
|
1408
|
+
});
|
1409
|
+
|
1410
|
+
if (result.length > 0) {
|
1411
|
+
var me = result[result.length - 1];
|
1412
|
+
me.nextGap = {
|
1413
|
+
duration: (root.duration_milliseconds - time).toFixed(2),
|
1414
|
+
start: time,
|
1415
|
+
finish: root.duration_milliseconds
|
1416
|
+
};
|
1417
|
+
me.nextGap.topReason = determineGap(me.nextGap, root, null);
|
1418
|
+
}
|
1419
|
+
|
1420
|
+
return result;
|
1421
|
+
},
|
1422
|
+
getSqlTimingsCount: function getSqlTimingsCount(root) {
|
1423
|
+
var result = 0,
|
1424
|
+
countSql = function countSql(timing) {
|
1425
|
+
if (timing.sql_timings) {
|
1426
|
+
result += timing.sql_timings.length;
|
1427
|
+
}
|
973
1428
|
|
974
|
-
|
975
|
-
|
976
|
-
|
977
|
-
getSqlTimingsCount: function (root) {
|
978
|
-
var result = 0,
|
979
|
-
countSql = function (timing) {
|
980
|
-
if (timing.sql_timings) {
|
981
|
-
result += timing.sql_timings.length;
|
982
|
-
}
|
983
|
-
|
984
|
-
if (timing.children) {
|
985
|
-
for (var i = 0; i < timing.children.length; i++) {
|
986
|
-
countSql(timing.children[i]);
|
987
|
-
}
|
988
|
-
}
|
989
|
-
};
|
990
|
-
countSql(root);
|
991
|
-
return result;
|
992
|
-
},
|
993
|
-
|
994
|
-
fetchResultsExposed: function (ids) {
|
995
|
-
return fetchResults(ids);
|
996
|
-
},
|
997
|
-
|
998
|
-
formatParameters: function (parameters) {
|
999
|
-
if (parameters != null) {
|
1000
|
-
return parameters.map(function(item, index){ return "["+item[0]+", "+ item[1] +"]";}).join(', ');
|
1429
|
+
if (timing.children) {
|
1430
|
+
for (var i = 0; i < timing.children.length; i++) {
|
1431
|
+
countSql(timing.children[i]);
|
1001
1432
|
}
|
1002
|
-
|
1003
|
-
|
1004
|
-
}
|
1005
|
-
},
|
1433
|
+
}
|
1434
|
+
};
|
1006
1435
|
|
1007
|
-
|
1008
|
-
|
1436
|
+
countSql(root);
|
1437
|
+
return result;
|
1438
|
+
},
|
1439
|
+
fetchResultsExposed: function fetchResultsExposed(ids) {
|
1440
|
+
return fetchResults(ids);
|
1441
|
+
},
|
1442
|
+
formatParameters: function formatParameters(parameters) {
|
1443
|
+
if (parameters != null) {
|
1444
|
+
return parameters
|
1445
|
+
.map(function(item, index) {
|
1446
|
+
return "[" + item[0] + ", " + item[1] + "]";
|
1447
|
+
})
|
1448
|
+
.join(", ");
|
1449
|
+
} else {
|
1450
|
+
return "";
|
1451
|
+
}
|
1452
|
+
},
|
1453
|
+
formatDuration: function formatDuration(duration) {
|
1454
|
+
return (duration || 0).toFixed(1);
|
1455
|
+
},
|
1456
|
+
showTotalSqlCount: function showTotalSqlCount() {
|
1457
|
+
return options.showTotalSqlCount;
|
1458
|
+
},
|
1459
|
+
timestampToRelative: function timestampToRelative(timestamp) {
|
1460
|
+
var now = Math.round(new Date().getTime() / 1000);
|
1461
|
+
timestamp = Math.round(timestamp / 1000);
|
1462
|
+
var diff = now - timestamp;
|
1463
|
+
if (diff < 60) {
|
1464
|
+
return "< 1 minute";
|
1465
|
+
}
|
1466
|
+
var buildDisplayTime = function buildDisplayTime(num, unit) {
|
1467
|
+
var res = num + " " + unit;
|
1468
|
+
if (num !== 1) {
|
1469
|
+
res += "s";
|
1009
1470
|
}
|
1010
|
-
|
1471
|
+
return res;
|
1472
|
+
};
|
1473
|
+
diff = Math.round(diff / 60);
|
1474
|
+
if (diff <= 60) {
|
1475
|
+
return buildDisplayTime(diff, "minute");
|
1476
|
+
}
|
1477
|
+
diff = Math.round(diff / 60);
|
1478
|
+
if (diff <= 24) {
|
1479
|
+
return buildDisplayTime(diff, "hour");
|
1480
|
+
}
|
1481
|
+
diff = Math.round(diff / 24);
|
1482
|
+
return buildDisplayTime(diff, "day");
|
1483
|
+
}
|
1484
|
+
};
|
1011
1485
|
})();
|
1012
1486
|
|
1013
|
-
MiniProfiler
|
1014
|
-
|
1015
|
-
if (typeof prettyPrint === "undefined") {
|
1016
|
-
|
1017
|
-
// prettify.js
|
1018
|
-
// http://code.google.com/p/google-code-prettify/
|
1019
|
-
|
1020
|
-
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};
|
1021
|
-
(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(">");
|
1022
|
-
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),
|
1023
|
-
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);
|
1024
|
-
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("-");
|
1025
|
-
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("\\"===
|
1026
|
-
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,
|
1027
|
-
""))){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,
|
1028
|
-
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)];
|
1029
|
-
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])*(?:\"|$))/,
|
1030
|
-
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*)>/,
|
1031
|
-
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]*/,
|
1032
|
-
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,
|
1033
|
-
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;
|
1034
|
-
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]}
|
1035
|
-
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&&
|
1036
|
-
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,
|
1037
|
-
"&")}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=["!","!=","!==","#","%","%=","&","&&","&&=","&=","(","*","*=","+=",",","-=","->","/","/=",":","::",";","<","<<","<<=","<=","=","==","===",">",">=",">>",">>=",">>>",">>>=","?","@","[","^","^=","^^","^^=","{","|","|=","||","||=",
|
1038
|
-
"~","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]*)/,
|
1039
|
-
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 ",
|
1040
|
-
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",
|
1041
|
-
"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],
|
1042
|
-
["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 ",
|
1043
|
-
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 ",
|
1044
|
-
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 ",
|
1045
|
-
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"]);
|
1046
|
-
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,
|
1047
|
-
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]+/]]),
|
1048
|
-
["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")>=
|
1049
|
-
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,
|
1050
|
-
" "))}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"),
|
1051
|
-
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,
|
1052
|
-
PR_TAG:"tag",PR_TYPE:S}})()
|
1053
|
-
|
1054
|
-
;
|
1055
|
-
|
1056
|
-
// lang-sql.js
|
1057
|
-
// http://code.google.com/p/google-code-prettify/
|
1058
|
-
|
1059
|
-
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,
|
1060
|
-
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"])
|
1061
|
-
|
1062
|
-
;
|
1487
|
+
if (window.MiniProfiler) {
|
1488
|
+
_MiniProfiler.patchesApplied = window.MiniProfiler.patchesApplied;
|
1063
1489
|
}
|
1490
|
+
window.MiniProfiler = _MiniProfiler;
|
1491
|
+
_MiniProfiler.init();
|