speedup-rails 0.0.7 → 0.0.9

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e20b0e2c53cfa6c365ee4130ec61313c490dab7f
4
- data.tar.gz: 3c71390f34b1e23c53a6d351f2a4455886277ce7
3
+ metadata.gz: a79adaf0346b1581840b1cbc3d88f33e31f31b0e
4
+ data.tar.gz: 877452dc9f81628257b2e844c0f6a53025d368bf
5
5
  SHA512:
6
- metadata.gz: 9df81c075bda9ecce97d80336232ff0d1690651e6ff102125ea2941ea29c7e66b767fb0f68c519ea4bdeff683f91142eb0198b84cb28789ba0d470200dccc535
7
- data.tar.gz: c73178b30a4f83c81085562090f4122bc3c5154449c12d188f11d1bc76000f9a4cd5a5c5bb5c3ee60ddad83b631a6601d0ccb82468a4fff31c4d3f987dd8033a
6
+ metadata.gz: 5d94ee85e7b3efbd8461ccb7b78bf86b871a115d5437cd488874b1337a5cebb25347cabb88c2d5f0cfb145373b3bf6575e798dca1b659bd066d450ecf28867e9
7
+ data.tar.gz: 8a626e5ceb3d20502ddcc69d9fb1e1985bbd160eacd6779720f95be6ac39a95e011326ea3480f72a8bc35d9fea070afa4f7daa9f47ff2719db9f916dd22b213a
@@ -2,6 +2,7 @@ module SpeedupRails
2
2
  module ApplicationHelper
3
3
 
4
4
  def render_ms(value)
5
+ return nil unless value
5
6
  ((value * 100).round.to_f / 100).to_s + ' ms'
6
7
  end
7
8
 
@@ -1,5 +1,8 @@
1
+ <div class="icon_container">
2
+ <%= image_tag('speedup_rails/icons.png', alt: '', style: 'clip: rect(0, 20px, 20px, 0px); left: 0;') %>
3
+ </div>
1
4
  <span class="speedup_rails_<%= key %>" data-key="<%= key %>">
2
- <%= image_tag('speedup_rails/alert.jpg', alt: '') %><%= data.count %> problems
5
+ <%= data.count %> problems
3
6
  </span>
4
7
  <% if data.any? %>
5
8
  <div class="additional_info">
@@ -1,13 +1,21 @@
1
+ <div class="icon_container">
2
+ <%= image_tag('speedup_rails/icons.png', alt: '', style: 'clip: rect(0, 60px, 20px, 40px); left: -40px;') %>
3
+ </div>
1
4
  <span class="speedup_rails_<%= key %>" data-key="<%= key %>">
2
- <%= image_tag('speedup_rails/file-icon.png', alt: '') %><%= data.count %> partials (<%= render_ms(request_data[:view_duration]) %>)
5
+ <%= data.count %> partials
6
+ <% unless redirect %>
7
+ (<%= render_ms(request_data[:view_duration]) %>)
8
+ <% end %>
3
9
  </span>
4
- <div class="additional_info">
5
- <div class="partials">
6
- <% data.each do |template| %>
7
- <div>
8
- <span class="duration <%= template[:duration] > 100 ? 'duration-warning' : 'duration-info' %>"><%= render_ms(template[:duration]) %></span>
9
- <span class="template"><%= template[:identifier] %></span>
10
- </div>
11
- <% end %>
10
+ <% if data.any? %>
11
+ <div class="additional_info">
12
+ <div class="partials">
13
+ <% data.each do |template| %>
14
+ <div>
15
+ <span class="duration <%= template[:duration] > 100 ? 'duration-warning' : 'duration-info' %>"><%= render_ms(template[:duration]) %></span>
16
+ <span class="template"><%= template[:identifier] %></span>
17
+ </div>
18
+ <% end %>
19
+ </div>
12
20
  </div>
13
- </div>
21
+ <% end %>
@@ -1,5 +1,8 @@
1
+ <div class="icon_container">
2
+ <%= image_tag('speedup_rails/icons.png', alt: '', style: 'clip: rect(0, 40px, 20px, 20px); left: -20px;') %>
3
+ </div>
1
4
  <span class="speedup_rails_<%= key %>" data-key="<%= key %>">
2
- <%= image_tag('speedup_rails/database.png', alt: '') %><%= data.count %> queries (<%= render_ms(data.sum{|t| t[:duration] }) %>)
5
+ <%= data.count %> queries (<%= render_ms(data.sum{|t| t[:duration] }) %>)
3
6
  </span>
