ruby-prof 1.7.2 → 2.0.0
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/{CHANGES → CHANGELOG.md} +112 -178
- data/README.md +5 -5
- data/bin/ruby-prof +1 -4
- data/docs/advanced-usage.md +132 -0
- data/docs/alternatives.md +98 -0
- data/docs/architecture.md +122 -0
- data/docs/best-practices.md +27 -0
- data/docs/getting-started.md +130 -0
- data/docs/history.md +11 -0
- data/docs/index.md +45 -0
- data/docs/profiling-rails.md +64 -0
- data/docs/public/examples/example.rb +33 -0
- data/docs/public/examples/generate_reports.rb +92 -0
- data/docs/public/examples/reports/call_info.txt +27 -0
- data/docs/public/examples/reports/call_stack.html +835 -0
- data/docs/public/examples/reports/callgrind.out +150 -0
- data/docs/public/examples/reports/flame_graph.html +408 -0
- data/docs/public/examples/reports/flat.txt +45 -0
- data/docs/public/examples/reports/graph.dot +129 -0
- data/docs/public/examples/reports/graph.html +1319 -0
- data/docs/public/examples/reports/graph.txt +100 -0
- data/docs/public/examples/reports/graphviz_viewer.html +1 -0
- data/docs/public/images/call_stack.png +0 -0
- data/docs/public/images/class_diagram.png +0 -0
- data/docs/public/images/dot_printer.png +0 -0
- data/docs/public/images/flame_graph.png +0 -0
- data/docs/public/images/flat.png +0 -0
- data/docs/public/images/graph.png +0 -0
- data/docs/public/images/graph_html.png +0 -0
- data/docs/public/images/ruby-prof-logo.svg +1 -0
- data/docs/reports.md +150 -0
- data/docs/stylesheets/extra.css +80 -0
- data/ext/ruby_prof/rp_allocation.c +0 -15
- data/ext/ruby_prof/rp_allocation.h +29 -33
- data/ext/ruby_prof/rp_call_tree.c +3 -0
- data/ext/ruby_prof/rp_call_tree.h +1 -4
- data/ext/ruby_prof/rp_call_trees.h +1 -4
- data/ext/ruby_prof/rp_measurement.c +0 -5
- data/ext/ruby_prof/rp_measurement.h +49 -53
- data/ext/ruby_prof/rp_method.c +3 -0
- data/ext/ruby_prof/rp_method.h +1 -4
- data/ext/ruby_prof/rp_profile.c +1 -1
- data/ext/ruby_prof/rp_profile.h +1 -5
- data/ext/ruby_prof/rp_stack.h +50 -53
- data/ext/ruby_prof/rp_thread.h +1 -4
- data/ext/ruby_prof/ruby_prof.h +1 -4
- data/ext/ruby_prof/vc/ruby_prof.vcxproj +7 -8
- data/lib/ruby-prof/assets/call_stack_printer.html.erb +746 -711
- data/lib/ruby-prof/assets/flame_graph_printer.html.erb +412 -0
- data/lib/ruby-prof/assets/graph_printer.html.erb +355 -355
- data/lib/ruby-prof/call_tree.rb +57 -57
- data/lib/ruby-prof/call_tree_visitor.rb +36 -36
- data/lib/ruby-prof/measurement.rb +17 -17
- data/lib/ruby-prof/printers/abstract_printer.rb +19 -33
- data/lib/ruby-prof/printers/call_info_printer.rb +53 -53
- data/lib/ruby-prof/printers/call_stack_printer.rb +168 -180
- data/lib/ruby-prof/printers/call_tree_printer.rb +132 -145
- data/lib/ruby-prof/printers/dot_printer.rb +177 -132
- data/lib/ruby-prof/printers/flame_graph_printer.rb +79 -0
- data/lib/ruby-prof/printers/flat_printer.rb +52 -52
- data/lib/ruby-prof/printers/graph_html_printer.rb +62 -63
- data/lib/ruby-prof/printers/graph_printer.rb +112 -113
- data/lib/ruby-prof/printers/multi_printer.rb +134 -127
- data/lib/ruby-prof/profile.rb +13 -0
- data/lib/ruby-prof/rack.rb +114 -105
- data/lib/ruby-prof/task.rb +147 -147
- data/lib/ruby-prof/thread.rb +20 -20
- data/lib/ruby-prof/version.rb +1 -1
- data/lib/ruby-prof.rb +50 -52
- data/lib/unprof.rb +10 -10
- data/ruby-prof.gemspec +5 -5
- data/test/abstract_printer_test.rb +25 -27
- data/test/alias_test.rb +203 -117
- data/test/call_tree_builder.rb +126 -126
- data/test/call_tree_visitor_test.rb +27 -27
- data/test/call_trees_test.rb +66 -66
- data/test/duplicate_names_test.rb +32 -32
- data/test/dynamic_method_test.rb +50 -50
- data/test/exceptions_test.rb +24 -24
- data/test/exclude_threads_test.rb +48 -48
- data/test/fiber_test.rb +72 -72
- data/test/inverse_call_tree_test.rb +174 -174
- data/test/line_number_test.rb +138 -1
- data/test/marshal_test.rb +144 -145
- data/test/measure_allocations.rb +26 -26
- data/test/measure_allocations_test.rb +340 -1
- data/test/measure_process_time_test.rb +3098 -3142
- data/test/measure_times.rb +56 -56
- data/test/measure_wall_time_test.rb +511 -372
- data/test/measurement_test.rb +82 -82
- data/test/merge_test.rb +48 -48
- data/test/multi_printer_test.rb +52 -66
- data/test/no_method_class_test.rb +15 -15
- data/test/pause_resume_test.rb +171 -171
- data/test/prime.rb +54 -54
- data/test/prime_script.rb +5 -5
- data/test/printer_call_stack_test.rb +28 -27
- data/test/printer_call_tree_test.rb +30 -30
- data/test/printer_flame_graph_test.rb +82 -0
- data/test/printer_flat_test.rb +99 -99
- data/test/printer_graph_html_test.rb +62 -59
- data/test/printer_graph_test.rb +42 -40
- data/test/printers_test.rb +28 -44
- data/test/printing_recursive_graph_test.rb +81 -81
- data/test/profile_test.rb +101 -101
- data/test/rack_test.rb +103 -93
- data/test/recursive_test.rb +139 -139
- data/test/scheduler.rb +4 -0
- data/test/singleton_test.rb +39 -38
- data/test/stack_printer_test.rb +61 -61
- data/test/start_stop_test.rb +106 -106
- data/test/test_helper.rb +4 -0
- data/test/thread_test.rb +29 -29
- data/test/unique_call_path_test.rb +123 -123
- data/test/yarv_test.rb +56 -56
- metadata +53 -11
- data/ext/ruby_prof/rp_measure_memory.c +0 -46
- data/lib/ruby-prof/compatibility.rb +0 -113
- data/test/compatibility_test.rb +0 -49
- data/test/measure_memory_test.rb +0 -1193
|
@@ -1,113 +1,112 @@
|
|
|
1
|
-
# encoding: utf-8
|
|
2
|
-
|
|
3
|
-
module RubyProf
|
|
4
|
-
# Generates graph[link:files/examples/graph_txt.html] profile reports as text.
|
|
5
|
-
# To use the graph printer:
|
|
6
|
-
#
|
|
7
|
-
# result = RubyProf.profile do
|
|
8
|
-
# [code to profile]
|
|
9
|
-
# end
|
|
10
|
-
#
|
|
11
|
-
# printer = RubyProf::GraphPrinter.new(result)
|
|
12
|
-
# printer.print(STDOUT
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
@output << "
|
|
29
|
-
@output << "
|
|
30
|
-
@output << "
|
|
31
|
-
@output << "
|
|
32
|
-
@output << "
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
@output << sprintf("%#{PERCENTAGE_WIDTH}s", "%
|
|
37
|
-
@output << sprintf("%#{
|
|
38
|
-
@output << sprintf("%#{TIME_WIDTH}s", "
|
|
39
|
-
@output << sprintf("%#{TIME_WIDTH}s", "
|
|
40
|
-
@output << sprintf("%#{TIME_WIDTH}s", "
|
|
41
|
-
@output << sprintf("%#{
|
|
42
|
-
@output <<
|
|
43
|
-
@output << "
|
|
44
|
-
@output << "
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
@output << sprintf("%#{PERCENTAGE_WIDTH-1}.2f%%",
|
|
65
|
-
@output << sprintf("%#{
|
|
66
|
-
@output << sprintf("%#{TIME_WIDTH}.3f", method.
|
|
67
|
-
@output << sprintf("%#{TIME_WIDTH}.3f", method.
|
|
68
|
-
@output << sprintf("%#{TIME_WIDTH}.3f", method.
|
|
69
|
-
@output << sprintf("%#{
|
|
70
|
-
@output << sprintf("
|
|
71
|
-
@output << sprintf("
|
|
72
|
-
@output << sprintf("
|
|
73
|
-
@output <<
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
@output << "
|
|
83
|
-
@output << sprintf("%#{TIME_WIDTH}.3f", caller.
|
|
84
|
-
@output << sprintf("%#{TIME_WIDTH}.3f", caller.
|
|
85
|
-
@output << sprintf("%#{TIME_WIDTH}.3f", caller.
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
@output << sprintf("
|
|
90
|
-
@output <<
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
@output << sprintf("%#{TIME_WIDTH}.3f", child.
|
|
102
|
-
@output << sprintf("%#{TIME_WIDTH}.3f", child.
|
|
103
|
-
@output << sprintf("%#{TIME_WIDTH}.3f", child.
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
@output << sprintf("
|
|
108
|
-
@output <<
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
end
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
3
|
+
module RubyProf
|
|
4
|
+
# Generates graph[link:files/examples/graph_txt.html] profile reports as text.
|
|
5
|
+
# To use the graph printer:
|
|
6
|
+
#
|
|
7
|
+
# result = RubyProf.profile do
|
|
8
|
+
# [code to profile]
|
|
9
|
+
# end
|
|
10
|
+
#
|
|
11
|
+
# printer = RubyProf::GraphPrinter.new(result)
|
|
12
|
+
# printer.print(STDOUT)
|
|
13
|
+
|
|
14
|
+
class GraphPrinter < AbstractPrinter
|
|
15
|
+
PERCENTAGE_WIDTH = 8
|
|
16
|
+
TIME_WIDTH = 11
|
|
17
|
+
CALL_WIDTH = 17
|
|
18
|
+
|
|
19
|
+
# Override to default sort by total time
|
|
20
|
+
def print(output = STDOUT, sort_method: :total_time, **options)
|
|
21
|
+
super(output, sort_method: sort_method, **options)
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
private
|
|
25
|
+
|
|
26
|
+
def print_header(thread)
|
|
27
|
+
@output << "Measure Mode: %s\n" % @result.measure_mode_string
|
|
28
|
+
@output << "Thread ID: #{thread.id}\n"
|
|
29
|
+
@output << "Fiber ID: #{thread.fiber_id}\n"
|
|
30
|
+
@output << "Total Time: #{thread.total_time}\n"
|
|
31
|
+
@output << "Sort by: #{sort_method}\n"
|
|
32
|
+
@output << "\n"
|
|
33
|
+
|
|
34
|
+
# 1 is for % sign
|
|
35
|
+
@output << sprintf("%#{PERCENTAGE_WIDTH}s", "%total")
|
|
36
|
+
@output << sprintf("%#{PERCENTAGE_WIDTH}s", "%self")
|
|
37
|
+
@output << sprintf("%#{TIME_WIDTH}s", "total")
|
|
38
|
+
@output << sprintf("%#{TIME_WIDTH}s", "self")
|
|
39
|
+
@output << sprintf("%#{TIME_WIDTH}s", "wait")
|
|
40
|
+
@output << sprintf("%#{TIME_WIDTH}s", "child")
|
|
41
|
+
@output << sprintf("%#{CALL_WIDTH}s", "calls")
|
|
42
|
+
@output << " name"
|
|
43
|
+
@output << " location"
|
|
44
|
+
@output << "\n"
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def print_methods(thread)
|
|
48
|
+
total_time = thread.total_time
|
|
49
|
+
# Sort methods from longest to shortest total time
|
|
50
|
+
methods = thread.methods.sort_by(&sort_method)
|
|
51
|
+
|
|
52
|
+
# Print each method in total time order
|
|
53
|
+
methods.reverse_each do |method|
|
|
54
|
+
total_percentage = (method.total_time/total_time) * 100
|
|
55
|
+
next if total_percentage < min_percent
|
|
56
|
+
|
|
57
|
+
self_percentage = (method.self_time/total_time) * 100
|
|
58
|
+
|
|
59
|
+
@output << "-" * 150 << "\n"
|
|
60
|
+
print_parents(thread, method)
|
|
61
|
+
|
|
62
|
+
# 1 is for % sign
|
|
63
|
+
@output << sprintf("%#{PERCENTAGE_WIDTH-1}.2f%%", total_percentage)
|
|
64
|
+
@output << sprintf("%#{PERCENTAGE_WIDTH-1}.2f%%", self_percentage)
|
|
65
|
+
@output << sprintf("%#{TIME_WIDTH}.3f", method.total_time)
|
|
66
|
+
@output << sprintf("%#{TIME_WIDTH}.3f", method.self_time)
|
|
67
|
+
@output << sprintf("%#{TIME_WIDTH}.3f", method.wait_time)
|
|
68
|
+
@output << sprintf("%#{TIME_WIDTH}.3f", method.children_time)
|
|
69
|
+
@output << sprintf("%#{CALL_WIDTH}i", method.called)
|
|
70
|
+
@output << sprintf(" %s", method.recursive? ? "*" : " ")
|
|
71
|
+
@output << sprintf("%-30s", method.full_name)
|
|
72
|
+
@output << sprintf(" %s", method_location(method))
|
|
73
|
+
@output << "\n"
|
|
74
|
+
|
|
75
|
+
print_children(method)
|
|
76
|
+
end
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
def print_parents(thread, method)
|
|
80
|
+
method.call_trees.callers.sort_by(&:total_time).each do |caller|
|
|
81
|
+
@output << " " * 2 * PERCENTAGE_WIDTH
|
|
82
|
+
@output << sprintf("%#{TIME_WIDTH}.3f", caller.total_time)
|
|
83
|
+
@output << sprintf("%#{TIME_WIDTH}.3f", caller.self_time)
|
|
84
|
+
@output << sprintf("%#{TIME_WIDTH}.3f", caller.wait_time)
|
|
85
|
+
@output << sprintf("%#{TIME_WIDTH}.3f", caller.children_time)
|
|
86
|
+
|
|
87
|
+
call_called = "#{caller.called}/#{method.called}"
|
|
88
|
+
@output << sprintf("%#{CALL_WIDTH}s", call_called)
|
|
89
|
+
@output << sprintf(" %s", caller.parent.target.full_name)
|
|
90
|
+
@output << "\n"
|
|
91
|
+
end
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
def print_children(method)
|
|
95
|
+
method.call_trees.callees.sort_by(&:total_time).reverse.each do |child|
|
|
96
|
+
# Get children method
|
|
97
|
+
|
|
98
|
+
@output << " " * 2 * PERCENTAGE_WIDTH
|
|
99
|
+
|
|
100
|
+
@output << sprintf("%#{TIME_WIDTH}.3f", child.total_time)
|
|
101
|
+
@output << sprintf("%#{TIME_WIDTH}.3f", child.self_time)
|
|
102
|
+
@output << sprintf("%#{TIME_WIDTH}.3f", child.wait_time)
|
|
103
|
+
@output << sprintf("%#{TIME_WIDTH}.3f", child.children_time)
|
|
104
|
+
|
|
105
|
+
call_called = "#{child.called}/#{child.target.called}"
|
|
106
|
+
@output << sprintf("%#{CALL_WIDTH}s", call_called)
|
|
107
|
+
@output << sprintf(" %s", child.target.full_name)
|
|
108
|
+
@output << "\n"
|
|
109
|
+
end
|
|
110
|
+
end
|
|
111
|
+
end
|
|
112
|
+
end
|
|
@@ -1,127 +1,134 @@
|
|
|
1
|
-
# encoding: utf-8
|
|
2
|
-
|
|
3
|
-
module RubyProf
|
|
4
|
-
# Helper class to simplify printing profiles of several types from
|
|
5
|
-
# one profiling run. Currently prints a flat profile, a callgrind
|
|
6
|
-
# profile, a call stack profile and a graph profile.
|
|
7
|
-
class MultiPrinter
|
|
8
|
-
def initialize(result, printers = [:flat, :graph_html])
|
|
9
|
-
@flat_printer = printers.include?(:flat) ? FlatPrinter.new(result) : nil
|
|
10
|
-
|
|
11
|
-
@graph_printer = printers.include?(:graph) ? GraphPrinter.new(result) : nil
|
|
12
|
-
@graph_html_printer = printers.include?(:graph_html) ? GraphHtmlPrinter.new(result) : nil
|
|
13
|
-
|
|
14
|
-
@tree_printer = printers.include?(:tree) ? CallTreePrinter.new(result) : nil
|
|
15
|
-
@call_info_printer = printers.include?(:call_tree) ? CallInfoPrinter.new(result) : nil
|
|
16
|
-
|
|
17
|
-
@stack_printer = printers.include?(:stack) ? CallStackPrinter.new(result) : nil
|
|
18
|
-
@
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
#
|
|
27
|
-
#
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
def
|
|
56
|
-
"#{@directory}/#{@file_name}.graph.
|
|
57
|
-
end
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
def
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
3
|
+
module RubyProf
|
|
4
|
+
# Helper class to simplify printing profiles of several types from
|
|
5
|
+
# one profiling run. Currently prints a flat profile, a callgrind
|
|
6
|
+
# profile, a call stack profile and a graph profile.
|
|
7
|
+
class MultiPrinter
|
|
8
|
+
def initialize(result, printers = [:flat, :graph, :graph_html, :flame_graph, :stack])
|
|
9
|
+
@flat_printer = printers.include?(:flat) ? FlatPrinter.new(result) : nil
|
|
10
|
+
|
|
11
|
+
@graph_printer = printers.include?(:graph) ? GraphPrinter.new(result) : nil
|
|
12
|
+
@graph_html_printer = printers.include?(:graph_html) ? GraphHtmlPrinter.new(result) : nil
|
|
13
|
+
|
|
14
|
+
@tree_printer = printers.include?(:tree) ? CallTreePrinter.new(result) : nil
|
|
15
|
+
@call_info_printer = printers.include?(:call_tree) ? CallInfoPrinter.new(result) : nil
|
|
16
|
+
|
|
17
|
+
@stack_printer = printers.include?(:stack) ? CallStackPrinter.new(result) : nil
|
|
18
|
+
@flame_graph_printer = printers.include?(:flame_graph) ? FlameGraphPrinter.new(result) : nil
|
|
19
|
+
@dot_printer = printers.include?(:dot) ? DotPrinter.new(result) : nil
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def self.needs_dir?
|
|
23
|
+
true
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
# Create profile files under the specified directory.
|
|
27
|
+
#
|
|
28
|
+
# Keyword arguments:
|
|
29
|
+
# profile: - Base name for profile files. Default is "profile".
|
|
30
|
+
# path: - Directory to write files to. Default is current directory.
|
|
31
|
+
#
|
|
32
|
+
# Also accepts min_percent:, sort_method:, and other printer-specific kwargs.
|
|
33
|
+
def print(profile: "profile", path: File.expand_path("."), **options)
|
|
34
|
+
@file_name = profile
|
|
35
|
+
@directory = path
|
|
36
|
+
|
|
37
|
+
print_to_flat(**options) if @flat_printer
|
|
38
|
+
|
|
39
|
+
print_to_graph(**options) if @graph_printer
|
|
40
|
+
print_to_graph_html(**options) if @graph_html_printer
|
|
41
|
+
|
|
42
|
+
print_to_stack(**options) if @stack_printer
|
|
43
|
+
print_to_flame_graph(**options) if @flame_graph_printer
|
|
44
|
+
print_to_call_info(**options) if @call_info_printer
|
|
45
|
+
print_to_tree(**options) if @tree_printer
|
|
46
|
+
print_to_dot(**options) if @dot_printer
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
# the name of the flat profile file
|
|
50
|
+
def flat_report
|
|
51
|
+
"#{@directory}/#{@file_name}.flat.txt"
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
# the name of the graph profile file
|
|
55
|
+
def graph_report
|
|
56
|
+
"#{@directory}/#{@file_name}.graph.txt"
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
def graph_html_report
|
|
60
|
+
"#{@directory}/#{@file_name}.graph.html"
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
# the name of the callinfo profile file
|
|
64
|
+
def call_info_report
|
|
65
|
+
"#{@directory}/#{@file_name}.call_tree.txt"
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
# the name of the callgrind profile file
|
|
69
|
+
def tree_report
|
|
70
|
+
"#{@directory}/#{@file_name}.callgrind.out.#{$$}"
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
# the name of the call stack profile file
|
|
74
|
+
def stack_report
|
|
75
|
+
"#{@directory}/#{@file_name}.stack.html"
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
# the name of the flame graph profile file
|
|
79
|
+
def flame_graph_report
|
|
80
|
+
"#{@directory}/#{@file_name}.flame_graph.html"
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
# the name of the call stack profile file
|
|
84
|
+
def dot_report
|
|
85
|
+
"#{@directory}/#{@file_name}.dot"
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
def print_to_flat(**options)
|
|
89
|
+
File.open(flat_report, "wb") do |file|
|
|
90
|
+
@flat_printer.print(file, **options)
|
|
91
|
+
end
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
def print_to_graph(**options)
|
|
95
|
+
File.open(graph_report, "wb") do |file|
|
|
96
|
+
@graph_printer.print(file, **options)
|
|
97
|
+
end
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
def print_to_graph_html(**options)
|
|
101
|
+
File.open(graph_html_report, "wb") do |file|
|
|
102
|
+
@graph_html_printer.print(file, **options)
|
|
103
|
+
end
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
def print_to_call_info(**options)
|
|
107
|
+
File.open(call_info_report, "wb") do |file|
|
|
108
|
+
@call_info_printer.print(file, **options)
|
|
109
|
+
end
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
def print_to_tree(**options)
|
|
113
|
+
@tree_printer.print(path: @directory, **options)
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
def print_to_stack(**options)
|
|
117
|
+
File.open(stack_report, "wb") do |file|
|
|
118
|
+
@stack_printer.print(file, **options)
|
|
119
|
+
end
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
def print_to_flame_graph(**options)
|
|
123
|
+
File.open(flame_graph_report, "wb") do |file|
|
|
124
|
+
@flame_graph_printer.print(file, **options)
|
|
125
|
+
end
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
def print_to_dot(**options)
|
|
129
|
+
File.open(dot_report, "wb") do |file|
|
|
130
|
+
@dot_printer.print(file, **options)
|
|
131
|
+
end
|
|
132
|
+
end
|
|
133
|
+
end
|
|
134
|
+
end
|
data/lib/ruby-prof/profile.rb
CHANGED
|
@@ -17,6 +17,19 @@ module RubyProf
|
|
|
17
17
|
end
|
|
18
18
|
end
|
|
19
19
|
|
|
20
|
+
def measure_mode_name
|
|
21
|
+
case self.measure_mode
|
|
22
|
+
when WALL_TIME
|
|
23
|
+
"Wall Time"
|
|
24
|
+
when PROCESS_TIME
|
|
25
|
+
"Process Time"
|
|
26
|
+
when ALLOCATIONS
|
|
27
|
+
"Allocations"
|
|
28
|
+
when MEMORY
|
|
29
|
+
"Memory"
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
20
33
|
# Hides methods that, when represented as a call graph, have
|
|
21
34
|
# extremely large in and out degrees and make navigation impossible.
|
|
22
35
|
def exclude_common_methods!
|