ruby-prof 1.3.0-x64-mingw32 → 1.4.3-x64-mingw32
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGES +42 -0
- data/README.rdoc +1 -1
- data/Rakefile +2 -14
- data/ext/ruby_prof/extconf.rb +13 -27
- data/ext/ruby_prof/rp_allocation.c +1 -1
- data/ext/ruby_prof/rp_call_trees.c +2 -2
- data/ext/ruby_prof/rp_measure_allocations.c +1 -1
- data/ext/ruby_prof/rp_measure_process_time.c +1 -1
- data/ext/ruby_prof/rp_measure_wall_time.c +1 -1
- data/ext/ruby_prof/rp_measurement.c +1 -1
- data/ext/ruby_prof/rp_method.c +2 -2
- data/ext/ruby_prof/rp_method.h +19 -19
- data/ext/ruby_prof/rp_profile.c +12 -37
- data/ext/ruby_prof/rp_profile.h +0 -1
- data/ext/ruby_prof/rp_stack.c +12 -4
- data/ext/ruby_prof/rp_thread.c +2 -2
- data/ext/ruby_prof/vc/ruby_prof.sln +8 -0
- data/ext/ruby_prof/vc/ruby_prof.vcxproj +15 -4
- data/lib/2.7/ruby_prof.so +0 -0
- data/lib/3.0/ruby_prof.so +0 -0
- data/lib/ruby-prof.rb +4 -3
- data/lib/ruby-prof/compatibility.rb +0 -10
- data/lib/ruby-prof/printers/abstract_printer.rb +13 -3
- data/lib/ruby-prof/printers/call_stack_printer.rb +1 -0
- data/lib/ruby-prof/printers/flat_printer.rb +3 -2
- data/lib/ruby-prof/printers/graph_printer.rb +1 -1
- data/lib/ruby-prof/profile.rb +8 -4
- data/lib/ruby-prof/rack.rb +51 -130
- data/lib/ruby-prof/version.rb +1 -1
- data/ruby-prof.gemspec +1 -1
- data/test/fiber_test.rb +55 -187
- data/test/gc_test.rb +12 -2
- data/test/marshal_test.rb +22 -5
- data/test/measure_memory_trace_test.rb +361 -2
- data/test/printer_call_stack_test.rb +0 -1
- data/test/printer_call_tree_test.rb +0 -1
- data/test/printer_flat_test.rb +61 -30
- data/test/printer_graph_html_test.rb +0 -1
- data/test/printer_graph_test.rb +3 -4
- data/test/printers_test.rb +3 -3
- data/test/printing_recursive_graph_test.rb +1 -1
- data/test/profile_test.rb +16 -0
- data/test/rack_test.rb +0 -64
- data/test/start_stop_test.rb +4 -4
- data/test/temp.rb +20 -0
- data/test/test_helper.rb +10 -5
- metadata +9 -5
data/ext/ruby_prof/rp_profile.h
CHANGED
data/ext/ruby_prof/rp_stack.c
CHANGED
@@ -22,6 +22,14 @@ void prof_stack_free(prof_stack_t* stack)
|
|
22
22
|
xfree(stack);
|
23
23
|
}
|
24
24
|
|
25
|
+
prof_frame_t* prof_stack_parent(prof_stack_t* stack)
|
26
|
+
{
|
27
|
+
if (stack->ptr == stack->start || stack->ptr - 1 == stack->start)
|
28
|
+
return NULL;
|
29
|
+
else
|
30
|
+
return stack->ptr - 2;
|
31
|
+
}
|
32
|
+
|
25
33
|
prof_frame_t* prof_stack_last(prof_stack_t* stack)
|
26
34
|
{
|
27
35
|
if (stack->ptr == stack->start)
|
@@ -86,8 +94,8 @@ prof_frame_t* prof_frame_current(prof_stack_t* stack)
|
|
86
94
|
|
87
95
|
prof_frame_t* prof_frame_push(prof_stack_t* stack, prof_call_tree_t* call_tree, double measurement, bool paused)
|
88
96
|
{
|
89
|
-
prof_frame_t* parent_frame = prof_stack_last(stack);
|
90
97
|
prof_frame_t* result = prof_stack_push(stack);
|
98
|
+
prof_frame_t* parent_frame = prof_stack_parent(stack);
|
91
99
|
|
92
100
|
result->call_tree = call_tree;
|
93
101
|
|
@@ -129,7 +137,7 @@ prof_frame_t* prof_frame_push(prof_stack_t* stack, prof_call_tree_t* call_tree,
|
|
129
137
|
prof_frame_t* prof_frame_unshift(prof_stack_t* stack, prof_call_tree_t* parent_call_tree, prof_call_tree_t* call_tree, double measurement)
|
130
138
|
{
|
131
139
|
if (prof_stack_last(stack))
|
132
|
-
rb_raise(rb_eRuntimeError, "
|
140
|
+
rb_raise(rb_eRuntimeError, "Stack unshift can only be called with an empty stack");
|
133
141
|
|
134
142
|
parent_call_tree->measurement->total_time = call_tree->measurement->total_time;
|
135
143
|
parent_call_tree->measurement->self_time = 0;
|
@@ -172,7 +180,7 @@ prof_frame_t* prof_frame_pop(prof_stack_t* stack, double measurement)
|
|
172
180
|
call_tree->measurement->total_time += total_time;
|
173
181
|
|
174
182
|
call_tree->visits--;
|
175
|
-
|
183
|
+
|
176
184
|
prof_frame_t* parent_frame = prof_stack_last(stack);
|
177
185
|
if (parent_frame)
|
178
186
|
{
|
@@ -187,7 +195,7 @@ prof_frame_t* prof_frame_pop(prof_stack_t* stack, double measurement)
|
|
187
195
|
|
188
196
|
prof_method_t* prof_find_method(prof_stack_t* stack, VALUE source_file, int source_line)
|
189
197
|
{
|
190
|
-
prof_frame_t* frame = stack
|
198
|
+
prof_frame_t* frame = prof_stack_last(stack);
|
191
199
|
while (frame >= stack->start)
|
192
200
|
{
|
193
201
|
if (!frame->call_tree)
|
data/ext/ruby_prof/rp_thread.c
CHANGED
@@ -21,7 +21,7 @@ You cannot create an instance of RubyProf::Thread, instead you access it from a
|
|
21
21
|
|
22
22
|
VALUE cRpThread;
|
23
23
|
|
24
|
-
// ====== thread_data_t ======
|
24
|
+
// ====== thread_data_t ======
|
25
25
|
thread_data_t* thread_data_create(void)
|
26
26
|
{
|
27
27
|
thread_data_t* result = ALLOC(thread_data_t);
|
@@ -146,7 +146,7 @@ thread_data_t* prof_get_thread(VALUE self)
|
|
146
146
|
}
|
147
147
|
|
148
148
|
// ====== Thread Table ======
|
149
|
-
// The thread table is hash keyed on ruby fiber_id that stores instances of thread_data_t.
|
149
|
+
// The thread table is hash keyed on ruby fiber_id that stores instances of thread_data_t.
|
150
150
|
|
151
151
|
st_table* threads_table_create()
|
152
152
|
{
|
@@ -7,16 +7,24 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ruby_prof", "ruby_prof.vcxp
|
|
7
7
|
EndProject
|
8
8
|
Global
|
9
9
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
10
|
+
Debug|ARM = Debug|ARM
|
11
|
+
Debug|ARM64 = Debug|ARM64
|
10
12
|
Debug|x64 = Debug|x64
|
11
13
|
Debug|x86 = Debug|x86
|
14
|
+
Release|ARM = Release|ARM
|
15
|
+
Release|ARM64 = Release|ARM64
|
12
16
|
Release|x64 = Release|x64
|
13
17
|
Release|x86 = Release|x86
|
14
18
|
EndGlobalSection
|
15
19
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
20
|
+
{6B4978F4-3B5F-4D38-81A8-069EC28CC069}.Debug|ARM.ActiveCfg = Debug|Win32
|
21
|
+
{6B4978F4-3B5F-4D38-81A8-069EC28CC069}.Debug|ARM64.ActiveCfg = Debug|Win32
|
16
22
|
{6B4978F4-3B5F-4D38-81A8-069EC28CC069}.Debug|x64.ActiveCfg = Debug|x64
|
17
23
|
{6B4978F4-3B5F-4D38-81A8-069EC28CC069}.Debug|x64.Build.0 = Debug|x64
|
18
24
|
{6B4978F4-3B5F-4D38-81A8-069EC28CC069}.Debug|x86.ActiveCfg = Debug|Win32
|
19
25
|
{6B4978F4-3B5F-4D38-81A8-069EC28CC069}.Debug|x86.Build.0 = Debug|Win32
|
26
|
+
{6B4978F4-3B5F-4D38-81A8-069EC28CC069}.Release|ARM.ActiveCfg = Release|Win32
|
27
|
+
{6B4978F4-3B5F-4D38-81A8-069EC28CC069}.Release|ARM64.ActiveCfg = Release|Win32
|
20
28
|
{6B4978F4-3B5F-4D38-81A8-069EC28CC069}.Release|x64.ActiveCfg = Release|x64
|
21
29
|
{6B4978F4-3B5F-4D38-81A8-069EC28CC069}.Release|x64.Build.0 = Release|x64
|
22
30
|
{6B4978F4-3B5F-4D38-81A8-069EC28CC069}.Release|x86.ActiveCfg = Release|Win32
|
@@ -64,7 +64,7 @@
|
|
64
64
|
</PropertyGroup>
|
65
65
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
66
66
|
<TargetExt>.so</TargetExt>
|
67
|
-
<OutDir>..\..\..\lib
|
67
|
+
<OutDir>..\..\..\lib\</OutDir>
|
68
68
|
</PropertyGroup>
|
69
69
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
70
70
|
<ClCompile>
|
@@ -102,17 +102,28 @@
|
|
102
102
|
</ItemDefinitionGroup>
|
103
103
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
104
104
|
<ClCompile>
|
105
|
-
<AdditionalIncludeDirectories>C:\msys64\usr\local\ruby-2.7.
|
105
|
+
<AdditionalIncludeDirectories>C:\msys64\usr\local\ruby-2.7.2vc\include\ruby-2.7.0\x64-mswin64_140;C:\msys64\usr\local\ruby-2.7.2vc\include\ruby-2.7.0;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
106
106
|
<Optimization>Disabled</Optimization>
|
107
|
-
<PreprocessorDefinitions
|
107
|
+
<PreprocessorDefinitions>%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
108
|
+
<WarningLevel>Level3</WarningLevel>
|
108
109
|
</ClCompile>
|
109
110
|
<Link>
|
110
|
-
<AdditionalLibraryDirectories>C:\msys64\usr\local\ruby-2.7.
|
111
|
+
<AdditionalLibraryDirectories>C:\msys64\usr\local\ruby-2.7.2vc\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
111
112
|
<AdditionalDependencies>x64-vcruntime140-ruby270.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
112
113
|
<ModuleDefinitionFile>ruby_prof.def</ModuleDefinitionFile>
|
113
114
|
<SubSystem>Console</SubSystem>
|
114
115
|
</Link>
|
115
116
|
</ItemDefinitionGroup>
|
117
|
+
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
118
|
+
<ClCompile>
|
119
|
+
<AdditionalIncludeDirectories>C:\msys64\usr\local\ruby-2.7.1vc\include\ruby-2.7.0\x64-mswin64_140;C:\msys64\usr\local\ruby-2.7.1vc\include\ruby-2.7.0;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
120
|
+
</ClCompile>
|
121
|
+
<Link>
|
122
|
+
<AdditionalLibraryDirectories>C:\msys64\usr\local\ruby-2.7.1vc\lib</AdditionalLibraryDirectories>
|
123
|
+
<AdditionalDependencies>x64-vcruntime140-ruby270.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
124
|
+
<ModuleDefinitionFile>ruby_prof.def</ModuleDefinitionFile>
|
125
|
+
</Link>
|
126
|
+
</ItemDefinitionGroup>
|
116
127
|
<ItemGroup>
|
117
128
|
<ClInclude Include="..\rp_aggregate_call_tree.h" />
|
118
129
|
<ClInclude Include="..\rp_allocation.h" />
|
Binary file
|
Binary file
|
data/lib/ruby-prof.rb
CHANGED
@@ -1,11 +1,12 @@
|
|
1
1
|
# encoding: utf-8
|
2
|
+
require 'rubygems/version'
|
2
3
|
|
3
4
|
# Load the C-based binding.
|
4
5
|
begin
|
5
|
-
|
6
|
-
require "#{
|
6
|
+
version = Gem::Version.new(RUBY_VERSION)
|
7
|
+
require "#{version.segments[0..1].join('.')}/ruby_prof.so"
|
7
8
|
rescue LoadError
|
8
|
-
|
9
|
+
require_relative "../ext/ruby_prof/ruby_prof.so"
|
9
10
|
end
|
10
11
|
|
11
12
|
require 'ruby-prof/version'
|
@@ -81,16 +81,6 @@ module RubyProf
|
|
81
81
|
Profile.profile(options, &block)
|
82
82
|
end
|
83
83
|
|
84
|
-
# :nodoc:
|
85
|
-
def self.measure_mode_string
|
86
|
-
case measure_mode
|
87
|
-
when WALL_TIME then "wall_time"
|
88
|
-
when PROCESS_TIME then "process_time"
|
89
|
-
when ALLOCATIONS then "allocations"
|
90
|
-
when MEMORY then "memory"
|
91
|
-
end
|
92
|
-
end
|
93
|
-
|
94
84
|
# :nodoc:
|
95
85
|
def self.start_script(script)
|
96
86
|
start
|
@@ -17,11 +17,21 @@ module RubyProf
|
|
17
17
|
@output = nil
|
18
18
|
end
|
19
19
|
|
20
|
-
# Returns the min_percent of
|
20
|
+
# Returns the min_percent of time a method must take to be included in a profiling report
|
21
21
|
def min_percent
|
22
22
|
@options[:min_percent] || 0
|
23
23
|
end
|
24
24
|
|
25
|
+
# Returns the max_percent of time a method can take to be included in a profiling report
|
26
|
+
def max_percent
|
27
|
+
@options[:max_percent] || 100
|
28
|
+
end
|
29
|
+
|
30
|
+
# Returns the method to filter methods by (when using min_percent and max_percent)
|
31
|
+
def filter_by
|
32
|
+
@options[:filter_by] || :self_time
|
33
|
+
end
|
34
|
+
|
25
35
|
# Returns the time format used to show when a profile was run
|
26
36
|
def time_format
|
27
37
|
'%A, %B %-d at %l:%M:%S %p (%Z)'
|
@@ -89,7 +99,7 @@ module RubyProf
|
|
89
99
|
end
|
90
100
|
|
91
101
|
def print_header(thread)
|
92
|
-
@output << "Measure Mode: %s\n" %
|
102
|
+
@output << "Measure Mode: %s\n" % @result.measure_mode_string
|
93
103
|
@output << "Thread ID: %d\n" % thread.id
|
94
104
|
@output << "Fiber ID: %d\n" % thread.fiber_id unless thread.id == thread.fiber_id
|
95
105
|
@output << "Total: %0.6f\n" % thread.total_time
|
@@ -103,7 +113,7 @@ module RubyProf
|
|
103
113
|
|
104
114
|
def print_footer(thread)
|
105
115
|
@output << <<~EOT
|
106
|
-
|
116
|
+
|
107
117
|
* recursively called methods
|
108
118
|
|
109
119
|
Columns are:
|
@@ -29,8 +29,9 @@ module RubyProf
|
|
29
29
|
|
30
30
|
sum = 0
|
31
31
|
methods.each do |method|
|
32
|
-
|
33
|
-
next if
|
32
|
+
percent = (method.send(filter_by) / total_time) * 100
|
33
|
+
next if percent < min_percent
|
34
|
+
next if percent > max_percent
|
34
35
|
|
35
36
|
sum += method.self_time
|
36
37
|
#self_time_called = method.called > 0 ? method.self_time/method.called : 0
|
@@ -25,7 +25,7 @@ module RubyProf
|
|
25
25
|
end
|
26
26
|
|
27
27
|
def print_header(thread)
|
28
|
-
@output << "Measure Mode: %s\n" %
|
28
|
+
@output << "Measure Mode: %s\n" % @result.measure_mode_string
|
29
29
|
@output << "Thread ID: #{thread.id}\n"
|
30
30
|
@output << "Fiber ID: #{thread.fiber_id}\n"
|
31
31
|
@output << "Total Time: #{thread.total_time}\n"
|
data/lib/ruby-prof/profile.rb
CHANGED
@@ -7,10 +7,14 @@ module RubyProf
|
|
7
7
|
# :nodoc:
|
8
8
|
def measure_mode_string
|
9
9
|
case self.measure_mode
|
10
|
-
when WALL_TIME
|
11
|
-
|
12
|
-
when
|
13
|
-
|
10
|
+
when WALL_TIME
|
11
|
+
"wall_time"
|
12
|
+
when PROCESS_TIME
|
13
|
+
"process_time"
|
14
|
+
when ALLOCATIONS
|
15
|
+
"allocations"
|
16
|
+
when MEMORY
|
17
|
+
"memory"
|
14
18
|
end
|
15
19
|
end
|
16
20
|
|
data/lib/ruby-prof/rack.rb
CHANGED
@@ -5,43 +5,37 @@ module Rack
|
|
5
5
|
class RubyProf
|
6
6
|
def initialize(app, options = {})
|
7
7
|
@app = app
|
8
|
+
@options = options
|
9
|
+
@options[:min_percent] ||= 1
|
8
10
|
|
9
|
-
options[:
|
11
|
+
@tmpdir = options[:path] || Dir.tmpdir
|
12
|
+
FileUtils.mkdir_p(@tmpdir)
|
10
13
|
|
11
|
-
options[:
|
12
|
-
|
14
|
+
@printer_klasses = @options[:printers] || {::RubyProf::FlatPrinter => 'flat.txt',
|
15
|
+
::RubyProf::GraphPrinter => 'graph.txt',
|
16
|
+
::RubyProf::GraphHtmlPrinter => 'graph.html',
|
17
|
+
::RubyProf::CallStackPrinter => 'call_stack.html'}
|
13
18
|
|
14
19
|
@skip_paths = options[:skip_paths] || [%r{^/assets}, %r{\.(css|js|png|jpeg|jpg|gif)$}]
|
15
20
|
@only_paths = options[:only_paths]
|
16
|
-
|
17
|
-
@max_requests = options[:max_requests]
|
18
|
-
|
19
|
-
@options = options
|
20
21
|
end
|
21
22
|
|
22
23
|
def call(env)
|
23
24
|
request = Rack::Request.new(env)
|
24
25
|
|
25
26
|
if should_profile?(request.path)
|
26
|
-
profiler.resume
|
27
27
|
begin
|
28
|
-
result =
|
29
|
-
|
30
|
-
|
31
|
-
|
28
|
+
result = nil
|
29
|
+
data = ::RubyProf::Profile.profile(profiling_options) do
|
30
|
+
result = @app.call(env)
|
31
|
+
end
|
32
32
|
|
33
|
-
|
34
|
-
|
35
|
-
nil
|
36
|
-
else
|
37
|
-
request.path.gsub('/', '-')[1..-1]
|
38
|
-
end
|
33
|
+
path = request.path.gsub('/', '-')
|
34
|
+
path.slice!(0)
|
39
35
|
|
40
|
-
|
41
|
-
|
36
|
+
print(data, path)
|
37
|
+
result
|
42
38
|
end
|
43
|
-
|
44
|
-
result
|
45
39
|
else
|
46
40
|
@app.call(env)
|
47
41
|
end
|
@@ -49,126 +43,53 @@ module Rack
|
|
49
43
|
|
50
44
|
private
|
51
45
|
|
52
|
-
|
53
|
-
|
54
|
-
@options = options
|
55
|
-
|
56
|
-
@profile = ::RubyProf::Profile.new(profiling_options)
|
57
|
-
@profile.start
|
58
|
-
@profile.pause
|
59
|
-
|
60
|
-
@printer_klasses = options[:printers] || default_printers
|
61
|
-
|
62
|
-
@tmpdir = options[:path]
|
63
|
-
|
64
|
-
@max_requests = options[:max_requests] || 1
|
65
|
-
@requests_count = 0
|
46
|
+
def should_profile?(path)
|
47
|
+
return false if paths_match?(path, @skip_paths)
|
66
48
|
|
67
|
-
|
68
|
-
|
69
|
-
# ongoing profile is not lost if the process shuts down before the
|
70
|
-
# max request count is reached
|
71
|
-
ObjectSpace.define_finalizer(self, proc { print! })
|
72
|
-
end
|
49
|
+
@only_paths ? paths_match?(path, @only_paths) : true
|
50
|
+
end
|
73
51
|
|
74
|
-
|
75
|
-
|
76
|
-
|
52
|
+
def paths_match?(path, paths)
|
53
|
+
paths.any? { |skip_path| skip_path =~ path }
|
54
|
+
end
|
77
55
|
|
78
|
-
|
79
|
-
|
80
|
-
|
56
|
+
def profiling_options
|
57
|
+
options = {}
|
58
|
+
options[:measure_mode] = ::RubyProf.measure_mode
|
59
|
+
options[:exclude_threads] =
|
60
|
+
if @options[:ignore_existing_threads]
|
61
|
+
Thread.list.select{|t| t != Thread.current}
|
62
|
+
else
|
63
|
+
::RubyProf.exclude_threads
|
64
|
+
end
|
65
|
+
if @options[:request_thread_only]
|
66
|
+
options[:include_threads] = [Thread.current]
|
81
67
|
end
|
82
|
-
|
83
|
-
|
84
|
-
@requests_count >= @max_requests
|
68
|
+
if @options[:merge_fibers]
|
69
|
+
options[:merge_fibers] = true
|
85
70
|
end
|
71
|
+
options
|
72
|
+
end
|
86
73
|
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
data = @profile.stop
|
91
|
-
|
92
|
-
prefix ||= "multi-requests-#{@requests_count}"
|
93
|
-
|
94
|
-
@printer_klasses.each do |printer_klass, base_name|
|
95
|
-
printer = printer_klass.new(data)
|
96
|
-
|
97
|
-
if base_name.respond_to?(:call)
|
98
|
-
base_name = base_name.call
|
99
|
-
end
|
74
|
+
def print(data, path)
|
75
|
+
@printer_klasses.each do |printer_klass, base_name|
|
76
|
+
printer = printer_klass.new(data)
|
100
77
|
|
101
|
-
|
102
|
-
|
103
|
-
printer.print(@options.merge(:profile => "#{prefix}-#{base_name}"))
|
104
|
-
else
|
105
|
-
file_name = ::File.join(@tmpdir, "#{prefix}-#{base_name}")
|
106
|
-
::File.open(file_name, 'wb') do |file|
|
107
|
-
printer.print(file, @options)
|
108
|
-
end
|
109
|
-
end
|
78
|
+
if base_name.respond_to?(:call)
|
79
|
+
base_name = base_name.call
|
110
80
|
end
|
111
81
|
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
options[:exclude_threads] =
|
121
|
-
if @options[:ignore_existing_threads]
|
122
|
-
Thread.list.select{|t| t != Thread.current}
|
123
|
-
else
|
124
|
-
::RubyProf.exclude_threads
|
82
|
+
if printer_klass == ::RubyProf::MultiPrinter
|
83
|
+
printer.print(@options.merge(:profile => "#{path}-#{base_name}"))
|
84
|
+
elsif printer_klass == ::RubyProf::CallTreePrinter
|
85
|
+
printer.print(@options.merge(:profile => "#{path}-#{base_name}"))
|
86
|
+
else
|
87
|
+
file_name = ::File.join(@tmpdir, "#{path}-#{base_name}")
|
88
|
+
::File.open(file_name, 'wb') do |file|
|
89
|
+
printer.print(file, @options)
|
125
90
|
end
|
126
|
-
if @options[:request_thread_only]
|
127
|
-
options[:include_threads] = [Thread.current]
|
128
91
|
end
|
129
|
-
if @options[:merge_fibers]
|
130
|
-
options[:merge_fibers] = true
|
131
|
-
end
|
132
|
-
options
|
133
|
-
end
|
134
|
-
|
135
|
-
def default_printers
|
136
|
-
{::RubyProf::FlatPrinter => 'flat.txt',
|
137
|
-
::RubyProf::GraphPrinter => 'graph.txt',
|
138
|
-
::RubyProf::GraphHtmlPrinter => 'graph.html',
|
139
|
-
::RubyProf::CallStackPrinter => 'call_stack.html'}
|
140
92
|
end
|
141
93
|
end
|
142
|
-
|
143
|
-
def profiler
|
144
|
-
if aggregate_requests?
|
145
|
-
@@_shared_profiler ||= RackProfiler.new(@options)
|
146
|
-
else
|
147
|
-
@_profiler ||= RackProfiler.new(@options)
|
148
|
-
end
|
149
|
-
end
|
150
|
-
|
151
|
-
def delete_profiler!
|
152
|
-
if aggregate_requests?
|
153
|
-
@@_shared_profiler.print! if @@_shared_profiler
|
154
|
-
@@_shared_profiler = nil
|
155
|
-
else
|
156
|
-
@_profiler = nil
|
157
|
-
end
|
158
|
-
end
|
159
|
-
|
160
|
-
def aggregate_requests?
|
161
|
-
!@max_requests.nil?
|
162
|
-
end
|
163
|
-
|
164
|
-
def should_profile?(path)
|
165
|
-
return false if paths_match?(path, @skip_paths)
|
166
|
-
|
167
|
-
@only_paths ? paths_match?(path, @only_paths) : true
|
168
|
-
end
|
169
|
-
|
170
|
-
def paths_match?(path, paths)
|
171
|
-
paths.any? { |skip_path| skip_path =~ path }
|
172
|
-
end
|
173
94
|
end
|
174
95
|
end
|