rack-mini-profiler 0.1.20 → 0.1.25

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of rack-mini-profiler might be problematic. Click here for more details.

Files changed (44) hide show
  1. checksums.yaml +7 -0
  2. data/Ruby/CHANGELOG +130 -0
  3. data/{README.md → Ruby/README.md} +40 -9
  4. data/Ruby/lib/html/flamegraph.html +325 -0
  5. data/Ruby/lib/html/includes.css +451 -0
  6. data/{lib → Ruby/lib}/html/includes.js +135 -24
  7. data/{lib → Ruby/lib}/html/includes.less +38 -35
  8. data/{lib → Ruby/lib}/html/includes.tmpl +40 -15
  9. data/{lib → Ruby/lib}/html/jquery.1.7.1.js +1 -1
  10. data/{lib → Ruby/lib}/html/jquery.tmpl.js +1 -1
  11. data/{lib → Ruby/lib}/html/list.css +0 -0
  12. data/{lib → Ruby/lib}/html/list.js +7 -6
  13. data/{lib → Ruby/lib}/html/list.tmpl +0 -0
  14. data/Ruby/lib/html/profile_handler.js +1 -0
  15. data/{lib → Ruby/lib}/html/share.html +0 -0
  16. data/{lib → Ruby/lib}/mini_profiler/client_settings.rb +0 -0
  17. data/{lib → Ruby/lib}/mini_profiler/client_timer_struct.rb +1 -1
  18. data/{lib → Ruby/lib}/mini_profiler/config.rb +57 -52
  19. data/{lib → Ruby/lib}/mini_profiler/context.rb +11 -10
  20. data/Ruby/lib/mini_profiler/custom_timer_struct.rb +22 -0
  21. data/Ruby/lib/mini_profiler/flame_graph.rb +54 -0
  22. data/Ruby/lib/mini_profiler/gc_profiler.rb +107 -0
  23. data/{lib → Ruby/lib}/mini_profiler/page_timer_struct.rb +7 -2
  24. data/{lib → Ruby/lib}/mini_profiler/profiler.rb +206 -196
  25. data/{lib → Ruby/lib}/mini_profiler/profiling_methods.rb +131 -100
  26. data/{lib → Ruby/lib}/mini_profiler/request_timer_struct.rb +20 -1
  27. data/{lib → Ruby/lib}/mini_profiler/sql_timer_struct.rb +0 -0
  28. data/{lib → Ruby/lib}/mini_profiler/storage/abstract_store.rb +31 -27
  29. data/{lib → Ruby/lib}/mini_profiler/storage/file_store.rb +111 -109
  30. data/Ruby/lib/mini_profiler/storage/memcache_store.rb +53 -0
  31. data/{lib → Ruby/lib}/mini_profiler/storage/memory_store.rb +65 -63
  32. data/Ruby/lib/mini_profiler/storage/redis_store.rb +54 -0
  33. data/{lib → Ruby/lib}/mini_profiler/timer_struct.rb +0 -0
  34. data/Ruby/lib/mini_profiler/version.rb +5 -0
  35. data/{lib → Ruby/lib}/mini_profiler_rails/railtie.rb +3 -2
  36. data/Ruby/lib/patches/net_patches.rb +14 -0
  37. data/{lib → Ruby/lib}/patches/sql_patches.rb +89 -48
  38. data/{lib → Ruby/lib}/rack-mini-profiler.rb +2 -1
  39. data/rack-mini-profiler.gemspec +8 -6
  40. metadata +56 -65
  41. data/CHANGELOG +0 -93
  42. data/lib/html/includes.css +0 -75
  43. data/lib/html/profile_handler.js +0 -62
  44. data/lib/mini_profiler/storage/redis_store.rb +0 -44
