speedup-rails 0.0.9 → 0.0.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/speedup_rails/results_controller.rb +8 -4
- data/app/views/speedup_rails/collectors/_queries.html.erb +1 -1
- data/app/views/speedup_rails/collectors/_rubyprof.html.erb +3 -1
- data/app/views/speedup_rails/results/show.html.erb +3 -3
- data/lib/speedup-rails.rb +6 -0
- data/lib/speedup-rails/engine.rb +5 -0
- data/lib/speedup/collectors/collector.rb +1 -1
- data/lib/speedup/collectors/rubyprof_collector.rb +40 -11
- data/lib/speedup/middleware.rb +8 -3
- data/lib/speedup/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0bb89c83b0040085db59dece30966f81ad22dfda
|
4
|
+
data.tar.gz: 4858351dc1b7ea0d8b502e337a2951df17fc6746
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 02c1eb941cb18965f599e74fbc2a58ac9126fb9f04de4c6a785c132ae2b0035ccd69b75b2fe4fae7c439b7d444648f4fcabb5f980cccf33d9ce3f7d1fc95d1c9
|
7
|
+
data.tar.gz: 429645d3ce4bf5ad83149a0f49676b83711287517ec9caad8b706187abe950a3d4344036273f9deb4bb95bf2d2434d5a1d0cf2ba5c52413d7cc08321bd63b422
|
@@ -4,13 +4,17 @@ module SpeedupRails
|
|
4
4
|
def show
|
5
5
|
@request_id = params[:id]
|
6
6
|
@request = Speedup::Request.get(@request_id)
|
7
|
-
@
|
8
|
-
|
9
|
-
|
7
|
+
if @request
|
8
|
+
@collectors = Speedup.collectors
|
9
|
+
@redirect = params[:redirect]
|
10
|
+
render layout: false
|
11
|
+
else
|
12
|
+
render nothing: true, status: :not_found
|
13
|
+
end
|
10
14
|
end
|
11
15
|
|
12
16
|
def rubyprof
|
13
|
-
send_file Rails.root.join('tmp', 'rubyprof', params[:id] ), :type => 'text/html', :disposition => 'inline'
|
17
|
+
send_file Rails.root.join('tmp', 'rubyprof', params[:id] + params[:prof_id]), :type => 'text/html', :disposition => 'inline'
|
14
18
|
end
|
15
19
|
|
16
20
|
end
|
@@ -21,7 +21,7 @@
|
|
21
21
|
</div>
|
22
22
|
|
23
23
|
<script type="text/javascript">
|
24
|
-
var traces = document.getElementById("
|
24
|
+
var traces = document.getElementById("speedup_<%= request_id %>_collectorinfo_<%= key %>").getElementsByClassName('backtrace')
|
25
25
|
for (var j = traces.length - 1; j >= 0; j--) {
|
26
26
|
traces[j].onclick = function() {
|
27
27
|
var i;
|
@@ -1,3 +1,5 @@
|
|
1
1
|
<span class="speedup_rails_<%= key %>" data-key="<%= key %>">
|
2
|
-
|
2
|
+
<% data.each do |prof_id| %>
|
3
|
+
<%= link_to 'ruby-prof_'+prof_id.to_s, rubyprof_result_path(@request_id, prof_id: prof_id), target: '_blank' %>
|
4
|
+
<% end %>
|
3
5
|
</span>
|
@@ -1,8 +1,8 @@
|
|
1
|
-
<ul class="speedup_main_bar
|
1
|
+
<ul class="speedup_main_bar <%= ' redirect' if @redirect %>">
|
2
2
|
<% @collectors.each do |col| %>
|
3
3
|
<% next unless col.render? %>
|
4
|
-
<li id="
|
5
|
-
<%= render "speedup_rails/collectors/#{col.key}", data: @request[col.key] || [], key: col.key, request_data: @request[:request], redirect: @redirect %>
|
4
|
+
<li id="speedup_<%= @request_id %>_collectorinfo_<%= col.key %>">
|
5
|
+
<%= render "speedup_rails/collectors/#{col.key}", request_id: @request_id, data: @request[col.key] || [], key: col.key, request_data: @request[:request], redirect: @redirect %>
|
6
6
|
</li>
|
7
7
|
<% end %>
|
8
8
|
</ul>
|
data/lib/speedup-rails.rb
CHANGED
@@ -86,6 +86,12 @@ module Speedup
|
|
86
86
|
@collectors
|
87
87
|
end
|
88
88
|
|
89
|
+
def self.profile(&block)
|
90
|
+
@rubyprof ||= @collectors.detect{|c| c.key == :rubyprof}
|
91
|
+
raise "You need to enable rubyprof collector to profile!" unless @rubyprof
|
92
|
+
@rubyprof.profile(&block)
|
93
|
+
end
|
94
|
+
|
89
95
|
end
|
90
96
|
|
91
97
|
ActiveSupport.run_load_hooks(:speedup, Speedup) if Speedup.enabled?
|
data/lib/speedup-rails/engine.rb
CHANGED
@@ -34,6 +34,11 @@ module SpeedupRails
|
|
34
34
|
config.speedup.show_bar = Rails.env.development?
|
35
35
|
config.speedup.automount = true
|
36
36
|
|
37
|
+
initializer :assets do |config|
|
38
|
+
Rails.application.config.assets.precompile += %w(speedup_rails/icons.png)
|
39
|
+
Rails.application.config.assets.paths << root.join("app", "assets", "images")
|
40
|
+
end
|
41
|
+
|
37
42
|
initializer 'speedup.set_configs' do |app|
|
38
43
|
ActiveSupport.on_load(:speedup) do
|
39
44
|
app.config.speedup.each do |k,v|
|
@@ -70,7 +70,7 @@ module Speedup
|
|
70
70
|
# Uses a event_to_data method.
|
71
71
|
def store_event(evt, key=nil)
|
72
72
|
key ||= self.key
|
73
|
-
Speedup.request.store_event(key, event_to_data(evt) )
|
73
|
+
Speedup.request.store_event(key, event_to_data(evt) ) if Speedup.request
|
74
74
|
end
|
75
75
|
|
76
76
|
# Transfer the event to actual stored data.
|
@@ -10,7 +10,7 @@ module Speedup
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def parse_options
|
13
|
-
|
13
|
+
@profile_request = !!@options[:profile_request]
|
14
14
|
end
|
15
15
|
|
16
16
|
# The data results that are inserted at the end of the request for use in
|
@@ -22,16 +22,12 @@ module Speedup
|
|
22
22
|
end
|
23
23
|
|
24
24
|
def setup_subscribes
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
# Print a flat profile to text
|
32
|
-
printer = RubyProf::CallStackPrinter.new(result)
|
33
|
-
::File.open(@results_dir.join( Speedup.request.id ), 'wb') do |file|
|
34
|
-
printer.print(file)
|
25
|
+
if enabled? && @profile_request
|
26
|
+
before_request do
|
27
|
+
start_prof
|
28
|
+
end
|
29
|
+
after_request do
|
30
|
+
end_prof
|
35
31
|
end
|
36
32
|
end
|
37
33
|
end
|
@@ -41,6 +37,39 @@ module Speedup
|
|
41
37
|
super || evt.payload[:controller].start_with?('Speedup')
|
42
38
|
end
|
43
39
|
|
40
|
+
def start_prof
|
41
|
+
RubyProf.start
|
42
|
+
end
|
43
|
+
|
44
|
+
def end_prof(result_id=nil)
|
45
|
+
result = RubyProf.stop
|
46
|
+
|
47
|
+
Speedup.request.store_event(key, result_id )
|
48
|
+
|
49
|
+
# Print a flat profile to text
|
50
|
+
printer = printer_klass.new(result)
|
51
|
+
::File.open(@results_dir.join( Speedup.request.id + result_id.to_s ), 'wb') do |file|
|
52
|
+
printer.print(file)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def profile(result_id=nil, &block)
|
57
|
+
start_prof
|
58
|
+
yield
|
59
|
+
end_prof(next_id)
|
60
|
+
end
|
61
|
+
|
62
|
+
private
|
63
|
+
|
64
|
+
def next_id
|
65
|
+
@next_id = @next_id.to_i + 1
|
66
|
+
end
|
67
|
+
|
68
|
+
def printer_klass
|
69
|
+
# RubyProf::GraphHtmlPrinter
|
70
|
+
RubyProf::CallStackPrinter
|
71
|
+
end
|
72
|
+
|
44
73
|
end
|
45
74
|
end
|
46
75
|
end
|
data/lib/speedup/middleware.rb
CHANGED
@@ -31,6 +31,10 @@ module Speedup
|
|
31
31
|
raise exception
|
32
32
|
end
|
33
33
|
|
34
|
+
def speedup_request?(env)
|
35
|
+
env['REQUEST_PATH'].starts_with?('/speedup_rails')
|
36
|
+
end
|
37
|
+
|
34
38
|
class SpeedupBody
|
35
39
|
include Enumerable
|
36
40
|
|
@@ -88,8 +92,9 @@ module Speedup
|
|
88
92
|
end
|
89
93
|
str << "if( typeof jQuery !== 'undefined' ) {
|
90
94
|
jQuery(document).ajaxComplete(function(evt, xhr, settings){
|
91
|
-
|
92
|
-
|
95
|
+
var request_id = xhr.getResponseHeader('X-Request-Id');
|
96
|
+
if( request_id && !settings.url.match('#{SpeedupRails::Engine.routes.url_helpers.result_path('')}') )
|
97
|
+
loadRequestData('#{SpeedupRails::Engine.routes.url_helpers.result_path('REQUEST_ID')}'.replace('REQUEST_ID', request_id));
|
93
98
|
});
|
94
99
|
}"
|
95
100
|
str << '</script>'
|
@@ -138,7 +143,7 @@ module Speedup
|
|
138
143
|
right: 0;
|
139
144
|
padding: 5px;
|
140
145
|
display: none;
|
141
|
-
height: 500px;
|
146
|
+
max-height: 500px;
|
142
147
|
max-width: 200%;
|
143
148
|
overflow: scroll;
|
144
149
|
}
|
data/lib/speedup/version.rb
CHANGED
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.
|
4
|
+
version: 0.0.10
|
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:
|
11
|
+
date: 2016-01-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -562,7 +562,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
562
562
|
version: '0'
|
563
563
|
requirements: []
|
564
564
|
rubyforge_project:
|
565
|
-
rubygems_version: 2.
|
565
|
+
rubygems_version: 2.5.1
|
566
566
|
signing_key:
|
567
567
|
specification_version: 4
|
568
568
|
summary: SpeedUpRails provide analyzing and motitoring tool for rails.
|