rack-mini-profiler 0.9.2 → 0.9.7
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 +4 -4
- data/CHANGELOG.md +20 -0
- data/README.md +20 -5
- data/lib/html/includes.css +18 -4
- data/lib/html/includes.js +99 -58
- data/lib/html/includes.less +26 -5
- data/lib/html/includes.tmpl +50 -49
- data/lib/html/list.tmpl +8 -8
- data/lib/mini_profiler/asset_version.rb +5 -0
- data/lib/mini_profiler/client_settings.rb +3 -3
- data/lib/mini_profiler/config.rb +11 -11
- data/lib/mini_profiler/gc_profiler.rb +8 -28
- data/lib/mini_profiler/profiler.rb +170 -105
- data/lib/mini_profiler/profiling_methods.rb +15 -17
- data/lib/mini_profiler/storage/file_store.rb +4 -4
- data/lib/mini_profiler/storage/memcache_store.rb +6 -7
- data/lib/mini_profiler/storage/memory_store.rb +56 -27
- data/lib/mini_profiler/storage/redis_store.rb +19 -11
- data/lib/mini_profiler/timer_struct/base.rb +33 -0
- data/lib/mini_profiler/timer_struct/client.rb +89 -0
- data/lib/mini_profiler/timer_struct/custom.rb +22 -0
- data/lib/mini_profiler/timer_struct/page.rb +62 -0
- data/lib/mini_profiler/timer_struct/request.rb +126 -0
- data/lib/mini_profiler/timer_struct/sql.rb +59 -0
- data/lib/mini_profiler/version.rb +2 -2
- data/lib/mini_profiler_rails/railtie.rb +6 -1
- data/lib/patches/db/activerecord.rb +42 -0
- data/lib/patches/db/moped.rb +12 -0
- data/lib/patches/db/mysql2.rb +30 -0
- data/lib/patches/db/pg.rb +104 -0
- data/lib/patches/db/plucky.rb +47 -0
- data/lib/patches/db/rsolr.rb +24 -0
- data/lib/patches/db/sequel.rb +10 -0
- data/lib/patches/sql_patches.rb +17 -255
- data/lib/rack-mini-profiler.rb +28 -0
- data/rack-mini-profiler.gemspec +6 -2
- metadata +17 -9
- data/lib/mini_profiler/client_timer_struct.rb +0 -78
- data/lib/mini_profiler/custom_timer_struct.rb +0 -22
- data/lib/mini_profiler/page_timer_struct.rb +0 -58
- data/lib/mini_profiler/request_timer_struct.rb +0 -115
- data/lib/mini_profiler/sql_timer_struct.rb +0 -58
- data/lib/mini_profiler/timer_struct.rb +0 -33
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 2417d22f7d7896ced32bc242d3e7f0b43eb73f6f
|
|
4
|
+
data.tar.gz: 0a5d429ac232a90772dd17de9650fb12f6eb355c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 1b33304bb3ccb9e659fc5a274d939cb2e8455a9a5427bd3fa46a98ff8d88d5b238ebfe3a46f6b2cee9730f88a1ebe585bae41ac716f988e5feecc6ac17231d48
|
|
7
|
+
data.tar.gz: 8799e05e0fcea21ab023aa7e4594cb75e21c7315fa0c25478d275a3df815b37731cb490d3e64756d0bc2d206d00292b9c395a368349715c22cd7dbe328f2093b
|
data/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,24 @@
|
|
|
1
1
|
# CHANGELOG
|
|
2
|
+
|
|
3
|
+
## 0.9.7 - 2015-08-03 (Sam Saffron)
|
|
4
|
+
|
|
5
|
+
- [FEATURE] remove confusing pp=profile-gc-time (Nate Berkopec)
|
|
6
|
+
- [FEATURE] truncate strings in pp=analyze-memory (Nate Berkopec)
|
|
7
|
+
- [FEATURE] rename pp=profile-gc-ruby-head to pp=profile-memory (Nate Berkopec)
|
|
8
|
+
|
|
9
|
+
## 0.9.6 - 2015-07-08 (Sam Saffron)
|
|
10
|
+
|
|
11
|
+
- [FIX] incorrect truncation in pp=analyze-memory
|
|
12
|
+
|
|
13
|
+
## 0.9.5 - 2015-07-08 (Sam Saffron)
|
|
14
|
+
|
|
15
|
+
- [FEATURE] improve pp=analyze-memory
|
|
16
|
+
|
|
17
|
+
## 0.9.4 - 2015-07-08 (Sam Saffron)
|
|
18
|
+
- [UX] added a link to "more" actions in profiler
|
|
19
|
+
- [FEATURE] pp=help now displays links
|
|
20
|
+
- [FEATURE] simple memory report with pp=analyze-memory
|
|
21
|
+
|
|
2
22
|
## 0.9.2 - 2014-06-26 (Sam Saffron)
|
|
3
23
|
- [CHANGE] staging and other environments behave like production (Cedric Felizard)
|
|
4
24
|
- [DOC] CHANGELOG reorg (Olivier Lacan)
|
data/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# rack-mini-profiler
|
|
2
2
|
|
|
3
|
-
[](https://codeclimate.com/github/MiniProfiler/rack-mini-profiler) [](https://travis-ci.org/MiniProfiler/rack-mini-profiler)
|
|
4
4
|
|
|
5
5
|
Middleware that displays speed badge for every html page. Designed to work both in production and in development.
|
|
6
6
|
|
|
@@ -23,7 +23,6 @@ We have decided to restructure our repository so there is a central UI repo and
|
|
|
23
23
|
|
|
24
24
|
- Setting up a build that reuses https://github.com/MiniProfiler/ui
|
|
25
25
|
- Migrating the internal data structures [per the spec](https://github.com/MiniProfiler/ui)
|
|
26
|
-
- Cleaning up the [horrendous class structure that is using strings as keys and crazy non-objects](https://github.com/MiniProfiler/rack-mini-profiler/blob/master/lib/mini_profiler/sql_timer_struct.rb#L36-L44)
|
|
27
26
|
|
|
28
27
|
If you feel like taking on any of this start an issue and update us on your progress.
|
|
29
28
|
|
|
@@ -87,7 +86,7 @@ end
|
|
|
87
86
|
|
|
88
87
|
To generate [flamegraphs](http://samsaffron.com/archive/2013/03/19/flame-graphs-in-ruby-miniprofiler):
|
|
89
88
|
|
|
90
|
-
* add the **flamegraph** gem to your Gemfile
|
|
89
|
+
* add the [**flamegraph**](https://github.com/SamSaffron/flamegraph) gem to your Gemfile
|
|
91
90
|
* visit a page in your app with `?pp=flamegraph`
|
|
92
91
|
|
|
93
92
|
Flamegraph generation is supported in MRI 2.0 and 2.1 only.
|
|
@@ -112,6 +111,19 @@ Various aspects of rack-mini-profiler's behavior can be configured when your app
|
|
|
112
111
|
For example in a Rails app, this should be done in an initializer:
|
|
113
112
|
**config/initializers/mini_profiler.rb**
|
|
114
113
|
|
|
114
|
+
### Caching behavior
|
|
115
|
+
To fix some nasty bugs with rack-mini-profiler showing the wrong data, the middleware
|
|
116
|
+
will remove headers relating to caching (Date & Etag on responses, If-Modified-Since & If-None-Match on requests).
|
|
117
|
+
This probably won't ever break your application, but it can cause some unexpected behavior. For
|
|
118
|
+
example, in a Rails app, calls to `stale?` will always return true.
|
|
119
|
+
|
|
120
|
+
To disable this behavior, use the following config setting:
|
|
121
|
+
|
|
122
|
+
```ruby
|
|
123
|
+
# Do not let rack-mini-profiler disable caching
|
|
124
|
+
Rack::MiniProfiler.config.disable_caching = false # defaults to true
|
|
125
|
+
```
|
|
126
|
+
|
|
115
127
|
### Storage
|
|
116
128
|
|
|
117
129
|
rack-mini-profiler stores its results so they can be shared later and aren't lost at the end of the request.
|
|
@@ -167,10 +179,13 @@ The available configuration options are:
|
|
|
167
179
|
|
|
168
180
|
* pre_authorize_cb - A lambda callback you can set to determine whether or not mini_profiler should be visible on a given request. Default in a Rails environment is only on in development mode. If in a Rack app, the default is always on.
|
|
169
181
|
* position - Can either be 'right' or 'left'. Default is 'left'.
|
|
182
|
+
* skip_paths - Specifies path list that can be skipped.
|
|
170
183
|
* skip_schema_queries - Whether or not you want to log the queries about the schema of your tables. Default is 'false', 'true' in rails development.
|
|
171
184
|
* auto_inject (default true) - when false the miniprofiler script is not injected in the page
|
|
172
|
-
*
|
|
173
|
-
*
|
|
185
|
+
* backtrace_ignores (default nil) - an array of regexes you can use to filter out unwanted lines from the backtraces
|
|
186
|
+
* backtrace_includes (default nil, or [/^\/?(app|config|lib|test)/] in rails) - an array of regexes you can use to keep lines in the backtrace
|
|
187
|
+
* backtrace_remove (default nil, or Rails.root in rails) - A string or regex to remove part of each line in the backtrace
|
|
188
|
+
* toggle_shortcut (default Alt+P) - a jquery.hotkeys.js-style keyboard shortcut, used to toggle the mini_profiler's visibility. See https://github.com/jeresig/jquery.hotkeys for more info.
|
|
174
189
|
* start_hidden (default false) - Whether or not you want the mini_profiler to be visible when loading a page
|
|
175
190
|
* backtrace_threshold_ms (default zero) - Minimum SQL query elapsed time before a backtrace is recorded. Backtrace recording can take a couple of milliseconds on rubies earlier than 2.0, impacting performance for very small queries.
|
|
176
191
|
* flamegraph_sample_rate (default 0.5ms) - How often fast_stack should get stack trace info to generate flamegraphs
|
data/lib/html/includes.css
CHANGED
|
@@ -149,6 +149,21 @@
|
|
|
149
149
|
.profiler-result .profiler-queries .profiler-stack-trace {
|
|
150
150
|
margin-bottom: 15px;
|
|
151
151
|
}
|
|
152
|
+
.profiler-result .profiler-queries tbody tr {
|
|
153
|
+
border-bottom: 1px solid #f1f1f1;
|
|
154
|
+
}
|
|
155
|
+
.profiler-result .profiler-queries tr {
|
|
156
|
+
background-color: #FFF;
|
|
157
|
+
}
|
|
158
|
+
.profiler-result .profiler-queries tr.slow {
|
|
159
|
+
background-color: #FEE;
|
|
160
|
+
}
|
|
161
|
+
.profiler-result .profiler-queries tr.very-slow {
|
|
162
|
+
background-color: #FDD;
|
|
163
|
+
}
|
|
164
|
+
.profiler-result .profiler-queries tr.very-very-slow {
|
|
165
|
+
background-color: #FCC;
|
|
166
|
+
}
|
|
152
167
|
.profiler-result .profiler-queries pre {
|
|
153
168
|
font-family: Consolas, monospace, serif;
|
|
154
169
|
white-space: pre-wrap;
|
|
@@ -163,14 +178,10 @@
|
|
|
163
178
|
.profiler-result .profiler-queries td {
|
|
164
179
|
padding: 15px;
|
|
165
180
|
text-align: left;
|
|
166
|
-
background-color: #fff;
|
|
167
181
|
}
|
|
168
182
|
.profiler-result .profiler-queries td:last-child {
|
|
169
183
|
padding-right: 25px;
|
|
170
184
|
}
|
|
171
|
-
.profiler-result .profiler-queries .profiler-odd td {
|
|
172
|
-
background-color: #e5e5e5;
|
|
173
|
-
}
|
|
174
185
|
.profiler-result .profiler-queries .profiler-since-start,
|
|
175
186
|
.profiler-result .profiler-queries .profiler-duration {
|
|
176
187
|
text-align: right;
|
|
@@ -384,6 +395,9 @@
|
|
|
384
395
|
padding: 0px;
|
|
385
396
|
margin: 0px;
|
|
386
397
|
}
|
|
398
|
+
.profiler-results .profiler-more-actions {
|
|
399
|
+
float: left;
|
|
400
|
+
}
|
|
387
401
|
.profiler-queries-bg {
|
|
388
402
|
z-index: 2147483642;
|
|
389
403
|
display: none;
|
data/lib/html/includes.js
CHANGED
|
@@ -278,7 +278,7 @@ var MiniProfiler = (function () {
|
|
|
278
278
|
|
|
279
279
|
var queriesScrollIntoView = function (link, queries, whatToScroll) {
|
|
280
280
|
var id = link.closest('tr').attr('data-timing-id'),
|
|
281
|
-
cells = queries.find('tr[data-timing-id="' + id + '"]
|
|
281
|
+
cells = queries.find('tr[data-timing-id="' + id + '"]');
|
|
282
282
|
|
|
283
283
|
// ensure they're in view
|
|
284
284
|
whatToScroll.scrollTop(whatToScroll.scrollTop() + cells.first().position().top - 100);
|
|
@@ -326,13 +326,13 @@ var MiniProfiler = (function () {
|
|
|
326
326
|
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)];
|
|
327
327
|
|
|
328
328
|
// Look for rgba(0, 0, 0, 0) == transparent in Safari 3
|
|
329
|
-
if (result = /rgba\(0, 0, 0, 0\)/.exec(color)) return
|
|
329
|
+
if (result = /rgba\(0, 0, 0, 0\)/.exec(color)) return [0,0,0,0];
|
|
330
330
|
|
|
331
331
|
return null;
|
|
332
332
|
};
|
|
333
333
|
|
|
334
334
|
var bindDocumentEvents = function () {
|
|
335
|
-
$(document).bind('click keyup', function (e) {
|
|
335
|
+
$(document).bind('click.mini-profiler keyup.mini-profiler', function (e) {
|
|
336
336
|
|
|
337
337
|
// this happens on every keystroke, and :visible is crazy expensive in IE <9
|
|
338
338
|
// and in this case, the display:none check is sufficient.
|
|
@@ -365,9 +365,19 @@ var MiniProfiler = (function () {
|
|
|
365
365
|
popupHide(button, popup);
|
|
366
366
|
}
|
|
367
367
|
});
|
|
368
|
-
$(document).bind('keydown', options.toggleShortcut, function(e) {
|
|
368
|
+
$(document).bind('keydown.mini-profiler', options.toggleShortcut, function(e) {
|
|
369
369
|
$('.profiler-results').toggle();
|
|
370
370
|
});
|
|
371
|
+
|
|
372
|
+
if (typeof Turbolinks !== 'undefined' && Turbolinks.supported) {
|
|
373
|
+
$(document).bind('page:change.mini-profiler', function() {
|
|
374
|
+
unbindDocumentEvents();
|
|
375
|
+
});
|
|
376
|
+
}
|
|
377
|
+
};
|
|
378
|
+
|
|
379
|
+
var unbindDocumentEvents = function() {
|
|
380
|
+
$(document).unbind('.mini-profiler');
|
|
371
381
|
};
|
|
372
382
|
|
|
373
383
|
var initFullView = function () {
|
|
@@ -456,11 +466,11 @@ var MiniProfiler = (function () {
|
|
|
456
466
|
// fetch profile results for any ajax calls
|
|
457
467
|
// note, this does not use $ cause we want to hook into the main jQuery
|
|
458
468
|
if (jQuery && jQuery(document) && jQuery(document).ajaxComplete) {
|
|
459
|
-
jQuery(document).ajaxComplete
|
|
469
|
+
jQuery(document).bind('ajaxComplete.mini-profiler', jQueryAjaxComplete);
|
|
460
470
|
}
|
|
461
471
|
|
|
462
472
|
if (jQuery && jQuery(document).ajaxStart)
|
|
463
|
-
jQuery(document).ajaxStart
|
|
473
|
+
jQuery(document).bind('ajaxStart.mini-profiler', function () { ajaxStartTime = new Date(); });
|
|
464
474
|
|
|
465
475
|
// fetch results after ASP Ajax calls
|
|
466
476
|
if (typeof (Sys) != 'undefined' && typeof (Sys.WebForms) != 'undefined' && typeof (Sys.WebForms.PageRequestManager) != 'undefined') {
|
|
@@ -534,22 +544,27 @@ var MiniProfiler = (function () {
|
|
|
534
544
|
var _send = XMLHttpRequest.prototype.send;
|
|
535
545
|
|
|
536
546
|
XMLHttpRequest.prototype.send = function sendReplacement(data) {
|
|
537
|
-
|
|
547
|
+
if (this.onreadystatechange) {
|
|
548
|
+
if (typeof (this.miniprofiler) == 'undefined' || typeof (this.miniprofiler.prev_onreadystatechange) == 'undefined') {
|
|
549
|
+
this.miniprofiler = { prev_onreadystatechange: this.onreadystatechange };
|
|
538
550
|
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
551
|
+
this.onreadystatechange = function onReadyStateChangeReplacement() {
|
|
552
|
+
if (this.readyState == 4) {
|
|
553
|
+
var stringIds = this.getResponseHeader('X-MiniProfiler-Ids');
|
|
554
|
+
if (stringIds) {
|
|
555
|
+
var ids = typeof JSON != 'undefined' ? JSON.parse(stringIds) : eval(stringIds);
|
|
556
|
+
fetchResults(ids);
|
|
557
|
+
}
|
|
558
|
+
}
|
|
547
559
|
|
|
548
|
-
|
|
549
|
-
|
|
560
|
+
if (this.miniprofiler.prev_onreadystatechange != null)
|
|
561
|
+
return this.miniprofiler.prev_onreadystatechange.apply(this, arguments);
|
|
562
|
+
};
|
|
563
|
+
}
|
|
564
|
+
}
|
|
550
565
|
|
|
551
566
|
return _send.apply(this, arguments);
|
|
552
|
-
}
|
|
567
|
+
}
|
|
553
568
|
}
|
|
554
569
|
|
|
555
570
|
// some elements want to be hidden on certain doc events
|
|
@@ -644,6 +659,16 @@ var MiniProfiler = (function () {
|
|
|
644
659
|
};
|
|
645
660
|
|
|
646
661
|
var init = function() {
|
|
662
|
+
|
|
663
|
+
// jquery.hotkeys.js
|
|
664
|
+
// https://github.com/jeresig/jquery.hotkeys/blob/master/jquery.hotkeys.js
|
|
665
|
+
|
|
666
|
+
if (MiniProfiler.jQuery.hotkeys === undefined) {
|
|
667
|
+
(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]=
|
|
668
|
+
!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:"+",
|
|
669
|
+
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);
|
|
670
|
+
}
|
|
671
|
+
|
|
647
672
|
if (options.authorized) {
|
|
648
673
|
var url = options.path + "includes.css?v=" + options.version;
|
|
649
674
|
if (document.createStyleSheet) {
|
|
@@ -660,13 +685,6 @@ var MiniProfiler = (function () {
|
|
|
660
685
|
doInit();
|
|
661
686
|
}
|
|
662
687
|
|
|
663
|
-
// jquery.hotkeys.js
|
|
664
|
-
// https://github.com/jeresig/jquery.hotkeys/blob/master/jquery.hotkeys.js
|
|
665
|
-
|
|
666
|
-
(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]=
|
|
667
|
-
!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:"+",
|
|
668
|
-
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);
|
|
669
|
-
|
|
670
688
|
};
|
|
671
689
|
|
|
672
690
|
var major, minor;
|
|
@@ -688,11 +706,15 @@ var MiniProfiler = (function () {
|
|
|
688
706
|
}
|
|
689
707
|
},
|
|
690
708
|
|
|
709
|
+
cleanUp: function() {
|
|
710
|
+
unbindDocumentEvents();
|
|
711
|
+
},
|
|
712
|
+
|
|
691
713
|
getClientTimingByName: function (clientTiming, name) {
|
|
692
714
|
|
|
693
|
-
for (var i = 0; i < clientTiming.
|
|
694
|
-
if (clientTiming.
|
|
695
|
-
return clientTiming.
|
|
715
|
+
for (var i = 0; i < clientTiming.timings.length; i++) {
|
|
716
|
+
if (clientTiming.timings[i].name == name) {
|
|
717
|
+
return clientTiming.timings[i];
|
|
696
718
|
}
|
|
697
719
|
}
|
|
698
720
|
return { Name: name, Duration: "", Start: "" };
|
|
@@ -726,14 +748,20 @@ var MiniProfiler = (function () {
|
|
|
726
748
|
return options.path + 'results?id=' + id;
|
|
727
749
|
},
|
|
728
750
|
|
|
751
|
+
moreUrl: function () {
|
|
752
|
+
var loc = window.location.href;
|
|
753
|
+
loc = loc.indexOf("?") > 0 ? loc + "&pp=help" : "?pp=help";
|
|
754
|
+
return loc;
|
|
755
|
+
},
|
|
756
|
+
|
|
729
757
|
getClientTimings: function (clientTimings) {
|
|
730
758
|
var list = [];
|
|
731
759
|
var t;
|
|
732
760
|
|
|
733
|
-
if (!clientTimings.
|
|
761
|
+
if (!clientTimings.timings) return [];
|
|
734
762
|
|
|
735
|
-
for (var i = 0; i < clientTimings.
|
|
736
|
-
t = clientTimings.
|
|
763
|
+
for (var i = 0; i < clientTimings.timings.length; i++) {
|
|
764
|
+
t = clientTimings.timings[i];
|
|
737
765
|
var trivial = t.Name != "Dom Complete" && t.Name != "Response" && t.Name != "First Paint Time";
|
|
738
766
|
trivial = t.Duration < 2 ? trivial : false;
|
|
739
767
|
list.push(
|
|
@@ -752,19 +780,32 @@ var MiniProfiler = (function () {
|
|
|
752
780
|
getSqlTimings: function (root) {
|
|
753
781
|
var result = [],
|
|
754
782
|
addToResults = function (timing) {
|
|
755
|
-
if (timing.
|
|
756
|
-
for (var i = 0, sqlTiming; i < timing.
|
|
757
|
-
sqlTiming = timing.
|
|
783
|
+
if (timing.sql_timings) {
|
|
784
|
+
for (var i = 0, sqlTiming; i < timing.sql_timings.length; i++) {
|
|
785
|
+
sqlTiming = timing.sql_timings[i];
|
|
758
786
|
|
|
759
787
|
// HACK: add info about the parent Timing to each SqlTiming so UI can render
|
|
760
|
-
sqlTiming.
|
|
788
|
+
sqlTiming.parent_timing_name = timing.name;
|
|
789
|
+
|
|
790
|
+
if(sqlTiming.duration_milliseconds > 50) {
|
|
791
|
+
sqlTiming.row_class = "slow";
|
|
792
|
+
}
|
|
793
|
+
|
|
794
|
+
if(sqlTiming.duration_milliseconds > 200) {
|
|
795
|
+
sqlTiming.row_class = "very-slow";
|
|
796
|
+
}
|
|
797
|
+
|
|
798
|
+
if(sqlTiming.duration_milliseconds > 400) {
|
|
799
|
+
sqlTiming.row_class = "very-very-slow";
|
|
800
|
+
}
|
|
801
|
+
|
|
761
802
|
result.push(sqlTiming);
|
|
762
803
|
}
|
|
763
804
|
}
|
|
764
805
|
|
|
765
|
-
if (timing.
|
|
766
|
-
for (var i = 0; i < timing.
|
|
767
|
-
addToResults(timing.
|
|
806
|
+
if (timing.children) {
|
|
807
|
+
for (var i = 0; i < timing.children.length; i++) {
|
|
808
|
+
addToResults(timing.children[i]);
|
|
768
809
|
}
|
|
769
810
|
}
|
|
770
811
|
};
|
|
@@ -799,16 +840,16 @@ var MiniProfiler = (function () {
|
|
|
799
840
|
};
|
|
800
841
|
|
|
801
842
|
var processTimes = function (elem, parent) {
|
|
802
|
-
var duration = { start: elem.
|
|
843
|
+
var duration = { start: elem.start_milliseconds, finish: (elem.start_milliseconds + elem.duration_milliseconds) };
|
|
803
844
|
elem.richTiming = [duration];
|
|
804
845
|
if (parent != null) {
|
|
805
846
|
elem.parent = parent;
|
|
806
847
|
elem.parent.richTiming = removeDuration(elem.parent.richTiming, duration);
|
|
807
848
|
}
|
|
808
849
|
|
|
809
|
-
if (elem.
|
|
810
|
-
for (var i = 0; i < elem.
|
|
811
|
-
processTimes(elem.
|
|
850
|
+
if (elem.children) {
|
|
851
|
+
for (var i = 0; i < elem.children.length; i++) {
|
|
852
|
+
processTimes(elem.children[i], elem);
|
|
812
853
|
}
|
|
813
854
|
}
|
|
814
855
|
};
|
|
@@ -816,7 +857,7 @@ var MiniProfiler = (function () {
|
|
|
816
857
|
processTimes(root, null);
|
|
817
858
|
|
|
818
859
|
// sort results by time
|
|
819
|
-
result.sort(function (a, b) { return a.
|
|
860
|
+
result.sort(function (a, b) { return a.start_milliseconds - b.start_milliseconds; });
|
|
820
861
|
|
|
821
862
|
var determineOverlap = function(gap, node) {
|
|
822
863
|
var overlap = 0;
|
|
@@ -837,15 +878,15 @@ var MiniProfiler = (function () {
|
|
|
837
878
|
var determineGap = function (gap, node, match) {
|
|
838
879
|
var overlap = determineOverlap(gap, node);
|
|
839
880
|
if (match == null || overlap > match.duration) {
|
|
840
|
-
match = { name: node.
|
|
881
|
+
match = { name: node.name, duration: overlap };
|
|
841
882
|
}
|
|
842
|
-
else if (match.name == node.
|
|
883
|
+
else if (match.name == node.name) {
|
|
843
884
|
match.duration += overlap;
|
|
844
885
|
}
|
|
845
886
|
|
|
846
|
-
if (node.
|
|
847
|
-
for (var i = 0; i < node.
|
|
848
|
-
match = determineGap(gap, node.
|
|
887
|
+
if (node.children) {
|
|
888
|
+
for (var i = 0; i < node.children.length; i++) {
|
|
889
|
+
match = determineGap(gap, node.children[i], match);
|
|
849
890
|
}
|
|
850
891
|
}
|
|
851
892
|
return match;
|
|
@@ -855,14 +896,14 @@ var MiniProfiler = (function () {
|
|
|
855
896
|
var prev = null;
|
|
856
897
|
$.each(result, function () {
|
|
857
898
|
this.prevGap = {
|
|
858
|
-
duration: (this.
|
|
899
|
+
duration: (this.start_milliseconds - time).toFixed(2),
|
|
859
900
|
start: time,
|
|
860
|
-
finish: this.
|
|
901
|
+
finish: this.start_milliseconds
|
|
861
902
|
};
|
|
862
903
|
|
|
863
904
|
this.prevGap.topReason = determineGap(this.prevGap, root, null);
|
|
864
905
|
|
|
865
|
-
time = this.
|
|
906
|
+
time = this.start_milliseconds + this.duration_milliseconds;
|
|
866
907
|
prev = this;
|
|
867
908
|
});
|
|
868
909
|
|
|
@@ -870,9 +911,9 @@ var MiniProfiler = (function () {
|
|
|
870
911
|
if (result.length > 0) {
|
|
871
912
|
var me = result[result.length - 1];
|
|
872
913
|
me.nextGap = {
|
|
873
|
-
duration: (root.
|
|
914
|
+
duration: (root.duration_milliseconds - time).toFixed(2),
|
|
874
915
|
start: time,
|
|
875
|
-
finish: root.
|
|
916
|
+
finish: root.duration_milliseconds
|
|
876
917
|
};
|
|
877
918
|
me.nextGap.topReason = determineGap(me.nextGap, root, null);
|
|
878
919
|
}
|
|
@@ -883,13 +924,13 @@ var MiniProfiler = (function () {
|
|
|
883
924
|
getSqlTimingsCount: function (root) {
|
|
884
925
|
var result = 0,
|
|
885
926
|
countSql = function (timing) {
|
|
886
|
-
if (timing.
|
|
887
|
-
result += timing.
|
|
927
|
+
if (timing.sql_timings) {
|
|
928
|
+
result += timing.sql_timings.length;
|
|
888
929
|
}
|
|
889
930
|
|
|
890
|
-
if (timing.
|
|
891
|
-
for (var i = 0; i < timing.
|
|
892
|
-
countSql(timing.
|
|
931
|
+
if (timing.children) {
|
|
932
|
+
for (var i = 0; i < timing.children.length; i++) {
|
|
933
|
+
countSql(timing.children[i]);
|
|
893
934
|
}
|
|
894
935
|
}
|
|
895
936
|
};
|