@@ -0,0 +1,451 @@
1
+ .profiler-result,
2
+ .profiler-queries {
3
+ color: #555;
4
+ line-height: 1;
5
+ font-size: 12px;
6
+ }
7
+ .profiler-result pre,
8
+ .profiler-queries pre,
9
+ .profiler-result code,
10
+ .profiler-queries code,
11
+ .profiler-result label,
12
+ .profiler-queries label,
13
+ .profiler-result table,
14
+ .profiler-queries table,
15
+ .profiler-result tbody,
16
+ .profiler-queries tbody,
17
+ .profiler-result thead,
18
+ .profiler-queries thead,
19
+ .profiler-result tfoot,
20
+ .profiler-queries tfoot,
21
+ .profiler-result tr,
22
+ .profiler-queries tr,
23
+ .profiler-result th,
24
+ .profiler-queries th,
25
+ .profiler-result td,
26
+ .profiler-queries td {
27
+ margin: 0;
28
+ padding: 0;
29
+ border: 0;
30
+ font-size: 100%;
31
+ font: inherit;
32
+ vertical-align: baseline;
33
+ background-color: transparent;
34
+ overflow: visible;
35
+ max-height: none;
36
+ }
37
+ .profiler-result table,
38
+ .profiler-queries table {
39
+ border-collapse: collapse;
40
+ border-spacing: 0;
41
+ }
42
+ .profiler-result a,
43
+ .profiler-queries a,
44
+ .profiler-result a:hover,
45
+ .profiler-queries a:hover {
46
+ cursor: pointer;
47
+ color: #0077cc;
48
+ }
49
+ .profiler-result a,
50
+ .profiler-queries a {
51
+ text-decoration: none;
52
+ }
53
+ .profiler-result a:hover,
54
+ .profiler-queries a:hover {
55
+ text-decoration: underline;
56
+ }
57
+ .profiler-result {
58
+ font-family: Helvetica, Arial, sans-serif;
59
+ }
60
+ .profiler-result .profiler-toggle-duration-with-children {
61
+ float: right;
62
+ }
63
+ .profiler-result table.profiler-client-timings {
64
+ margin-top: 10px;
65
+ }
66
+ .profiler-result .profiler-label {
67
+ color: #555555;
68
+ overflow: hidden;
69
+ text-overflow: ellipsis;
70
+ }
71
+ .profiler-result .profiler-unit {
72
+ color: #aaaaaa;
73
+ }
74
+ .profiler-result .profiler-trivial {
75
+ display: none;
76
+ }
77
+ .profiler-result .profiler-trivial td,
78
+ .profiler-result .profiler-trivial td * {
79
+ color: #aaaaaa !important;
80
+ }
81
+ .profiler-result pre,
82
+ .profiler-result code,
83
+ .profiler-result .profiler-number,
84
+ .profiler-result .profiler-unit {
85
+ font-family: Consolas, monospace, serif;
86
+ }
87
+ .profiler-result .profiler-number {
88
+ color: #111111;
89
+ }
90
+ .profiler-result .profiler-info {
91
+ text-align: right;
92
+ }
93
+ .profiler-result .profiler-info .profiler-name {
94
+ float: left;
95
+ }
96
+ .profiler-result .profiler-info .profiler-server-time {
97
+ white-space: nowrap;
98
+ }
99
+ .profiler-result .profiler-timings th {
100
+ background-color: #fff;
101
+ color: #aaaaaa;
102
+ text-align: right;
103
+ }
104
+ .profiler-result .profiler-timings th,
105
+ .profiler-result .profiler-timings td {
106
+ white-space: nowrap;
107
+ }
108
+ .profiler-result .profiler-timings .profiler-duration-with-children {
109
+ display: none;
110
+ }
111
+ .profiler-result .profiler-timings .profiler-duration {
112
+ font-family: Consolas, monospace, serif;
113
+ color: #111111;
114
+ text-align: right;
115
+ }
116
+ .profiler-result .profiler-timings .profiler-indent {
117
+ letter-spacing: 4px;
118
+ }
119
+ .profiler-result .profiler-timings .profiler-queries-show .profiler-number,
120
+ .profiler-result .profiler-timings .profiler-queries-show .profiler-unit {
121
+ color: #0077cc;
122
+ }
123
+ .profiler-result .profiler-timings .profiler-queries-duration {
124
+ padding-left: 6px;
125
+ }
126
+ .profiler-result .profiler-timings .profiler-percent-in-sql {
127
+ white-space: nowrap;
128
+ text-align: right;
129
+ }
130
+ .profiler-result .profiler-timings tfoot td {
131
+ padding-top: 10px;
132
+ text-align: right;
133
+ }
134
+ .profiler-result .profiler-timings tfoot td a {
135
+ font-size: 95%;
136
+ display: inline-block;
137
+ margin-left: 12px;
138
+ }
139
+ .profiler-result .profiler-timings tfoot td a:first-child {
140
+ float: left;
141
+ margin-left: 0px;
142
+ }
143
+ .profiler-result .profiler-timings tfoot td a.profiler-custom-link {
144
+ float: left;
145
+ }
146
+ .profiler-result .profiler-queries {
147
+ font-family: Helvetica, Arial, sans-serif;
148
+ }
149
+ .profiler-result .profiler-queries .profiler-stack-trace {
150
+ margin-bottom: 15px;
151
+ }
152
+ .profiler-result .profiler-queries pre {
153
+ font-family: Consolas, monospace, serif;
154
+ white-space: pre-wrap;
155
+ }
156
+ .profiler-result .profiler-queries th {
157
+ background-color: #fff;
158
+ border-bottom: 1px solid #555;
159
+ font-weight: bold;
160
+ padding: 15px;
161
+ white-space: nowrap;
162
+ }
163
+ .profiler-result .profiler-queries td {
164
+ padding: 15px;
165
+ text-align: left;
166
+ background-color: #fff;
167
+ }
168
+ .profiler-result .profiler-queries td:last-child {
169
+ padding-right: 25px;
170
+ }
171
+ .profiler-result .profiler-queries .profiler-odd td {
172
+ background-color: #e5e5e5;
173
+ }
174
+ .profiler-result .profiler-queries .profiler-since-start,
175
+ .profiler-result .profiler-queries .profiler-duration {
176
+ text-align: right;
177
+ }
178
+ .profiler-result .profiler-queries .profiler-info div {
179
+ text-align: right;
180
+ margin-bottom: 5px;
181
+ }
182
+ .profiler-result .profiler-queries .profiler-gap-info,
183
+ .profiler-result .profiler-queries .profiler-gap-info td {
184
+ background-color: #ccc;
185
+ }
186
+ .profiler-result .profiler-queries .profiler-gap-info .profiler-unit {
187
+ color: #777;
188
+ }
189
+ .profiler-result .profiler-queries .profiler-gap-info .profiler-info {
190
+ text-align: right;
191
+ }
192
+ .profiler-result .profiler-queries .profiler-gap-info.profiler-trivial-gaps {
193
+ display: none;
194
+ }
195
+ .profiler-result .profiler-queries .profiler-trivial-gap-container {
196
+ text-align: center;
197
+ }
198
+ .profiler-result .profiler-queries .str {
199
+ color: #800000;
200
+ }
201
+ .profiler-result .profiler-queries .kwd {
202
+ color: #00008b;
203
+ }
204
+ .profiler-result .profiler-queries .com {
205
+ color: #808080;
206
+ }
207
+ .profiler-result .profiler-queries .typ {
208
+ color: #2b91af;
209
+ }
210
+ .profiler-result .profiler-queries .lit {
211
+ color: #800000;
212
+ }
213
+ .profiler-result .profiler-queries .pun {
214
+ color: #000000;
215
+ }
216
+ .profiler-result .profiler-queries .pln {
217
+ color: #000000;
218
+ }
219
+ .profiler-result .profiler-queries .tag {
220
+ color: #800000;
221
+ }
222
+ .profiler-result .profiler-queries .atn {
223
+ color: #ff0000;
224
+ }
225
+ .profiler-result .profiler-queries .atv {
226
+ color: #0000ff;
227
+ }
228
+ .profiler-result .profiler-queries .dec {
229
+ color: #800080;
230
+ }
231
+ .profiler-result .profiler-warning,
232
+ .profiler-result .profiler-warning *,
233
+ .profiler-result .profiler-warning .profiler-queries-show,
234
+ .profiler-result .profiler-warning .profiler-queries-show .profiler-unit {
235
+ color: #f00;
236
+ }
237
+ .profiler-result .profiler-warning:hover,
238
+ .profiler-result .profiler-warning *:hover,
239
+ .profiler-result .profiler-warning .profiler-queries-show:hover,
240
+ .profiler-result .profiler-warning .profiler-queries-show .profiler-unit:hover {
241
+ color: #f00;
242
+ }
243
+ .profiler-result .profiler-nuclear {
244
+ color: #f00;
245
+ font-weight: bold;
246
+ padding-right: 2px;
247
+ }
248
+ .profiler-result .profiler-nuclear:hover {
249
+ color: #f00;
250
+ }
251
+ .profiler-results {
252
+ z-index: 2147483643;
253
+ position: fixed;
254
+ top: 0px;
255
+ }
256
+ .profiler-results.profiler-left {
257
+ left: 0px;
258
+ }
259
+ .profiler-results.profiler-left.profiler-no-controls .profiler-result:last-child .profiler-button,
260
+ .profiler-results.profiler-left .profiler-controls {
261
+ -webkit-border-bottom-right-radius: 10px;
262
+ -moz-border-radius-bottomright: 10px;
263
+ border-bottom-right-radius: 10px;
264
+ }
265
+ .profiler-results.profiler-left .profiler-button,
266
+ .profiler-results.profiler-left .profiler-controls {
267
+ border-right: 1px solid #888888;
268
+ }
269
+ .profiler-results.profiler-right {
270
+ right: 0px;
271
+ }
272
+ .profiler-results.profiler-right.profiler-no-controls .profiler-result:last-child .profiler-button,
273
+ .profiler-results.profiler-right .profiler-controls {
274
+ -webkit-border-bottom-left-radius: 10px;
275
+ -moz-border-radius-bottomleft: 10px;
276
+ border-bottom-left-radius: 10px;
277
+ }
278
+ .profiler-results.profiler-right .profiler-button,
279
+ .profiler-results.profiler-right .profiler-controls {
280
+ border-left: 1px solid #888888;
281
+ }
282
+ .profiler-results .profiler-button,
283
+ .profiler-results .profiler-controls {
284
+ display: none;
285
+ z-index: 2147483640;
286
+ border-bottom: 1px solid #888888;
287
+ background-color: #fff;
288
+ padding: 4px 7px;
289
+ text-align: right;
290
+ cursor: pointer;
291
+ }
292
+ .profiler-results .profiler-button.profiler-button-active,
293
+ .profiler-results .profiler-controls.profiler-button-active {
294
+ background-color: maroon;
295
+ }
296
+ .profiler-results .profiler-button.profiler-button-active .profiler-number,
297
+ .profiler-results .profiler-controls.profiler-button-active .profiler-number,
298
+ .profiler-results .profiler-button.profiler-button-active .profiler-nuclear,
299
+ .profiler-results .profiler-controls.profiler-button-active .profiler-nuclear {
300
+ color: #fff;
301
+ font-weight: bold;
302
+ }
303
+ .profiler-results .profiler-button.profiler-button-active .profiler-unit,
304
+ .profiler-results .profiler-controls.profiler-button-active .profiler-unit {
305
+ color: #fff;
306
+ font-weight: normal;
307
+ }
308
+ .profiler-results .profiler-controls {
309
+ display: block;
310
+ font-size: 12px;
311
+ font-family: Consolas, monospace, serif;
312
+ cursor: default;
313
+ text-align: center;
314
+ }
315
+ .profiler-results .profiler-controls span {
316
+ border-right: 1px solid #aaaaaa;
317
+ padding-right: 5px;
318
+ margin-right: 5px;
319
+ cursor: pointer;
320
+ }
321
+ .profiler-results .profiler-controls span:last-child {
322
+ border-right: none;
323
+ }
324
+ .profiler-results .profiler-popup {
325
+ display: none;
326
+ z-index: 2147483641;
327
+ position: absolute;
328
+ background-color: #fff;
329
+ border: 1px solid #aaa;
330
+ padding: 5px 10px;
331
+ text-align: left;
332
+ line-height: 18px;
333
+ overflow: auto;
334
+ -moz-box-shadow: 0px 1px 15px #555555;
335
+ -webkit-box-shadow: 0px 1px 15px #555555;
336
+ box-shadow: 0px 1px 15px #555555;
337
+ }
338
+ .profiler-results .profiler-popup .profiler-info {
339
+ margin-bottom: 3px;
340
+ padding-bottom: 2px;
341
+ border-bottom: 1px solid #ddd;
342
+ }
343
+ .profiler-results .profiler-popup .profiler-info .profiler-name {
344
+ font-size: 110%;
345
+ font-weight: bold;
346
+ }
347
+ .profiler-results .profiler-popup .profiler-info .profiler-name .profiler-overall-duration {
348
+ display: none;
349
+ }
350
+ .profiler-results .profiler-popup .profiler-info .profiler-server-time {
351
+ font-size: 95%;
352
+ }
353
+ .profiler-results .profiler-popup .profiler-timings th,
354
+ .profiler-results .profiler-popup .profiler-timings td {
355
+ padding-left: 6px;
356
+ padding-right: 6px;
357
+ }
358
+ .profiler-results .profiler-popup .profiler-timings th {
359
+ font-size: 95%;
360
+ padding-bottom: 3px;
361
+ }
362
+ .profiler-results .profiler-popup .profiler-timings .profiler-label {
363
+ max-width: 275px;
364
+ }
365
+ .profiler-results .profiler-queries {
366
+ display: none;
367
+ z-index: 2147483643;
368
+ position: absolute;
369
+ overflow-y: auto;
370
+ overflow-x: auto;
371
+ background-color: #fff;
372
+ }
373
+ .profiler-results .profiler-queries th {
374
+ font-size: 17px;
375
+ }
376
+ .profiler-results.profiler-min .profiler-result {
377
+ display: none;
378
+ }
379
+ .profiler-results.profiler-min .profiler-controls span {
380
+ display: none;
381
+ }
382
+ .profiler-results.profiler-min .profiler-controls .profiler-min-max {
383
+ border-right: none;
384
+ padding: 0px;
385
+ margin: 0px;
386
+ }
387
+ .profiler-queries-bg {
388
+ z-index: 2147483642;
389
+ display: none;
390
+ background: #000;
391
+ opacity: 0.7;
392
+ position: absolute;
393
+ top: 0px;
394
+ left: 0px;
395
+ min-width: 100%;
396
+ }
397
+ .profiler-result-full .profiler-result {
398
+ width: 950px;
399
+ margin: 30px auto;
400
+ }
401
+ .profiler-result-full .profiler-result .profiler-button {
402
+ display: none;
403
+ }
404
+ .profiler-result-full .profiler-result .profiler-popup .profiler-info {
405
+ font-size: 25px;
406
+ border-bottom: 1px solid #aaaaaa;
407
+ padding-bottom: 3px;
408
+ margin-bottom: 25px;
409
+ }
410
+ .profiler-result-full .profiler-result .profiler-popup .profiler-info .profiler-overall-duration {
411
+ padding-right: 20px;
412
+ font-size: 80%;
413
+ color: #888;
414
+ }
415
+ .profiler-result-full .profiler-result .profiler-popup .profiler-timings td,
416
+ .profiler-result-full .profiler-result .profiler-popup .profiler-timings th {
417
+ padding-left: 8px;
418
+ padding-right: 8px;
419
+ }
420
+ .profiler-result-full .profiler-result .profiler-popup .profiler-timings th {
421
+ padding-bottom: 7px;
422
+ }
423
+ .profiler-result-full .profiler-result .profiler-popup .profiler-timings td {
424
+ font-size: 14px;
425
+ padding-bottom: 4px;
426
+ }
427
+ .profiler-result-full .profiler-result .profiler-popup .profiler-timings td:first-child {
428
+ padding-left: 10px;
429
+ }
430
+ .profiler-result-full .profiler-result .profiler-popup .profiler-timings .profiler-label {
431
+ max-width: 550px;
432
+ }
433
+ .profiler-result-full .profiler-result .profiler-queries {
434
+ margin: 25px 0;
435
+ }
436
+ .profiler-result-full .profiler-result .profiler-queries table {
437
+ width: 100%;
438
+ }
439
+ .profiler-result-full .profiler-result .profiler-queries th {
440
+ font-size: 16px;
441
+ color: #555;
442
+ line-height: 20px;
443
+ }
444
+ .profiler-result-full .profiler-result .profiler-queries td {
445
+ padding: 15px 10px;
446
+ text-align: left;
447
+ }
448
+ .profiler-result-full .profiler-result .profiler-queries .profiler-info div {
449
+ text-align: right;
450
+ margin-bottom: 5px;
451
+ }
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
- var MiniProfiler = (function ($) {
2
+ var MiniProfiler = (function () {
3
+ var $;
3
4
 
4
5
  var options,
5
6
  container,
@@ -60,11 +61,10 @@ var MiniProfiler = (function ($) {
60
61
  }
61
62
  };
62
63
 
63
- var getClientPerformance = function () {
64
+ var getClientPerformance = function() {
64
65
  return window.performance == null ? null : window.performance;
65
- }
66
+ };
66
67
 
67
- var waitedForEnd = 0;
68
68
  var fetchResults = function (ids) {
69
69
  var clientPerformance, clientProbes, i, j, p, id, idx;
70
70
 
@@ -364,6 +364,9 @@ var MiniProfiler = (function ($) {
364
364
  popupHide(button, popup);
365
365
  }
366
366
  });
367
+ $(document).bind('keydown', options.toggleShortcut, function(e) {
368
+ $('.profiler-results').toggle();
369
+ });
367
370
  };
368
371
 
369
372
  var initFullView = function () {
@@ -432,6 +435,7 @@ var MiniProfiler = (function ($) {
432
435
  // get master page profiler results
433
436
  fetchResults(options.ids);
434
437
  });
438
+ if (options.startHidden) container.hide();
435
439
  }
436
440
  else {
437
441
  fetchResults(options.ids);
@@ -449,11 +453,12 @@ var MiniProfiler = (function ($) {
449
453
  };
450
454
 
451
455
  // fetch profile results for any ajax calls
456
+ // note, this does not use $ cause we want to hook into the main jQuery
452
457
  if (jQuery && jQuery(document) && jQuery(document).ajaxComplete) {
453
458
  jQuery(document).ajaxComplete(jQueryAjaxComplete);
454
459
  }
455
460
 
456
- if (jQuery(document).ajaxStart)
461
+ if (jQuery && jQuery(document).ajaxStart)
457
462
  jQuery(document).ajaxStart(function () { ajaxStartTime = new Date(); });
458
463
 
459
464
  // fetch results after ASP Ajax calls
@@ -506,20 +511,92 @@ var MiniProfiler = (function ($) {
506
511
  });
507
512
  }
508
513
 
514
+ if (typeof (MooTools) != 'undefined' && typeof (Request) != 'undefined') {
515
+ Request.prototype.addEvents({
516
+ onComplete: function() {
517
+ var stringIds = this.xhr.getResponseHeader('X-MiniProfiler-Ids');
518
+ if (stringIds) {
519
+ var ids = typeof JSON != 'undefined' ? JSON.parse(stringIds) : eval(stringIds);
520
+ fetchResults(ids);
521
+ }
522
+ }
523
+ });
524
+ }
525
+
526
+ // add support for AngularJS, which use the basic XMLHttpRequest object.
527
+ if (window.angular && typeof (XMLHttpRequest) != 'undefined') {
528
+ var _send = XMLHttpRequest.prototype.send;
529
+
530
+ XMLHttpRequest.prototype.send = function sendReplacement(data) {
531
+ this._onreadystatechange = this.onreadystatechange;
532
+
533
+ this.onreadystatechange = function onReadyStateChangeReplacement() {
534
+ if (this.readyState == 4) {
535
+ var stringIds = this.getResponseHeader('X-MiniProfiler-Ids');
536
+ if (stringIds) {
537
+ var ids = typeof JSON != 'undefined' ? JSON.parse(stringIds) : eval(stringIds);
538
+ fetchResults(ids);
539
+ }
540
+ }
541
+
542
+ return this._onreadystatechange.apply(this, arguments);
543
+ }
544
+
545
+ return _send.apply(this, arguments);
546
+ }
547
+ }
548
+
509
549
  // some elements want to be hidden on certain doc events
510
550
  bindDocumentEvents();
511
551
  };
512
552
 
513
553
  return {
514
554
 
515
- init: function (opt) {
516
-
517
- options = opt || {};
555
+ init: function () {
556
+ var script = document.getElementById('mini-profiler');
557
+ if (!script || !script.getAttribute) return;
558
+
559
+ options = (function () {
560
+ var version = script.getAttribute('data-version');
561
+ var path = script.getAttribute('data-path');
562
+
563
+ var currentId = script.getAttribute('data-current-id');
564
+
565
+ var ids = script.getAttribute('data-ids');
566
+ if (ids) ids = ids.split(',');
567
+
568
+ var position = script.getAttribute('data-position');
569
+
570
+ var toggleShortcut = script.getAttribute('data-toggle-shortcut');
571
+
572
+ if (script.getAttribute('data-max-traces'))
573
+ var maxTraces = parseInt(script.getAttribute('data-max-traces'));
574
+
575
+ if (script.getAttribute('data-trivial') === 'true') var trivial = true;
576
+ if (script.getAttribute('data-children') == 'true') var children = true;
577
+ if (script.getAttribute('data-controls') == 'true') var controls = true;
578
+ if (script.getAttribute('data-authorized') == 'true') var authorized = true;
579
+ if (script.getAttribute('data-start-hidden') == 'true') var startHidden = true;
580
+
581
+ return {
582
+ ids: ids,
583
+ path: path,
584
+ version: version,
585
+ renderPosition: position,
586
+ showTrivial: trivial,
587
+ showChildrenTime: children,
588
+ maxTracesToShow: maxTraces,
589
+ showControls: controls,
590
+ currentId: currentId,
591
+ authorized: authorized,
592
+ toggleShortcut: toggleShortcut,
593
+ startHidden: startHidden
594
+ }
595
+ })();
518
596
 
519
597
  var doInit = function () {
520
598
  // when rendering a shared, full page, this div will exist
521
599
  container = $('.profiler-result-full');
522
-
523
600
  if (container.length) {
524
601
  if (window.location.href.indexOf("&trivial=1") > 0) {
525
602
  options.showTrivial = true
@@ -546,24 +623,49 @@ var MiniProfiler = (function ($) {
546
623
  document.getElementsByTagName('head')[0].appendChild(sc);
547
624
  };
548
625
 
549
- if (options.authorized) {
550
- var url = options.path + "includes.css?v=" + options.version;
551
- if (document.createStyleSheet) {
552
- document.createStyleSheet(url);
626
+ var wait = 0;
627
+ var finish = false;
628
+ var deferInit = function() {
629
+ if (finish) return;
630
+ if (window.performance && window.performance.timing && window.performance.timing.loadEventEnd == 0 && wait < 10000) {
631
+ setTimeout(deferInit, 100);
632
+ wait += 100;
553
633
  } else {
554
- $('head').append($('<link rel="stylesheet" type="text/css" href="' + url + '" />'));
634
+ finish = true;
635
+ init();
555
636
  }
637
+ };
556
638
 
557
- if (!$.tmpl) {
558
- load(options.path + 'jquery.tmpl.js?v=' + options.version, doInit);
639
+ var init = function() {
640
+ if (options.authorized) {
641
+ var url = options.path + "includes.css?v=" + options.version;
642
+ if (document.createStyleSheet) {
643
+ document.createStyleSheet(url);
644
+ } else {
645
+ $('head').append($('<link rel="stylesheet" type="text/css" href="' + url + '" />'));
646
+ }
647
+ if (!$.tmpl) {
648
+ load(options.path + 'jquery.tmpl.js?v=' + options.version, doInit);
649
+ } else {
650
+ doInit();
651
+ }
559
652
  } else {
560
653
  doInit();
561
654
  }
655
+ };
656
+
657
+ if (typeof(jQuery) == 'function') {
658
+ var jQueryVersion = jQuery.fn.jquery.split('.');
562
659
  }
563
- else {
564
- doInit();
660
+ if (jQueryVersion && parseInt(jQueryVersion[0]) < 2 && parseInt(jQueryVersion[1]) >= 7) {
661
+ MiniProfiler.jQuery = $ = jQuery;
662
+ $(deferInit);
663
+ } else {
664
+ load(options.path + "jquery.1.7.1.js?v=" + options.version, function() {
665
+ MiniProfiler.jQuery = $ = jQuery.noConflict(true);
666
+ $(deferInit);
667
+ });
565
668
  }
566
-
567
669
  },
568
670
 
569
671
  getClientTimingByName: function (clientTiming, name) {
@@ -650,7 +752,7 @@ var MiniProfiler = (function ($) {
650
752
  // start adding at the root and recurse down
651
753
  addToResults(root);
652
754
 
653
- var removeDuration = function (list, duration) {
755
+ var removeDuration = function(list, duration) {
654
756
 
655
757
  var newList = [];
656
758
  for (var i = 0; i < list.length; i++) {
@@ -674,7 +776,7 @@ var MiniProfiler = (function ($) {
674
776
  }
675
777
 
676
778
  return newList;
677
- }
779
+ };
678
780
 
679
781
  var processTimes = function (elem, parent) {
680
782
  var duration = { start: elem.StartMilliseconds, finish: (elem.StartMilliseconds + elem.DurationMilliseconds) };
@@ -696,7 +798,7 @@ var MiniProfiler = (function ($) {
696
798
  // sort results by time
697
799
  result.sort(function (a, b) { return a.StartMilliseconds - b.StartMilliseconds; });
698
800
 
699
- var determineOverlap = function (gap, node) {
801
+ var determineOverlap = function(gap, node) {
700
802
  var overlap = 0;
701
803
  for (var i = 0; i < node.richTiming.length; i++) {
702
804
  var current = node.richTiming[i];
@@ -710,7 +812,7 @@ var MiniProfiler = (function ($) {
710
812
  overlap += Math.min(gap.finish, current.finish) - Math.max(gap.start, current.start);
711
813
  }
712
814
  return overlap;
713
- }
815
+ };
714
816
 
715
817
  var determineGap = function (gap, node, match) {
716
818
  var overlap = determineOverlap(gap, node);
@@ -783,7 +885,16 @@ var MiniProfiler = (function ($) {
783
885
  return (duration || 0).toFixed(1);
784
886
  }
785
887
  };
786
- })(jQueryMP);
888
+ })();
889
+
890
+ MiniProfiler.init();
891
+
892
+ // jquery.hotkeys.js
893
+ // https://github.com/jeresig/jquery.hotkeys/blob/master/jquery.hotkeys.js
894
+
895
+ (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]=
896
+ !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:"+",
897
+ 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}})})(jQuery);
787
898
 
788
899
  // prettify.js
789
900
  // http://code.google.com/p/google-code-prettify/