tuttle 0.0.4 → 0.0.5
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 +9 -0
- data/app/controllers/tuttle/active_model_serializers_controller.rb +26 -0
- data/app/controllers/tuttle/active_support_controller.rb +26 -0
- data/app/controllers/tuttle/cancancan_controller.rb +1 -0
- data/app/controllers/tuttle/gems_controller.rb +4 -0
- data/app/controllers/tuttle/home_controller.rb +1 -3
- data/app/controllers/tuttle/performance_tuning_controller.rb +14 -0
- data/app/controllers/tuttle/rails_controller.rb +20 -18
- data/app/controllers/tuttle/request_controller.rb +16 -0
- data/app/controllers/tuttle/ruby_controller.rb +2 -0
- data/app/helpers/tuttle/application_helper.rb +8 -0
- data/app/views/layouts/tuttle/application.html.erb +22 -7
- data/app/views/tuttle/active_model_serializers/index.html.erb +86 -0
- data/app/views/tuttle/active_model_serializers/index9.html.erb +68 -0
- data/app/views/tuttle/active_support/dependencies.html.erb +72 -0
- data/app/views/tuttle/active_support/index.html.erb +69 -0
- data/app/views/tuttle/{rails → active_support}/inflectors.html.erb +0 -0
- data/app/views/tuttle/active_support/time_zones.html.erb +24 -0
- data/app/views/tuttle/cancancan/rule_tester.html.erb +1 -20
- data/app/views/tuttle/devise/index.html.erb +62 -9
- data/app/views/tuttle/gems/get_process_mem.html.erb +92 -0
- data/app/views/tuttle/gems/other.html.erb +102 -0
- data/app/views/tuttle/home/index.html.erb +1 -1
- data/app/views/tuttle/performance_tuning/index.html.erb +79 -0
- data/app/views/tuttle/rails/assets.html.erb +38 -43
- data/app/views/tuttle/rails/database.html.erb +2 -2
- data/app/views/tuttle/rails/engines.html.erb +40 -0
- data/app/views/tuttle/rails/generators.html.erb +74 -0
- data/app/views/tuttle/rails/index.html.erb +62 -86
- data/app/views/tuttle/rails/models.html.erb +16 -1
- data/app/views/tuttle/rails/schema_cache.html.erb +3 -1
- data/app/views/tuttle/request/index.html.erb +37 -0
- data/app/views/tuttle/ruby/index.html.erb +65 -0
- data/config/routes.rb +19 -3
- data/lib/tuttle.rb +6 -1
- data/lib/tuttle/engine.rb +23 -61
- data/lib/tuttle/instrumenter.rb +38 -0
- data/lib/tuttle/middleware/request_profiler.rb +80 -0
- data/lib/tuttle/ruby_prof/fast_call_stack_printer.rb +164 -0
- data/lib/tuttle/version.rb +1 -1
- metadata +21 -21
- data/app/assets/images/tuttle/favicon.ico +0 -0
- data/app/assets/javascripts/tuttle/application.js +0 -12
- data/app/assets/stylesheets/tuttle/application.css +0 -71
@@ -0,0 +1,164 @@
|
|
1
|
+
require 'ruby-prof/printers/call_stack_printer'
|
2
|
+
|
3
|
+
# This is a modified version of the RubyProf::CallStackPrinter
|
4
|
+
# It has been sped up by removing most link generation and
|
5
|
+
# expensive HTML formatting (like coloring)
|
6
|
+
|
7
|
+
module Tuttle
|
8
|
+
module RubyProf
|
9
|
+
# prints a HTML visualization of the call tree
|
10
|
+
class FastCallStackPrinter < ::RubyProf::CallStackPrinter
|
11
|
+
|
12
|
+
# Specify print options.
|
13
|
+
#
|
14
|
+
# options - Hash table
|
15
|
+
# :min_percent - Number 0 to 100 that specifes the minimum
|
16
|
+
# %self (the methods self time divided by the
|
17
|
+
# overall total time) that a method must take
|
18
|
+
# for it to be printed out in the report.
|
19
|
+
# Default value is 0.
|
20
|
+
#
|
21
|
+
# :print_file - True or false. Specifies if a method's source
|
22
|
+
# file should be printed. Default value if false.
|
23
|
+
#
|
24
|
+
# :threshold - a float from 0 to 100 that sets the threshold of
|
25
|
+
# results displayed.
|
26
|
+
# Default value is 1.0
|
27
|
+
#
|
28
|
+
# :title - a String to overide the default "ruby-prof call tree"
|
29
|
+
# title of the report.
|
30
|
+
#
|
31
|
+
# :expansion - a float from 0 to 100 that sets the threshold of
|
32
|
+
# results that are expanded, if the percent_total
|
33
|
+
# exceeds it.
|
34
|
+
# Default value is 10.0
|
35
|
+
#
|
36
|
+
# :application - a String to overide the name of the application,
|
37
|
+
# as it appears on the report.
|
38
|
+
#
|
39
|
+
def print(output = STDOUT, options = {})
|
40
|
+
@output = output
|
41
|
+
setup_options(options)
|
42
|
+
|
43
|
+
print_header
|
44
|
+
|
45
|
+
@overall_threads_time = @result.threads.inject(0) do |val, thread|
|
46
|
+
val += thread.total_time
|
47
|
+
end
|
48
|
+
|
49
|
+
@method_full_name_cache = Hash.new.compare_by_identity
|
50
|
+
|
51
|
+
@result.threads.each do |thread|
|
52
|
+
@overall_time = thread.total_time
|
53
|
+
thread_info = "Thread: #{thread.id}"
|
54
|
+
thread_info << ", Fiber: #{thread.fiber_id}" unless thread.id == thread.fiber_id
|
55
|
+
thread_info << " (#{"%4.2f%%" % ((@overall_time/@overall_threads_time)*100)} ~ #{@overall_time})"
|
56
|
+
@output.print "<div class=\"thread\">#{thread_info}</div>"
|
57
|
+
@output.print "<ul name=\"thread\">"
|
58
|
+
thread.methods.each do |m|
|
59
|
+
# $stderr.print m.dump
|
60
|
+
next unless m.root?
|
61
|
+
m.call_infos.each do |ci|
|
62
|
+
next unless ci.root?
|
63
|
+
print_stack ci, @overall_time
|
64
|
+
end
|
65
|
+
end
|
66
|
+
@output.print "</ul>"
|
67
|
+
end
|
68
|
+
|
69
|
+
@method_full_name_cache = nil
|
70
|
+
|
71
|
+
print_footer
|
72
|
+
|
73
|
+
end
|
74
|
+
|
75
|
+
def print_stack(call_info, parent_time)
|
76
|
+
total_time = call_info.total_time
|
77
|
+
percent_total = (total_time/@overall_time)*100
|
78
|
+
return unless percent_total > min_percent
|
79
|
+
|
80
|
+
percent_parent = (total_time/parent_time)*100
|
81
|
+
if percent_total < threshold
|
82
|
+
@output.write "<li style=\"display:none;\">".freeze
|
83
|
+
else
|
84
|
+
@output.write "<li>".freeze
|
85
|
+
end
|
86
|
+
|
87
|
+
expanded = percent_total >= expansion
|
88
|
+
kids = call_info.children
|
89
|
+
|
90
|
+
toggle_href = if kids.empty? || kids.none?{|ci| (ci.total_time/@overall_time)*100 >= threshold}
|
91
|
+
"<a href=\"#\" class=\"toggle empty\" ></a>".freeze
|
92
|
+
else
|
93
|
+
if expanded
|
94
|
+
"<a href=\"#\" class=\"toggle minus\" ></a>".freeze
|
95
|
+
else
|
96
|
+
"<a href=\"#\" class=\"toggle plus\" ></a>".freeze
|
97
|
+
end
|
98
|
+
end
|
99
|
+
@output.write toggle_href
|
100
|
+
|
101
|
+
method = call_info.target
|
102
|
+
@output.printf "<span>%4.2f%% (%4.2f%%) %s [%d calls, %d total]</span>\n".freeze,
|
103
|
+
percent_total, percent_parent,
|
104
|
+
method_full_name(method), call_info.called, method.called
|
105
|
+
unless kids.empty?
|
106
|
+
if expanded
|
107
|
+
@output.write "<ul>".freeze
|
108
|
+
else
|
109
|
+
@output.write '<ul style="display:none">'.freeze
|
110
|
+
end
|
111
|
+
kids.sort_by!(&:total_time).reverse_each do |callinfo|
|
112
|
+
print_stack callinfo, total_time
|
113
|
+
end
|
114
|
+
@output.write "</ul>".freeze
|
115
|
+
end
|
116
|
+
@output.write "</li>".freeze
|
117
|
+
end
|
118
|
+
|
119
|
+
def name(call_info)
|
120
|
+
method = call_info.target
|
121
|
+
method.full_name
|
122
|
+
end
|
123
|
+
|
124
|
+
def method_full_name(method)
|
125
|
+
@method_full_name_cache[method] ||= h(method.full_name)
|
126
|
+
end
|
127
|
+
|
128
|
+
def threshold
|
129
|
+
@threshold ||= super
|
130
|
+
end
|
131
|
+
|
132
|
+
def expansion
|
133
|
+
@expansion ||= super
|
134
|
+
end
|
135
|
+
|
136
|
+
def application
|
137
|
+
@application ||= @options.delete(:application) || $PROGRAM_NAME
|
138
|
+
end
|
139
|
+
|
140
|
+
def print_title_bar
|
141
|
+
@output.puts <<-"end_title_bar"
|
142
|
+
<div id="titlebar">
|
143
|
+
Call tree for application <b>#{h application} #{h arguments}</b><br/>
|
144
|
+
Generated on #{Time.now} with options #{h @options.inspect}<br/>
|
145
|
+
</div>
|
146
|
+
end_title_bar
|
147
|
+
end
|
148
|
+
|
149
|
+
def print_css
|
150
|
+
super
|
151
|
+
@output.puts <<-CSS_OVERRIDE
|
152
|
+
<style type="text/css">
|
153
|
+
<!--
|
154
|
+
ul li { background-color: white; }
|
155
|
+
-->
|
156
|
+
</style>
|
157
|
+
CSS_OVERRIDE
|
158
|
+
end
|
159
|
+
|
160
|
+
end
|
161
|
+
end
|
162
|
+
|
163
|
+
end
|
164
|
+
|
data/lib/tuttle/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tuttle
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dave Gynn
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-04-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -30,20 +30,6 @@ dependencies:
|
|
30
30
|
- - "<"
|
31
31
|
- !ruby/object:Gem::Version
|
32
32
|
version: '5.1'
|
33
|
-
- !ruby/object:Gem::Dependency
|
34
|
-
name: rake
|
35
|
-
requirement: !ruby/object:Gem::Requirement
|
36
|
-
requirements:
|
37
|
-
- - ">="
|
38
|
-
- !ruby/object:Gem::Version
|
39
|
-
version: '0'
|
40
|
-
type: :development
|
41
|
-
prerelease: false
|
42
|
-
version_requirements: !ruby/object:Gem::Requirement
|
43
|
-
requirements:
|
44
|
-
- - ">="
|
45
|
-
- !ruby/object:Gem::Version
|
46
|
-
version: '0'
|
47
33
|
- !ruby/object:Gem::Dependency
|
48
34
|
name: appraisal
|
49
35
|
requirement: !ruby/object:Gem::Requirement
|
@@ -69,40 +55,51 @@ files:
|
|
69
55
|
- MIT-LICENSE
|
70
56
|
- README.md
|
71
57
|
- Rakefile
|
72
|
-
- app/
|
73
|
-
- app/
|
74
|
-
- app/assets/stylesheets/tuttle/application.css
|
58
|
+
- app/controllers/tuttle/active_model_serializers_controller.rb
|
59
|
+
- app/controllers/tuttle/active_support_controller.rb
|
75
60
|
- app/controllers/tuttle/application_controller.rb
|
76
61
|
- app/controllers/tuttle/cancancan_controller.rb
|
77
62
|
- app/controllers/tuttle/devise_controller.rb
|
78
63
|
- app/controllers/tuttle/gems_controller.rb
|
79
64
|
- app/controllers/tuttle/home_controller.rb
|
80
65
|
- app/controllers/tuttle/paperclip_controller.rb
|
66
|
+
- app/controllers/tuttle/performance_tuning_controller.rb
|
81
67
|
- app/controllers/tuttle/rails_controller.rb
|
68
|
+
- app/controllers/tuttle/request_controller.rb
|
82
69
|
- app/controllers/tuttle/ruby_controller.rb
|
83
70
|
- app/helpers/tuttle/application_helper.rb
|
84
71
|
- app/views/layouts/tuttle/application.html.erb
|
72
|
+
- app/views/tuttle/active_model_serializers/index.html.erb
|
73
|
+
- app/views/tuttle/active_model_serializers/index9.html.erb
|
74
|
+
- app/views/tuttle/active_support/dependencies.html.erb
|
75
|
+
- app/views/tuttle/active_support/index.html.erb
|
76
|
+
- app/views/tuttle/active_support/inflectors.html.erb
|
77
|
+
- app/views/tuttle/active_support/time_zones.html.erb
|
85
78
|
- app/views/tuttle/cancancan/_rule_table.html.erb
|
86
79
|
- app/views/tuttle/cancancan/index.html.erb
|
87
80
|
- app/views/tuttle/cancancan/rule_tester.html.erb
|
88
81
|
- app/views/tuttle/devise/index.html.erb
|
82
|
+
- app/views/tuttle/gems/get_process_mem.html.erb
|
89
83
|
- app/views/tuttle/gems/http_clients.html.erb
|
90
84
|
- app/views/tuttle/gems/index.html.erb
|
91
85
|
- app/views/tuttle/gems/json.html.erb
|
92
86
|
- app/views/tuttle/gems/other.html.erb
|
93
87
|
- app/views/tuttle/home/index.html.erb
|
94
88
|
- app/views/tuttle/paperclip/index.html.erb
|
89
|
+
- app/views/tuttle/performance_tuning/index.html.erb
|
95
90
|
- app/views/tuttle/rails/assets.html.erb
|
96
91
|
- app/views/tuttle/rails/cache.html.erb
|
97
92
|
- app/views/tuttle/rails/controllers.html.erb
|
98
93
|
- app/views/tuttle/rails/database.html.erb
|
94
|
+
- app/views/tuttle/rails/engines.html.erb
|
95
|
+
- app/views/tuttle/rails/generators.html.erb
|
99
96
|
- app/views/tuttle/rails/helpers.html.erb
|
100
97
|
- app/views/tuttle/rails/index.html.erb
|
101
|
-
- app/views/tuttle/rails/inflectors.html.erb
|
102
98
|
- app/views/tuttle/rails/instrumentation.html.erb
|
103
99
|
- app/views/tuttle/rails/models.html.erb
|
104
100
|
- app/views/tuttle/rails/routes.html.erb
|
105
101
|
- app/views/tuttle/rails/schema_cache.html.erb
|
102
|
+
- app/views/tuttle/request/index.html.erb
|
106
103
|
- app/views/tuttle/ruby/index.html.erb
|
107
104
|
- app/views/tuttle/ruby/miscellaneous.html.erb
|
108
105
|
- app/views/tuttle/ruby/tuning.html.erb
|
@@ -110,7 +107,10 @@ files:
|
|
110
107
|
- lib/tasks/tuttle_tasks.rake
|
111
108
|
- lib/tuttle.rb
|
112
109
|
- lib/tuttle/engine.rb
|
110
|
+
- lib/tuttle/instrumenter.rb
|
111
|
+
- lib/tuttle/middleware/request_profiler.rb
|
113
112
|
- lib/tuttle/presenters/action_dispatch/routing/route_wrapper.rb
|
113
|
+
- lib/tuttle/ruby_prof/fast_call_stack_printer.rb
|
114
114
|
- lib/tuttle/version.rb
|
115
115
|
homepage: https://github.com/dgynn/tuttle
|
116
116
|
licenses:
|
@@ -132,7 +132,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
132
132
|
version: '0'
|
133
133
|
requirements: []
|
134
134
|
rubyforge_project:
|
135
|
-
rubygems_version: 2.
|
135
|
+
rubygems_version: 2.5.1
|
136
136
|
signing_key:
|
137
137
|
specification_version: 4
|
138
138
|
summary: Tuttle for Rails
|
Binary file
|
@@ -1,12 +0,0 @@
|
|
1
|
-
// This is a manifest file that'll be compiled into application.js, which will include all the files
|
2
|
-
// listed below.
|
3
|
-
//
|
4
|
-
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
|
5
|
-
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
|
6
|
-
//
|
7
|
-
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
8
|
-
// the compiled file.
|
9
|
-
//
|
10
|
-
// WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
|
11
|
-
// GO AFTER THE REQUIRES BELOW.
|
12
|
-
//
|
@@ -1,71 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
* This is a manifest file that'll be compiled into application.css, which will include all the files
|
3
|
-
* listed below.
|
4
|
-
*
|
5
|
-
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
|
6
|
-
* or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
|
7
|
-
*
|
8
|
-
* You're free to add application-wide styles to this file and they'll appear at the top of the
|
9
|
-
* compiled file, but it's generally better to create a new file per style scope.
|
10
|
-
*
|
11
|
-
*= require_self
|
12
|
-
*= require_tree .
|
13
|
-
*/
|
14
|
-
|
15
|
-
html {
|
16
|
-
overflow: -moz-scrollbars-vertical;
|
17
|
-
overflow-y: scroll;
|
18
|
-
}
|
19
|
-
body { padding-top: 50px; }
|
20
|
-
|
21
|
-
/* Typeahead */
|
22
|
-
.typeahead,
|
23
|
-
.tt-query,
|
24
|
-
.tt-hint {
|
25
|
-
width: 396px;
|
26
|
-
height: 30px;
|
27
|
-
padding: 8px 12px;
|
28
|
-
outline: none;
|
29
|
-
}
|
30
|
-
|
31
|
-
.typeahead {
|
32
|
-
background-color: #fff;
|
33
|
-
}
|
34
|
-
|
35
|
-
.typeahead:focus {
|
36
|
-
border: 2px solid #0097cf;
|
37
|
-
}
|
38
|
-
|
39
|
-
.tt-query {
|
40
|
-
-webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
|
41
|
-
-moz-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
|
42
|
-
box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
|
43
|
-
}
|
44
|
-
|
45
|
-
.tt-hint {
|
46
|
-
color: #999
|
47
|
-
}
|
48
|
-
|
49
|
-
.tt-dropdown-menu {
|
50
|
-
width: 422px;
|
51
|
-
margin-top: 12px;
|
52
|
-
padding: 8px 0;
|
53
|
-
background-color: #fff;
|
54
|
-
border: 1px solid #ccc;
|
55
|
-
border: 1px solid rgba(0, 0, 0, 0.2);
|
56
|
-
}
|
57
|
-
|
58
|
-
.tt-suggestion {
|
59
|
-
padding: 3px 20px;
|
60
|
-
font-size: 18px;
|
61
|
-
line-height: 24px;
|
62
|
-
}
|
63
|
-
|
64
|
-
.tt-suggestion.tt-cursor {
|
65
|
-
color: #fff;
|
66
|
-
background-color: #0097cf;
|
67
|
-
}
|
68
|
-
|
69
|
-
.tt-suggestion p {
|
70
|
-
margin: 0;
|
71
|
-
}
|