4
7
  <div class="additional_info">
5
8
  <div class="queries">
@@ -7,7 +10,25 @@
7
10
  <div>
8
11
  <span class="duration <%= query[:duration] > 10 ? 'duration-warning' : 'duration-info' %>"><%= render_ms(query[:duration])%></span>
9
12
  <span class="query"><%= query[:query] %></span>
13
+ <div class="backtrace">
14
+ <% query[:backtrace].each do |line| %>
15
+ <span class="backtrace_line"><%= line %><br/></span>
16
+ <% end %>
17
+ </div>
10
18
  </div>
11
19
  <% end %>
12
20
  </div>
13
21
  </div>
22
+
23
+ <script type="text/javascript">
24
+ var traces = document.getElementById("speedup_collectorinfo_<%= key %>").getElementsByClassName('backtrace')
25
+ for (var j = traces.length - 1; j >= 0; j--) {
26
+ traces[j].onclick = function() {
27
+ var i;
28
+ var x = this.getElementsByClassName("backtrace_line");
29
+ for (i = 0; i < x.length; i++) {
30
+ x[i].style.display = "inline";
31
+ }
32
+ };
33
+ };
34
+ </script>
@@ -1,5 +1,14 @@
1
+ <div class="icon_container">
2
+ <%= image_tag('speedup_rails/icons.png', alt: '', style: 'clip: rect(0, 80px, 20px, 60px); left: -60px;') %>
3
+ </div>
1
4
  <span class="speedup_rails_<%= key %>" data-key="<%= key %>">
2
-
3
- <%= image_tag('speedup_rails/input.png', alt: '') %> <%= data[:controller] %>#<%= data[:action] %>
4
- <%= image_tag('speedup_rails/time.png', alt: '') %> <%= (data[:duration] * 100).round.to_f / 100 %> ms
5
+ <%= data[:controller] %>#<%= data[:action] %>
6
+ </span>
7
+ </li>
8
+ <li id="speedup_collectorinfo_request2">
9
+ <div class="icon_container">
10
+ <%= image_tag('speedup_rails/icons.png', alt: '', style: 'clip: rect(0, 100px, 20px, 80px); left: -80px;') %>
11
+ </div>
12
+ <span class="speedup_rails_<%= key %>" data-key="<%= key %>">
13
+ <%= (data[:duration] * 100).round.to_f / 100 %> ms
5
14
  </span>
@@ -1,8 +1,8 @@
1
1
  <ul class="speedup_main_bar speedup_main_bar_<%= @redirect %><%= ' redirect' if @redirect %>">
2
2
  <% @collectors.each do |col| %>
3
3
  <% next unless col.render? %>
4
- <li>
5
- <%= render "speedup_rails/collectors/#{col.key}", data: @request[col.key] || [], key: col.key, request_data: @request[:request] %>
4
+ <li id="speedup_collectorinfo_<%= col.key %>">
5
+ <%= render "speedup_rails/collectors/#{col.key}", data: @request[col.key] || [], key: col.key, request_data: @request[:request], redirect: @redirect %>
6
6
  </li>
7
7
  <% end %>
8
8
  </ul>
@@ -85,6 +85,10 @@ module Speedup
85
85
 
86
86
  protected
87
87
 
88
+ def clean_trace
89
+ Rails.backtrace_cleaner.clean(caller[2..-1])
90
+ end
91
+
88
92
  def setup_subscribes
89
93
  # pass
90
94
  end
@@ -12,7 +12,7 @@ module Speedup
12
12
  end
13
13
 
14
14
  def event_to_data(evt)
15
- {time: evt.time, duration: evt.duration, name: evt.payload[:name], query: evt.payload[:sql]}
15
+ {time: evt.time, duration: evt.duration, name: evt.payload[:name], query: evt.payload[:sql], backtrace: clean_trace}
16
16
  end
17
17
 
18
18
  end
@@ -29,7 +29,7 @@ module Speedup
29
29
  result = RubyProf.stop if enabled?
30
30
 
31
31
  # Print a flat profile to text
32
- printer = RubyProf::GraphHtmlPrinter.new(result)
32
+ printer = RubyProf::CallStackPrinter.new(result)
33
33
  ::File.open(@results_dir.join( Speedup.request.id ), 'wb') do |file|
34
34
  printer.print(file)
35
35
  end
@@ -86,6 +86,12 @@ module Speedup
86
86
  @redirects.each_with_index do |req_id, idx|
