rack-mini-profiler 0.9.1 → 0.9.6
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 +163 -0
- data/README.md +19 -4
- 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 +10 -10
- data/lib/mini_profiler/profiler.rb +162 -93
- 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 +13 -3
- 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 +19 -15
- metadata +19 -11
- data/CHANGELOG +0 -181
- 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: e83bf4519ed83cd942b168c34783ee321a34e63f
|
|
4
|
+
data.tar.gz: f53964ce3946d426cac21d760e49ee37cf5e0fea
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a2e447437d2fb8dc5872fe3d751ee535b0bdb0e6a6e35644b0627412b126ce80535571c63408a0845f71aa5afc3065ce75fc8482746dd7ba617e60d0a69efa05
|
|
7
|
+
data.tar.gz: 81c35341c085d80ac5eee5b2423cdb8c6e3dbb9f9d3d08493ddb613b7349aa107dcffe4b7e5d54217066f54425269b29d65592519b35f84d1755411fc327ab0d
|
data/CHANGELOG.md
ADDED
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
# CHANGELOG
|
|
2
|
+
|
|
3
|
+
## 0.9.6 - 2014-07-08 (Sam Saffron)
|
|
4
|
+
|
|
5
|
+
- [FIX] incorrect truncation in pp=analyze-memory
|
|
6
|
+
|
|
7
|
+
## 0.9.5 - 2014-07-08 (Sam Saffron)
|
|
8
|
+
|
|
9
|
+
- [FEATURE] improve pp=analyze-memory
|
|
10
|
+
|
|
11
|
+
## 0.9.4 - 2014-07-08 (Sam Saffron)
|
|
12
|
+
- [UX] added a link to "more" actions in profiler
|
|
13
|
+
- [FEATURE] pp=help now displays links
|
|
14
|
+
- [FEATURE] simple memory report with pp=analyze-memory
|
|
15
|
+
|
|
16
|
+
## 0.9.2 - 2014-06-26 (Sam Saffron)
|
|
17
|
+
- [CHANGE] staging and other environments behave like production (Cedric Felizard)
|
|
18
|
+
- [DOC] CHANGELOG reorg (Olivier Lacan)
|
|
19
|
+
- [FIXED] Double calls to Rack::MiniProfilerRails.initialize! now raise an exception (Julik Tarkhanov)
|
|
20
|
+
- [FIXED] Add no-store header (George Mendoza)
|
|
21
|
+
|
|
22
|
+
## 0.9.1 - 2014-03-13 (Sam Saffron)
|
|
23
|
+
- [ADDED] Added back Ruby 1.8 support (thanks Malet)
|
|
24
|
+
- [IMPROVED] Amended Railstie so MiniProfiler can be launched with action view or action controller (Thanks Akira)
|
|
25
|
+
- [FIXED] Rails 3.0 support (thanks Zlatko)
|
|
26
|
+
- [FIXED] Possible XSS (admin only)
|
|
27
|
+
- [FIXED] Corrected Sql patching to avoid setting instance vars on nil which is frozen (thanks Andy, huoxito)
|
|
28
|
+
|
|
29
|
+
## 0.9.0.pre - 2013-12-12 (Sam Saffron)
|
|
30
|
+
- Bumped up version to reflect the stability of the project
|
|
31
|
+
- [IMPROVED] Reports for pp=profile-gc
|
|
32
|
+
- [IMPROVED] pp=flamegraph&flamegraph_sample_rate=1 , allow you to specify sampling rates
|
|
33
|
+
|
|
34
|
+
## 2013-09-17 (Ross Wilson)
|
|
35
|
+
- [IMPROVED] Instead of supressing all "/assets/" requests we now check the configured
|
|
36
|
+
config.assets.prefix path since developers can rename the path to serve Asset Pipeline
|
|
37
|
+
files from
|
|
38
|
+
|
|
39
|
+
## 2013-09-03
|
|
40
|
+
- [IMPROVED] Flamegraph now has much increased fidelity
|
|
41
|
+
- [REMOVED] Ripped out flamegraph so it can be isolated into a gem
|
|
42
|
+
- [REMOVED] Ripped out pp=sample it just was never really used
|
|
43
|
+
|
|
44
|
+
## 1.30 - 2013-08-30
|
|
45
|
+
- [ADDED] Rack::MiniProfiler.counter_method(klass,name) for injecting counters
|
|
46
|
+
- [FIXED] Counters were not shifting the table correctly
|
|
47
|
+
|
|
48
|
+
## 1.29 - 2013-08-20
|
|
49
|
+
- [ADDED] Implemented exception tracing using TracePoint see pp=trace-exceptions
|
|
50
|
+
- [FIXED] SOLR patching had an incorrect monkey patch
|
|
51
|
+
|
|
52
|
+
## 1.28 - 2012-07-18
|
|
53
|
+
- [FIXED] Diagnostics in abstract storage was raising not implemented killing
|
|
54
|
+
?pp=env and others
|
|
55
|
+
- [FIXED] SOLR xml unescaped by mistake
|
|
56
|
+
|
|
57
|
+
## 1.27 - 2013-06-26
|
|
58
|
+
- [ADDED] Rack::MiniProfiler.config.backtrace_threshold_ms
|
|
59
|
+
- [ADDED] jQuery 2.0 support
|
|
60
|
+
- [FIXED] Disabled global ajax handlers on MP requests @JP
|
|
61
|
+
|
|
62
|
+
## 1.26 - 2013-04-11
|
|
63
|
+
- [IMPROVED] Allow Rack::MiniProfilerRails.initialize!(Rails.application), for post config intialization
|
|
64
|
+
|
|
65
|
+
## 1.25 - 2013-04-08
|
|
66
|
+
- [FIXED] Missed flamegraph.html from build
|
|
67
|
+
|
|
68
|
+
## 1.24 - 2013-04-08
|
|
69
|
+
- [ADDED] Flame Graph Support see: http://samsaffron.com/archive/2013/03/19/flame-graphs-in-ruby-miniprofiler
|
|
70
|
+
- [ADDED] New toggle_shortcut and start_hidden options
|
|
71
|
+
- [ADDED] Mongoid support
|
|
72
|
+
- [ADDED] Rack::MiniProfiler.counter counter_name {}
|
|
73
|
+
- [ADDED] Net:HTTP profiling
|
|
74
|
+
- [ADDED] Ruby 1.8.7 support ... grrr
|
|
75
|
+
- [IMPROVED] More robust gc profiling
|
|
76
|
+
- [IMPROVED] Script tag initialized via data-attributes
|
|
77
|
+
- [IMPROVED] Allow usage of existing jQuery if its already loaded
|
|
78
|
+
- [IMPROVED] Pre-authorize to run in all non development? and production? modes
|
|
79
|
+
- [FIXED] AngularJS support and MooTools
|
|
80
|
+
- [FIXED] File retention leak in file_store
|
|
81
|
+
- [FIXED] HTML5 implicit <body> tags
|
|
82
|
+
- [FIXED] pp=enable
|
|
83
|
+
|
|
84
|
+
## 1.22 - 2012-09-20
|
|
85
|
+
- [FIXED] Permission issue in the gem
|
|
86
|
+
|
|
87
|
+
## 17-September-2012
|
|
88
|
+
- [IMPROVED] Allow rack-mini-profiler to be sourced from github
|
|
89
|
+
- [IMPROVED] Extracted the pp=profile-gc-time out, the object space profiler needs to disable gc
|
|
90
|
+
|
|
91
|
+
## 1.21 - 2012-09-17
|
|
92
|
+
- [ADDED] New MemchacedStore
|
|
93
|
+
- [ADDED] Rails 4 support
|
|
94
|
+
|
|
95
|
+
## 2012-09-12 (Sam Saffron)
|
|
96
|
+
- [ADDED] pp=profile-gc: allows you to profile the GC in Ruby 1.9.3
|
|
97
|
+
|
|
98
|
+
## 1.19 - 2012-09-10 (Sam Saffron)
|
|
99
|
+
- [FIXED] Compatibility issue with Ruby 1.8.7
|
|
100
|
+
|
|
101
|
+
## 1.17 - 2012-09-09 (Sam Saffron)
|
|
102
|
+
- [FIXED] pp=sample was bust unless stacktrace was installed
|
|
103
|
+
|
|
104
|
+
## 1.16 - 2012-09-05 (Sam Saffron)
|
|
105
|
+
- [IMPROVED] Implemented stacktrace properly
|
|
106
|
+
- [FIXED] Long standing problem specs (issue with memory store)
|
|
107
|
+
- [FIXED] Issue where profiler would be dumped when you got a 404 in production (and any time rails is bypassed)
|
|
108
|
+
|
|
109
|
+
## 1.15.pre - 2012-09-04 (Sam Saffron)
|
|
110
|
+
- [FIXED] Annoying bug where client settings were not sticking
|
|
111
|
+
- [FIXED] Long standing issue with Rack::ConditionalGet stopping MiniProfiler from working properly
|
|
112
|
+
|
|
113
|
+
## 1.13.pre - 2012-09-03 (Sam Saffron)
|
|
114
|
+
- [ADDED] Setting: config.backtrace_ignores = [] - an array of regexes that match on caller lines that get ignored
|
|
115
|
+
- [ADDED] Setting: config.backtrace_includes = [] - an array of regexes that get included in the trace by default
|
|
116
|
+
- [ADDED] pp=normal-backtrace to clear the "sticky" state
|
|
117
|
+
- [IMPROVED] Cleaned up the way client settings are stored
|
|
118
|
+
- [IMPROVED] Made pp=full-backtrace "sticky"
|
|
119
|
+
- [IMPROVED] Changed "pp=sample" to work with "caller" no need for stack trace gem
|
|
120
|
+
- [FIXED] pg gem prepared statements were not being logged correctly
|
|
121
|
+
|
|
122
|
+
## 1.12.pre - 2012-08-20 (Sam Saffron)
|
|
123
|
+
- [IMPROVED] Cap X-MiniProfiler-Ids at 10, otherwise the header can get killed
|
|
124
|
+
|
|
125
|
+
## 2012-08-10 (Sam Saffron)
|
|
126
|
+
- [ADDED] Basic prepared statement profiling for Postgres
|
|
127
|
+
|
|
128
|
+
## 2012-08-07 (Sam Saffron)
|
|
129
|
+
- [ADDED] Option to disable profiler for the current session (pp=disable / pp=enable)
|
|
130
|
+
- [ADDED] yajl compatability contributed by Sven Riedel
|
|
131
|
+
|
|
132
|
+
## 0.1.9 - 2012-07-30 (Sam Saffron)
|
|
133
|
+
- [IMPROVED] Made compliant with ancient versions of Rack (including Rack used by Rails2)
|
|
134
|
+
- [FIXED] Broken share link
|
|
135
|
+
- [FIXED] Crashes on startup (in MemoryStore and FileStore)
|
|
136
|
+
- [FIXED] Unicode issue
|
|
137
|
+
|
|
138
|
+
## 0.1.7 - 2012-07-18 (Sam Saffron)
|
|
139
|
+
- [ADDED] First Paint time for Google Chrome
|
|
140
|
+
- [FIXED] Ensure non Rails installs have mini profiler
|
|
141
|
+
|
|
142
|
+
## 2012-07-12 (Sam Saffron)
|
|
143
|
+
- [ADDED] Native PG and MySql2 interceptors, this gives way more accurate times
|
|
144
|
+
- [ADDED] some more client probing built in to rails
|
|
145
|
+
- [IMPROVED] Refactored context so its a proper class and not a hash
|
|
146
|
+
- [IMPROVED] More tests
|
|
147
|
+
- [FIXED] Incorrect profiling steps (was not indenting or measuring start time right
|
|
148
|
+
|
|
149
|
+
## 0.1.3 - 2012-07-09 (Sam Saffron)
|
|
150
|
+
- [ADDED] New option to display full backtraces pp=full-backtrace
|
|
151
|
+
- [IMPROVED] Cleaned up mechanism for profiling in production, all you need to do now
|
|
152
|
+
is call Rack::MiniProfiler.authorize_request to get profiling working in
|
|
153
|
+
production
|
|
154
|
+
- [IMPROVED] Cleaned up railties, got rid of the post authorize callback
|
|
155
|
+
|
|
156
|
+
## 2012-06-28 (Sam Saffron)
|
|
157
|
+
- [ADDED] Started change log
|
|
158
|
+
- [ADDED] added MemcacheStore
|
|
159
|
+
- [IMPROVED] Corrected profiler so it properly captures POST requests (was supressing non 200s)
|
|
160
|
+
- [IMPROVED] Amended Rack.MiniProfiler.config[:user_provider] to use ip addres for identity
|
|
161
|
+
- [IMPROVED] Supress all '/assets/' in the rails tie (makes debugging easier)
|
|
162
|
+
- [FIXED] Issue where unviewed missing ids never got cleared
|
|
163
|
+
- [FIXED] record_sql was mega buggy
|
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
|
|
|
@@ -49,6 +48,8 @@ Or you want to execute some code before rack_mini_profiler required.
|
|
|
49
48
|
```ruby
|
|
50
49
|
gem 'rack-mini-profiler', require: false
|
|
51
50
|
```
|
|
51
|
+
Note the `require: false` part - if omitted, it will cause the Railtie for the mini-profiler to
|
|
52
|
+
be loaded outright, and an attempt to re-initialize it manually will raise an exception.
|
|
52
53
|
|
|
53
54
|
Then put initialize code in file like `config/initializers/rack_profiler.rb`
|
|
54
55
|
|
|
@@ -85,7 +86,7 @@ end
|
|
|
85
86
|
|
|
86
87
|
To generate [flamegraphs](http://samsaffron.com/archive/2013/03/19/flame-graphs-in-ruby-miniprofiler):
|
|
87
88
|
|
|
88
|
-
* add the **flamegraph** gem to your Gemfile
|
|
89
|
+
* add the [**flamegraph**](https://github.com/SamSaffron/flamegraph) gem to your Gemfile
|
|
89
90
|
* visit a page in your app with `?pp=flamegraph`
|
|
90
91
|
|
|
91
92
|
Flamegraph generation is supported in MRI 2.0 and 2.1 only.
|
|
@@ -110,6 +111,19 @@ Various aspects of rack-mini-profiler's behavior can be configured when your app
|
|
|
110
111
|
For example in a Rails app, this should be done in an initializer:
|
|
111
112
|
**config/initializers/mini_profiler.rb**
|
|
112
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
|
+
|
|
113
127
|
### Storage
|
|
114
128
|
|
|
115
129
|
rack-mini-profiler stores its results so they can be shared later and aren't lost at the end of the request.
|
|
@@ -165,10 +179,11 @@ The available configuration options are:
|
|
|
165
179
|
|
|
166
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.
|
|
167
181
|
* position - Can either be 'right' or 'left'. Default is 'left'.
|
|
182
|
+
* skip_paths - Specifies path list that can be skipped.
|
|
168
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.
|
|
169
184
|
* auto_inject (default true) - when false the miniprofiler script is not injected in the page
|
|
170
185
|
* backtrace_filter - a regex you can use to filter out unwanted lines from the backtraces
|
|
171
|
-
* toggle_shortcut (default Alt+P) - a jquery.hotkeys.js-style keyboard shortcut, used to toggle the mini_profiler's visibility. See
|
|
186
|
+
* 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.
|
|
172
187
|
* start_hidden (default false) - Whether or not you want the mini_profiler to be visible when loading a page
|
|
173
188
|
* 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.
|
|
174
189
|
* 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
|
};
|