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.
Files changed (43) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +20 -0
  3. data/README.md +20 -5
  4. data/lib/html/includes.css +18 -4
  5. data/lib/html/includes.js +99 -58
  6. data/lib/html/includes.less +26 -5
  7. data/lib/html/includes.tmpl +50 -49
  8. data/lib/html/list.tmpl +8 -8
  9. data/lib/mini_profiler/asset_version.rb +5 -0
  10. data/lib/mini_profiler/client_settings.rb +3 -3
  11. data/lib/mini_profiler/config.rb +11 -11
  12. data/lib/mini_profiler/gc_profiler.rb +8 -28
  13. data/lib/mini_profiler/profiler.rb +170 -105
  14. data/lib/mini_profiler/profiling_methods.rb +15 -17
  15. data/lib/mini_profiler/storage/file_store.rb +4 -4
  16. data/lib/mini_profiler/storage/memcache_store.rb +6 -7
  17. data/lib/mini_profiler/storage/memory_store.rb +56 -27
  18. data/lib/mini_profiler/storage/redis_store.rb +19 -11
  19. data/lib/mini_profiler/timer_struct/base.rb +33 -0
  20. data/lib/mini_profiler/timer_struct/client.rb +89 -0
  21. data/lib/mini_profiler/timer_struct/custom.rb +22 -0
  22. data/lib/mini_profiler/timer_struct/page.rb +62 -0
  23. data/lib/mini_profiler/timer_struct/request.rb +126 -0
  24. data/lib/mini_profiler/timer_struct/sql.rb +59 -0
  25. data/lib/mini_profiler/version.rb +2 -2
  26. data/lib/mini_profiler_rails/railtie.rb +6 -1
  27. data/lib/patches/db/activerecord.rb +42 -0
  28. data/lib/patches/db/moped.rb +12 -0
  29. data/lib/patches/db/mysql2.rb +30 -0
  30. data/lib/patches/db/pg.rb +104 -0
  31. data/lib/patches/db/plucky.rb +47 -0
  32. data/lib/patches/db/rsolr.rb +24 -0
  33. data/lib/patches/db/sequel.rb +10 -0
  34. data/lib/patches/sql_patches.rb +17 -255
  35. data/lib/rack-mini-profiler.rb +28 -0
  36. data/rack-mini-profiler.gemspec +6 -2
  37. metadata +17 -9
  38. data/lib/mini_profiler/client_timer_struct.rb +0 -78
  39. data/lib/mini_profiler/custom_timer_struct.rb +0 -22
  40. data/lib/mini_profiler/page_timer_struct.rb +0 -58
  41. data/lib/mini_profiler/request_timer_struct.rb +0 -115
  42. data/lib/mini_profiler/sql_timer_struct.rb +0 -58
  43. data/lib/mini_profiler/timer_struct.rb +0 -33
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8b3ee0b3863448cab4aa77a7d21a6660cd864fdd
4
- data.tar.gz: 84d03ff97e66376542b2ad7862abcb1e5fee280b
3
+ metadata.gz: 2417d22f7d7896ced32bc242d3e7f0b43eb73f6f
4
+ data.tar.gz: 0a5d429ac232a90772dd17de9650fb12f6eb355c
5
5
  SHA512:
6
- metadata.gz: e31c6eacf0d6fa8b01f1c11ef4be1f16a86e1f08843ef79ff8051c5029b78460aa9c23802b1cdc1be8e1b4d19dc19e6644c621740bec0c8578aed6a04bb52ede
7
- data.tar.gz: cf86b40baacdd86a5e90f641a4ec9e2367ddfef55c3f1810aeed774fd55950b86c428ab9df7eabcd08f09a1dc093b142f270ac3bad4ff7acba4a4b87e1d52826
6
+ metadata.gz: 1b33304bb3ccb9e659fc5a274d939cb2e8455a9a5427bd3fa46a98ff8d88d5b238ebfe3a46f6b2cee9730f88a1ebe585bae41ac716f988e5feecc6ac17231d48
7
+ data.tar.gz: 8799e05e0fcea21ab023aa7e4594cb75e21c7315fa0c25478d275a3df815b37731cb490d3e64756d0bc2d206d00292b9c395a368349715c22cd7dbe328f2093b
@@ -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
- [![Code Climate](https://codeclimate.com/github/MiniProfiler/rack-mini-profiler.png)](https://codeclimate.com/github/MiniProfiler/rack-mini-profiler) [![Build Status](https://travis-ci.org/MiniProfiler/rack-mini-profiler.png)](https://travis-ci.org/MiniProfiler/rack-mini-profiler)
3
+ [![Code Climate](https://codeclimate.com/github/MiniProfiler/rack-mini-profiler/badges/gpa.svg)](https://codeclimate.com/github/MiniProfiler/rack-mini-profiler) [![Build Status](https://travis-ci.org/MiniProfiler/rack-mini-profiler.svg)](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
- * backtrace_filter - a regex you can use to filter out unwanted lines from the backtraces
173
- * toggle_shortcut (default Alt+P) - a jquery.hotkeys.js-style keyboard shortcut, used to toggle the mini_profiler's visibility. See http://code.google.com/p/js-hotkeys/ for more info.
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
@@ -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;
@@ -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 + '"] td');
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 colors['transparent'];
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(jQueryAjaxComplete);
469
+ jQuery(document).bind('ajaxComplete.mini-profiler', jQueryAjaxComplete);
460
470
  }
461
471
 
462
472
  if (jQuery && jQuery(document).ajaxStart)
463
- jQuery(document).ajaxStart(function () { ajaxStartTime = new Date(); });
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
- this._onreadystatechange = this.onreadystatechange;
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
- this.onreadystatechange = function onReadyStateChangeReplacement() {
540
- if (this.readyState == 4) {
541
- var stringIds = this.getResponseHeader('X-MiniProfiler-Ids');
542
- if (stringIds) {
543
- var ids = typeof JSON != 'undefined' ? JSON.parse(stringIds) : eval(stringIds);
544
- fetchResults(ids);
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
- return this._onreadystatechange.apply(this, arguments);
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.Timings.length; i++) {
694
- if (clientTiming.Timings[i].Name == name) {
695
- return clientTiming.Timings[i];
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.Timings) return [];
761
+ if (!clientTimings.timings) return [];
734
762
 
735
- for (var i = 0; i < clientTimings.Timings.length; i++) {
736
- t = clientTimings.Timings[i];
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.SqlTimings) {
756
- for (var i = 0, sqlTiming; i < timing.SqlTimings.length; i++) {
757
- sqlTiming = timing.SqlTimings[i];
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.ParentTimingName = timing.Name;
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.Children) {
766
- for (var i = 0; i < timing.Children.length; i++) {
767
- addToResults(timing.Children[i]);
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.StartMilliseconds, finish: (elem.StartMilliseconds + elem.DurationMilliseconds) };
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.Children) {
810
- for (var i = 0; i < elem.Children.length; i++) {
811
- processTimes(elem.Children[i], 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.StartMilliseconds - b.StartMilliseconds; });
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.Name, duration: overlap };
881
+ match = { name: node.name, duration: overlap };
841
882
  }
842
- else if (match.name == node.Name) {
883
+ else if (match.name == node.name) {
843
884
  match.duration += overlap;
844
885
  }
845
886
 
846
- if (node.Children) {
847
- for (var i = 0; i < node.Children.length; i++) {
848
- match = determineGap(gap, node.Children[i], match);
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.StartMilliseconds - time).toFixed(2),
899
+ duration: (this.start_milliseconds - time).toFixed(2),
859
900
  start: time,
860
- finish: this.StartMilliseconds
901
+ finish: this.start_milliseconds
861
902
  };
862
903
 
863
904
  this.prevGap.topReason = determineGap(this.prevGap, root, null);
864
905
 
865
- time = this.StartMilliseconds + this.DurationMilliseconds;
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.DurationMilliseconds - time).toFixed(2),
914
+ duration: (root.duration_milliseconds - time).toFixed(2),
874
915
  start: time,
875
- finish: root.DurationMilliseconds
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.SqlTimings) {
887
- result += timing.SqlTimings.length;
927
+ if (timing.sql_timings) {
928
+ result += timing.sql_timings.length;
888
929
  }
889
930
 
890
- if (timing.Children) {
891
- for (var i = 0; i < timing.Children.length; i++) {
892
- countSql(timing.Children[i]);
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
  };