87
87
  str << " loadRequestData('#{SpeedupRails::Engine.routes.url_helpers.result_path(req_id, redirect: idx)}');"
88
88
  end
89
+ str << "if( typeof jQuery !== 'undefined' ) {
90
+ jQuery(document).ajaxComplete(function(evt, xhr, settings){
91
+ if(! settings.url.match('#{SpeedupRails::Engine.routes.url_helpers.result_path('')}') )
92
+ loadRequestData('#{SpeedupRails::Engine.routes.url_helpers.result_path('REQUEST_ID')}'.replace('REQUEST_ID', xhr.getResponseHeader('X-Request-Id')));
93
+ });
94
+ }"
89
95
  str << '</script>'
90
96
  str
91
97
  end
@@ -100,7 +106,7 @@ module Speedup
100
106
  bottom: 5px;
101
107
  right: 5px;
102
108
  min-width: 250px;
103
- z-index: 100;
109
+ z-index: 8;
104
110
  }
105
111
  #speedup_rails_bar .redirect {
106
112
  color: #444;
@@ -115,8 +121,17 @@ module Speedup
115
121
  overflow: auto;
116
122
  font: normal normal 12px/21px Tahoma, sans-serif;
117
123
  }
118
- #speedup_rails_bar > ul { list-style: none; clear: left; margin: 0; padding: 0; margin-left: 4px; }
119
- #speedup_rails_bar > ul > li { float: left; overflow: visible; }
124
+ #speedup_rails_bar > ul.speedup_main_bar {
125
+ list-style: none;
126
+ clear: left;
127
+ margin: 0;
128
+ padding: 0;
129
+ margin-left: 4px;
130
+ overflow: visible;
131
+ position: relative;
132
+ height: 22px;
133
+ }
134
+ #speedup_rails_bar > ul > li { float: left; padding-left: 5px; }
120
135
  #speedup_rails_bar .additional_info {
121
136
  position: absolute;
122
137
  bottom: 100%;
@@ -124,15 +139,17 @@ module Speedup
124
139
  padding: 5px;
125
140
  display: none;
126
141
  height: 500px;
142
+ max-width: 200%;
143
+ overflow: scroll;
127
144
  }
128
- #speedup_rails_bar > ul > li:hover .additional_info { display: block; max-width: 200%; }
129
- #speedup_rails_bar li > span { padding: 0 4px; }
130
- #speedup_rails_bar img {
131
- vertical-align: middle;
145
+ #speedup_rails_bar > ul > li:hover .additional_info { display: block; }
146
+ #speedup_rails_bar li > span { padding: 0 2px; margin-left: 20px; }
147
+ #speedup_rails_bar .icon_container {
132
148
  position: relative;
133
- top: -1px;
134
- margin-right: 3px;
135
- width: 18px;
149
+ }
150
+ #speedup_rails_bar .icon_container img {
151
+ position: absolute;
152
+ max-width: 100px;
136
153
  }
137
154
  #speedup_rails_bar .additional_info > div > div {
138
155
  border-bottom: 1px solid #c9c9c9;
@@ -146,6 +163,14 @@ module Speedup
146
163
  #speedup_rails_bar .additional_info .duration.duration-warning {
147
164
  color: red;
148
165
  }
166
+ #speedup_rails_bar .additional_info .backtrace {
167
+ font-size: 95%;
168
+ margin: 5px 0 0 20px;
169
+ line-height: 1.4em;
170
+ }
171
+ #speedup_rails_bar .additional_info .backtrace .backtrace_line:not(:first-child) {
172
+ display: none;
173
+ }
149
174
  </style>
150
175
  END_STYLES
151
176
  end
@@ -1,3 +1,3 @@
1
1
  module Speedup
2
- VERSION = "0.0.7"
2
+ VERSION = "0.0.9"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: speedup-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ondřej Ezr
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-11-30 00:00:00.000000000 Z
11
+ date: 2015-12-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -176,6 +176,7 @@ files:
176
176
  - app/assets/images/speedup_rails/alert.jpg
177
177
  - app/assets/images/speedup_rails/database.png
178
178
  - app/assets/images/speedup_rails/file-icon.png
179
+ - app/assets/images/speedup_rails/icons.png
179
180
  - app/assets/images/speedup_rails/input.png
180
181
  - app/assets/images/speedup_rails/time.png
181
182
  - app/assets/javascripts/speedup_rails/application.js