ruby-prof 1.6.3 → 1.7.2
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 +19 -0
- data/ext/ruby_prof/extconf.rb +23 -22
- data/ext/ruby_prof/rp_allocation.c +342 -342
- data/ext/ruby_prof/rp_call_tree.c +1 -1
- data/ext/ruby_prof/rp_call_tree.h +1 -1
- data/ext/ruby_prof/rp_call_trees.c +296 -296
- data/ext/ruby_prof/rp_call_trees.h +28 -28
- data/ext/ruby_prof/rp_measure_allocations.c +47 -47
- data/ext/ruby_prof/rp_measure_memory.c +46 -46
- data/ext/ruby_prof/rp_measure_process_time.c +64 -66
- data/ext/ruby_prof/rp_measure_wall_time.c +52 -64
- data/ext/ruby_prof/rp_measurement.c +364 -364
- data/ext/ruby_prof/rp_method.c +551 -550
- data/ext/ruby_prof/rp_method.h +5 -2
- data/ext/ruby_prof/rp_profile.c +2 -2
- data/ext/ruby_prof/rp_profile.h +36 -36
- data/ext/ruby_prof/rp_stack.c +212 -212
- data/ext/ruby_prof/rp_thread.c +1 -1
- data/ext/ruby_prof/ruby_prof.c +50 -50
- data/ext/ruby_prof/ruby_prof.h +35 -34
- data/ext/ruby_prof/vc/ruby_prof.vcxproj +5 -7
- data/lib/ruby-prof/compatibility.rb +113 -113
- data/lib/ruby-prof/exclude_common_methods.rb +204 -198
- data/lib/ruby-prof/method_info.rb +87 -85
- data/lib/ruby-prof/printers/abstract_printer.rb +156 -138
- data/lib/ruby-prof/version.rb +3 -3
- data/ruby-prof.gemspec +66 -64
- data/test/dynamic_method_test.rb +9 -21
- data/test/enumerable_test.rb +23 -21
- data/test/exclude_methods_test.rb +363 -146
- data/test/fiber_test.rb +195 -195
- data/test/gc_test.rb +104 -102
- data/test/line_number_test.rb +426 -134
- data/test/measure_allocations_test.rb +1172 -660
- data/test/measure_memory_test.rb +1193 -1024
- data/test/measure_process_time_test.rb +3330 -1610
- data/test/measure_wall_time_test.rb +634 -420
- data/test/merge_test.rb +146 -146
- data/test/method_info_test.rb +100 -95
- data/test/printers_test.rb +178 -135
- data/test/recursive_test.rb +796 -425
- data/test/start_stop_test.rb +4 -4
- data/test/test_helper.rb +20 -20
- data/test/thread_test.rb +229 -235
- data/test/unique_call_path_test.rb +9 -22
- data/test/yarv_test.rb +1 -5
- metadata +33 -8
data/ext/ruby_prof/ruby_prof.h
CHANGED
|
@@ -1,34 +1,35 @@
|
|
|
1
|
-
/* Copyright (C) 2005-2019 Shugo Maeda <shugo@ruby-lang.org> and Charlie Savage <cfis@savagexi.com>
|
|
2
|
-
Please see the LICENSE file for copyright and distribution information */
|
|
3
|
-
|
|
4
|
-
#ifndef __RUBY_PROF_H__
|
|
5
|
-
#define __RUBY_PROF_H__
|
|
6
|
-
|
|
7
|
-
#include <
|
|
8
|
-
#include <
|
|
9
|
-
|
|
10
|
-
#include <
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
#
|
|
14
|
-
#define
|
|
15
|
-
#define
|
|
16
|
-
#define
|
|
17
|
-
#define
|
|
18
|
-
#
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
1
|
+
/* Copyright (C) 2005-2019 Shugo Maeda <shugo@ruby-lang.org> and Charlie Savage <cfis@savagexi.com>
|
|
2
|
+
Please see the LICENSE file for copyright and distribution information */
|
|
3
|
+
|
|
4
|
+
#ifndef __RUBY_PROF_H__
|
|
5
|
+
#define __RUBY_PROF_H__
|
|
6
|
+
|
|
7
|
+
#include <stdio.h>
|
|
8
|
+
#include <stdbool.h>
|
|
9
|
+
|
|
10
|
+
#include <ruby.h>
|
|
11
|
+
#include <ruby/debug.h>
|
|
12
|
+
|
|
13
|
+
#ifndef rb_st_lookup
|
|
14
|
+
#define rb_st_foreach st_foreach
|
|
15
|
+
#define rb_st_free_table st_free_table
|
|
16
|
+
#define rb_st_init_numtable st_init_numtable
|
|
17
|
+
#define rb_st_insert st_insert
|
|
18
|
+
#define rb_st_lookup st_lookup
|
|
19
|
+
#endif
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
extern VALUE mProf;
|
|
23
|
+
|
|
24
|
+
// This method is not exposed in Ruby header files - at least not as of Ruby 2.6.3 :(
|
|
25
|
+
extern size_t rb_obj_memsize_of(VALUE);
|
|
26
|
+
|
|
27
|
+
typedef enum
|
|
28
|
+
{
|
|
29
|
+
OWNER_UNKNOWN = 0,
|
|
30
|
+
OWNER_RUBY = 1,
|
|
31
|
+
OWNER_C = 2
|
|
32
|
+
} prof_owner_t;
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
#endif //__RUBY_PROF_H__
|
|
@@ -66,7 +66,7 @@
|
|
|
66
66
|
</PropertyGroup>
|
|
67
67
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
|
68
68
|
<TargetExt>.so</TargetExt>
|
|
69
|
-
<OutDir>$(SolutionDir)
|
|
69
|
+
<OutDir>$(SolutionDir)\..\</OutDir>
|
|
70
70
|
</PropertyGroup>
|
|
71
71
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
|
72
72
|
<ClCompile>
|
|
@@ -104,20 +104,18 @@
|
|
|
104
104
|
</ItemDefinitionGroup>
|
|
105
105
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
|
106
106
|
<ClCompile>
|
|
107
|
-
<AdditionalIncludeDirectories>C:\msys64\usr\local\ruby-3.
|
|
107
|
+
<AdditionalIncludeDirectories>C:\msys64\usr\local\ruby-3.4.3-mswin\include\ruby-3.4.0\x64-mswin64_140;C:\msys64\usr\local\ruby-3.4.3-mswin\include\ruby-3.4.0;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
|
108
108
|
<Optimization>Disabled</Optimization>
|
|
109
109
|
<PreprocessorDefinitions>%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
|
110
110
|
<WarningLevel>Level3</WarningLevel>
|
|
111
111
|
</ClCompile>
|
|
112
112
|
<Link>
|
|
113
|
-
<AdditionalLibraryDirectories>C:\msys64\usr\local\ruby-3.
|
|
114
|
-
<AdditionalDependencies>x64-vcruntime140-
|
|
113
|
+
<AdditionalLibraryDirectories>C:\msys64\usr\local\ruby-3.4.3-mswin\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
|
114
|
+
<AdditionalDependencies>x64-vcruntime140-ruby340.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
|
115
115
|
<ModuleDefinitionFile>ruby_prof.def</ModuleDefinitionFile>
|
|
116
116
|
<SubSystem>Console</SubSystem>
|
|
117
117
|
</Link>
|
|
118
|
-
<ProjectReference
|
|
119
|
-
<LinkLibraryDependencies>false</LinkLibraryDependencies>
|
|
120
|
-
</ProjectReference>
|
|
118
|
+
<ProjectReference />
|
|
121
119
|
</ItemDefinitionGroup>
|
|
122
120
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
|
123
121
|
<ClCompile>
|
|
@@ -1,113 +1,113 @@
|
|
|
1
|
-
# encoding: utf-8
|
|
2
|
-
|
|
3
|
-
# These methods are deprecated and are available for backwards compatability.
|
|
4
|
-
module RubyProf
|
|
5
|
-
# call-seq:
|
|
6
|
-
# measure_mode -> measure_mode
|
|
7
|
-
#
|
|
8
|
-
# Returns what ruby-prof is measuring. Valid values include:
|
|
9
|
-
#
|
|
10
|
-
# * RubyProf::WALL_TIME
|
|
11
|
-
# * RubyProf::PROCESS_TIME
|
|
12
|
-
# * RubyProf::ALLOCATIONS
|
|
13
|
-
# * RubyProf::MEMORY
|
|
14
|
-
def self.measure_mode
|
|
15
|
-
@measure_mode ||= RubyProf::WALL_TIME
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
# call-seq:
|
|
19
|
-
# measure_mode=value -> void
|
|
20
|
-
#
|
|
21
|
-
# Specifies what ruby-prof should measure. Valid values include:
|
|
22
|
-
#
|
|
23
|
-
# * RubyProf::WALL_TIME - Wall time measures the real-world time elapsed between any two moments. If there are other processes concurrently running on the system that use significant CPU or disk time during a profiling run then the reported results will be larger than expected. On Windows, wall time is measured using GetTickCount(), on MacOS by mach_absolute_time, on Linux by clock_gettime and otherwise by gettimeofday.
|
|
24
|
-
# * RubyProf::PROCESS_TIME - Process time measures the time used by a process between any two moments. It is unaffected by other processes concurrently running on the system. Remember with process time that calls to methods like sleep will not be included in profiling results. On Windows, process time is measured using GetProcessTimes and on other platforms by clock_gettime.
|
|
25
|
-
# * RubyProf::ALLOCATIONS - Object allocations measures show how many objects each method in a program allocates. Measurements are done via Ruby's GC.stat api.
|
|
26
|
-
# * RubyProf::MEMORY - Memory measures how much memory each method in a program uses. Measurements are done via Ruby's TracePoint api.
|
|
27
|
-
def self.measure_mode=(value)
|
|
28
|
-
@measure_mode = value
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
# Returns the threads that ruby-prof should exclude from profiling
|
|
32
|
-
def self.exclude_threads
|
|
33
|
-
@exclude_threads ||= Array.new
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
# Specifies which threads ruby-prof should exclude from profiling
|
|
37
|
-
def self.exclude_threads=(value)
|
|
38
|
-
@exclude_threads = value
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
# Starts profiling
|
|
42
|
-
def self.start
|
|
43
|
-
ensure_not_running!
|
|
44
|
-
@profile = Profile.new(:measure_mode => measure_mode, :exclude_threads => exclude_threads)
|
|
45
|
-
@profile.start
|
|
46
|
-
end
|
|
47
|
-
|
|
48
|
-
# Pauses profiling
|
|
49
|
-
def self.pause
|
|
50
|
-
ensure_running!
|
|
51
|
-
@profile.pause
|
|
52
|
-
end
|
|
53
|
-
|
|
54
|
-
# Is a profile running?
|
|
55
|
-
def self.running?
|
|
56
|
-
if defined?(@profile) and @profile
|
|
57
|
-
@profile.running?
|
|
58
|
-
else
|
|
59
|
-
false
|
|
60
|
-
end
|
|
61
|
-
end
|
|
62
|
-
|
|
63
|
-
# Resume profiling
|
|
64
|
-
def self.resume
|
|
65
|
-
ensure_running!
|
|
66
|
-
@profile.resume
|
|
67
|
-
end
|
|
68
|
-
|
|
69
|
-
# Stops profiling
|
|
70
|
-
def self.stop
|
|
71
|
-
ensure_running!
|
|
72
|
-
result = @profile.stop
|
|
73
|
-
@profile = nil
|
|
74
|
-
result
|
|
75
|
-
end
|
|
76
|
-
|
|
77
|
-
# Profiles a block
|
|
78
|
-
def self.profile(options = {}, &block)
|
|
79
|
-
ensure_not_running!
|
|
80
|
-
options = {:measure_mode => measure_mode, :exclude_threads => exclude_threads }.merge!(options)
|
|
81
|
-
Profile.profile(options, &block)
|
|
82
|
-
end
|
|
83
|
-
|
|
84
|
-
# :nodoc:
|
|
85
|
-
def self.start_script(script)
|
|
86
|
-
start
|
|
87
|
-
load script
|
|
88
|
-
end
|
|
89
|
-
|
|
90
|
-
private
|
|
91
|
-
|
|
92
|
-
def self.ensure_running!
|
|
93
|
-
raise(RuntimeError, "RubyProf.start was not yet called") unless running?
|
|
94
|
-
end
|
|
95
|
-
|
|
96
|
-
def self.ensure_not_running!
|
|
97
|
-
raise(RuntimeError, "RubyProf is already running") if running?
|
|
98
|
-
end
|
|
99
|
-
|
|
100
|
-
class << self
|
|
101
|
-
extend Gem::Deprecate
|
|
102
|
-
deprecate :measure_mode, "Profile#measure_mode", 2023, 6
|
|
103
|
-
deprecate :measure_mode=, "Profile
|
|
104
|
-
deprecate :exclude_threads, "Profile#exclude_threads", 2023, 6
|
|
105
|
-
deprecate :exclude_threads=, "Profile#initialize", 2023, 6
|
|
106
|
-
deprecate :start, "Profile#start", 2023, 6
|
|
107
|
-
deprecate :pause, "Profile#pause", 2023, 6
|
|
108
|
-
deprecate :stop, "Profile#stop", 2023, 6
|
|
109
|
-
deprecate :resume, "Profile#resume", 2023, 6
|
|
110
|
-
deprecate :running?, "Profile#running?", 2023, 6
|
|
111
|
-
deprecate :profile, "Profile.profile", 2023, 6
|
|
112
|
-
end
|
|
113
|
-
end
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
3
|
+
# These methods are deprecated and are available for backwards compatability.
|
|
4
|
+
module RubyProf
|
|
5
|
+
# call-seq:
|
|
6
|
+
# measure_mode -> measure_mode
|
|
7
|
+
#
|
|
8
|
+
# Returns what ruby-prof is measuring. Valid values include:
|
|
9
|
+
#
|
|
10
|
+
# * RubyProf::WALL_TIME
|
|
11
|
+
# * RubyProf::PROCESS_TIME
|
|
12
|
+
# * RubyProf::ALLOCATIONS
|
|
13
|
+
# * RubyProf::MEMORY
|
|
14
|
+
def self.measure_mode
|
|
15
|
+
@measure_mode ||= RubyProf::WALL_TIME
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
# call-seq:
|
|
19
|
+
# measure_mode=value -> void
|
|
20
|
+
#
|
|
21
|
+
# Specifies what ruby-prof should measure. Valid values include:
|
|
22
|
+
#
|
|
23
|
+
# * RubyProf::WALL_TIME - Wall time measures the real-world time elapsed between any two moments. If there are other processes concurrently running on the system that use significant CPU or disk time during a profiling run then the reported results will be larger than expected. On Windows, wall time is measured using GetTickCount(), on MacOS by mach_absolute_time, on Linux by clock_gettime and otherwise by gettimeofday.
|
|
24
|
+
# * RubyProf::PROCESS_TIME - Process time measures the time used by a process between any two moments. It is unaffected by other processes concurrently running on the system. Remember with process time that calls to methods like sleep will not be included in profiling results. On Windows, process time is measured using GetProcessTimes and on other platforms by clock_gettime.
|
|
25
|
+
# * RubyProf::ALLOCATIONS - Object allocations measures show how many objects each method in a program allocates. Measurements are done via Ruby's GC.stat api.
|
|
26
|
+
# * RubyProf::MEMORY - Memory measures how much memory each method in a program uses. Measurements are done via Ruby's TracePoint api.
|
|
27
|
+
def self.measure_mode=(value)
|
|
28
|
+
@measure_mode = value
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
# Returns the threads that ruby-prof should exclude from profiling
|
|
32
|
+
def self.exclude_threads
|
|
33
|
+
@exclude_threads ||= Array.new
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
# Specifies which threads ruby-prof should exclude from profiling
|
|
37
|
+
def self.exclude_threads=(value)
|
|
38
|
+
@exclude_threads = value
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
# Starts profiling
|
|
42
|
+
def self.start
|
|
43
|
+
ensure_not_running!
|
|
44
|
+
@profile = Profile.new(:measure_mode => measure_mode, :exclude_threads => exclude_threads)
|
|
45
|
+
@profile.start
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
# Pauses profiling
|
|
49
|
+
def self.pause
|
|
50
|
+
ensure_running!
|
|
51
|
+
@profile.pause
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
# Is a profile running?
|
|
55
|
+
def self.running?
|
|
56
|
+
if defined?(@profile) and @profile
|
|
57
|
+
@profile.running?
|
|
58
|
+
else
|
|
59
|
+
false
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
# Resume profiling
|
|
64
|
+
def self.resume
|
|
65
|
+
ensure_running!
|
|
66
|
+
@profile.resume
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
# Stops profiling
|
|
70
|
+
def self.stop
|
|
71
|
+
ensure_running!
|
|
72
|
+
result = @profile.stop
|
|
73
|
+
@profile = nil
|
|
74
|
+
result
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
# Profiles a block
|
|
78
|
+
def self.profile(options = {}, &block)
|
|
79
|
+
ensure_not_running!
|
|
80
|
+
options = {:measure_mode => measure_mode, :exclude_threads => exclude_threads }.merge!(options)
|
|
81
|
+
Profile.profile(options, &block)
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
# :nodoc:
|
|
85
|
+
def self.start_script(script)
|
|
86
|
+
start
|
|
87
|
+
load script
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
private
|
|
91
|
+
|
|
92
|
+
def self.ensure_running!
|
|
93
|
+
raise(RuntimeError, "RubyProf.start was not yet called") unless running?
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
def self.ensure_not_running!
|
|
97
|
+
raise(RuntimeError, "RubyProf is already running") if running?
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
class << self
|
|
101
|
+
extend Gem::Deprecate
|
|
102
|
+
deprecate :measure_mode, "RubyProf::Profile#measure_mode", 2023, 6
|
|
103
|
+
deprecate :measure_mode=, "RubyProf::Profile.new(measure_mode: ...)", 2023, 6
|
|
104
|
+
deprecate :exclude_threads, "RubyProf::Profile#exclude_threads", 2023, 6
|
|
105
|
+
deprecate :exclude_threads=, "RubyProf::Profile#initialize", 2023, 6
|
|
106
|
+
deprecate :start, "RubyProf::Profile#start", 2023, 6
|
|
107
|
+
deprecate :pause, "RubyProf::Profile#pause", 2023, 6
|
|
108
|
+
deprecate :stop, "RubyProf::Profile#stop", 2023, 6
|
|
109
|
+
deprecate :resume, "RubyProf::Profile#resume", 2023, 6
|
|
110
|
+
deprecate :running?, "RubyProf::Profile#running?", 2023, 6
|
|
111
|
+
deprecate :profile, "RubyProf::Profile.profile", 2023, 6
|
|
112
|
+
end
|
|
113
|
+
end
|