ruby-prof 0.18.0-x64-mingw32 → 1.1.0-x64-mingw32
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 +32 -0
- data/LICENSE +2 -2
- data/README.rdoc +1 -483
- data/Rakefile +3 -6
- data/bin/ruby-prof +65 -30
- data/ext/ruby_prof/extconf.rb +6 -38
- data/ext/ruby_prof/rp_allocation.c +279 -0
- data/ext/ruby_prof/rp_allocation.h +31 -0
- data/ext/ruby_prof/rp_call_info.c +129 -283
- data/ext/ruby_prof/rp_call_info.h +16 -34
- data/ext/ruby_prof/rp_measure_allocations.c +25 -49
- data/ext/ruby_prof/rp_measure_memory.c +21 -56
- data/ext/ruby_prof/rp_measure_process_time.c +35 -39
- data/ext/ruby_prof/rp_measure_wall_time.c +36 -19
- data/ext/ruby_prof/rp_measurement.c +230 -0
- data/ext/ruby_prof/rp_measurement.h +50 -0
- data/ext/ruby_prof/rp_method.c +389 -389
- data/ext/ruby_prof/rp_method.h +34 -39
- data/ext/ruby_prof/rp_profile.c +895 -0
- data/ext/ruby_prof/rp_profile.h +37 -0
- data/ext/ruby_prof/rp_stack.c +103 -80
- data/ext/ruby_prof/rp_stack.h +5 -12
- data/ext/ruby_prof/rp_thread.c +143 -83
- data/ext/ruby_prof/rp_thread.h +15 -6
- data/ext/ruby_prof/ruby_prof.c +11 -757
- data/ext/ruby_prof/ruby_prof.h +4 -47
- data/ext/ruby_prof/vc/ruby_prof.vcxproj +10 -8
- data/lib/{2.6.3 → 2.6.5}/ruby_prof.so +0 -0
- data/lib/ruby-prof.rb +2 -18
- data/lib/ruby-prof/assets/call_stack_printer.html.erb +713 -0
- data/lib/ruby-prof/assets/call_stack_printer.png +0 -0
- data/lib/ruby-prof/assets/graph_printer.html.erb +356 -0
- data/lib/ruby-prof/call_info.rb +35 -93
- data/lib/ruby-prof/call_info_visitor.rb +19 -21
- data/lib/ruby-prof/compatibility.rb +37 -107
- data/lib/ruby-prof/exclude_common_methods.rb +198 -0
- data/lib/ruby-prof/measurement.rb +14 -0
- data/lib/ruby-prof/method_info.rb +52 -83
- data/lib/ruby-prof/printers/abstract_printer.rb +73 -50
- data/lib/ruby-prof/printers/call_info_printer.rb +13 -3
- data/lib/ruby-prof/printers/call_stack_printer.rb +62 -145
- data/lib/ruby-prof/printers/call_tree_printer.rb +20 -12
- data/lib/ruby-prof/printers/dot_printer.rb +5 -5
- data/lib/ruby-prof/printers/flat_printer.rb +6 -24
- data/lib/ruby-prof/printers/graph_html_printer.rb +6 -192
- data/lib/ruby-prof/printers/graph_printer.rb +13 -15
- data/lib/ruby-prof/printers/multi_printer.rb +66 -23
- data/lib/ruby-prof/profile.rb +10 -3
- data/lib/ruby-prof/rack.rb +0 -3
- data/lib/ruby-prof/thread.rb +12 -12
- data/lib/ruby-prof/version.rb +1 -1
- data/ruby-prof.gemspec +2 -2
- data/test/abstract_printer_test.rb +0 -27
- data/test/alias_test.rb +129 -0
- data/test/basic_test.rb +41 -40
- data/test/call_info_visitor_test.rb +3 -3
- data/test/dynamic_method_test.rb +0 -2
- data/test/fiber_test.rb +11 -17
- data/test/gc_test.rb +96 -0
- data/test/line_number_test.rb +120 -39
- data/test/marshal_test.rb +119 -0
- data/test/measure_allocations.rb +30 -0
- data/test/measure_allocations_test.rb +371 -12
- data/test/measure_allocations_trace_test.rb +385 -0
- data/test/measure_memory_trace_test.rb +756 -0
- data/test/measure_process_time_test.rb +821 -33
- data/test/measure_times.rb +54 -0
- data/test/measure_wall_time_test.rb +349 -145
- data/test/multi_printer_test.rb +1 -34
- data/test/parser_timings.rb +24 -0
- data/test/pause_resume_test.rb +5 -5
- data/test/prime.rb +2 -0
- data/test/printer_call_stack_test.rb +28 -0
- data/test/printer_call_tree_test.rb +31 -0
- data/test/printer_flat_test.rb +68 -0
- data/test/printer_graph_html_test.rb +60 -0
- data/test/printer_graph_test.rb +41 -0
- data/test/printers_test.rb +32 -166
- data/test/printing_recursive_graph_test.rb +26 -72
- data/test/recursive_test.rb +72 -77
- data/test/stack_printer_test.rb +2 -15
- data/test/start_stop_test.rb +22 -25
- data/test/test_helper.rb +5 -248
- data/test/thread_test.rb +11 -54
- data/test/unique_call_path_test.rb +16 -28
- data/test/yarv_test.rb +1 -0
- metadata +28 -36
- data/examples/flat.txt +0 -50
- data/examples/graph.dot +0 -84
- data/examples/graph.html +0 -823
- data/examples/graph.txt +0 -139
- data/examples/multi.flat.txt +0 -23
- data/examples/multi.graph.html +0 -760
- data/examples/multi.grind.dat +0 -114
- data/examples/multi.stack.html +0 -547
- data/examples/stack.html +0 -547
- data/ext/ruby_prof/rp_measure.c +0 -40
- data/ext/ruby_prof/rp_measure.h +0 -45
- data/ext/ruby_prof/rp_measure_cpu_time.c +0 -136
- data/ext/ruby_prof/rp_measure_gc_runs.c +0 -73
- data/ext/ruby_prof/rp_measure_gc_time.c +0 -60
- data/lib/ruby-prof/aggregate_call_info.rb +0 -76
- data/lib/ruby-prof/assets/call_stack_printer.css.html +0 -117
- data/lib/ruby-prof/assets/call_stack_printer.js.html +0 -385
- data/lib/ruby-prof/printers/flat_printer_with_line_numbers.rb +0 -83
- data/lib/ruby-prof/profile/exclude_common_methods.rb +0 -207
- data/lib/ruby-prof/profile/legacy_method_elimination.rb +0 -50
- data/test/aggregate_test.rb +0 -136
- data/test/block_test.rb +0 -74
- data/test/call_info_test.rb +0 -78
- data/test/issue137_test.rb +0 -63
- data/test/measure_cpu_time_test.rb +0 -212
- data/test/measure_gc_runs_test.rb +0 -32
- data/test/measure_gc_time_test.rb +0 -36
- data/test/measure_memory_test.rb +0 -33
- data/test/method_elimination_test.rb +0 -84
- data/test/module_test.rb +0 -45
- data/test/stack_test.rb +0 -138
data/test/call_info_test.rb
DELETED
@@ -1,78 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
# encoding: UTF-8
|
3
|
-
|
4
|
-
require File.expand_path('../test_helper', __FILE__)
|
5
|
-
|
6
|
-
class CallInfoTest < TestCase
|
7
|
-
def setup
|
8
|
-
# Need to use wall time for this test due to the sleep calls
|
9
|
-
RubyProf::measure_mode = RubyProf::WALL_TIME
|
10
|
-
end
|
11
|
-
|
12
|
-
# def test_clone
|
13
|
-
# result = RubyProf.profile do
|
14
|
-
# RubyProf::C1.hello
|
15
|
-
# end
|
16
|
-
#
|
17
|
-
# method = result.threads.first.top_methods.first
|
18
|
-
# call_info = method.call_infos.first
|
19
|
-
# call_info_clone = call_info.clone
|
20
|
-
#
|
21
|
-
## assert_equal(call_info.target, call_info_clone.target)
|
22
|
-
# assert_equal(call_info.total_time, call_info_clone.total_time)
|
23
|
-
# end
|
24
|
-
|
25
|
-
def test_merge
|
26
|
-
result1 = RubyProf.profile do
|
27
|
-
RubyProf::C1.hello
|
28
|
-
end
|
29
|
-
|
30
|
-
methods = result1.threads.first.methods.sort.reverse
|
31
|
-
assert_equal(3, methods.length)
|
32
|
-
|
33
|
-
assert_equal('CallInfoTest#test_merge', methods[0].full_name)
|
34
|
-
assert_in_delta(0.1, methods[0].total_time, 0.01)
|
35
|
-
assert_in_delta(0, methods[0].wait_time, 0.01)
|
36
|
-
assert_in_delta(0, methods[0].self_time, 0.01)
|
37
|
-
assert_equal(1, methods[0].called)
|
38
|
-
|
39
|
-
assert_equal('<Class::RubyProf::C1>#hello', methods[1].full_name)
|
40
|
-
assert_in_delta(0.1, methods[1].total_time, 0.01)
|
41
|
-
assert_in_delta(0, methods[1].wait_time, 0.01)
|
42
|
-
assert_in_delta(0, methods[1].self_time, 0.01)
|
43
|
-
assert_equal(1, methods[1].called)
|
44
|
-
|
45
|
-
assert_equal('Kernel#sleep', methods[2].full_name)
|
46
|
-
assert_in_delta(0.1, methods[2].total_time, 0.01)
|
47
|
-
assert_in_delta(0, methods[2].wait_time, 0.01)
|
48
|
-
assert_in_delta(0.1, methods[2].self_time, 0.01)
|
49
|
-
assert_equal(1, methods[2].called)
|
50
|
-
|
51
|
-
RubyProf.profile do
|
52
|
-
RubyProf::C1.hello
|
53
|
-
end
|
54
|
-
|
55
|
-
# Merge the trees
|
56
|
-
methods = result1.threads.first.methods.sort.reverse
|
57
|
-
assert_equal(3, methods.length)
|
58
|
-
|
59
|
-
assert_equal('CallInfoTest#test_merge', methods[0].full_name)
|
60
|
-
assert_in_delta(0.1, methods[0].total_time, 0.01)
|
61
|
-
assert_in_delta(0, methods[0].wait_time, 0.01)
|
62
|
-
assert_in_delta(0, methods[0].self_time, 0.01)
|
63
|
-
assert_equal(1, methods[0].called)
|
64
|
-
|
65
|
-
assert_equal('<Class::RubyProf::C1>#hello', methods[1].full_name)
|
66
|
-
assert_in_delta(0.1, methods[1].total_time, 0.01)
|
67
|
-
assert_in_delta(0, methods[1].wait_time, 0.01)
|
68
|
-
assert_in_delta(0, methods[1].self_time, 0.01)
|
69
|
-
assert_equal(1, methods[1].called)
|
70
|
-
|
71
|
-
assert_equal('Kernel#sleep', methods[2].full_name)
|
72
|
-
assert_in_delta(0.1, methods[2].total_time, 0.01)
|
73
|
-
assert_in_delta(0, methods[2].wait_time, 0.01)
|
74
|
-
assert_in_delta(0.1, methods[2].self_time, 0.01)
|
75
|
-
assert_equal(1, methods[2].called)
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
data/test/issue137_test.rb
DELETED
@@ -1,63 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
# encoding: UTF-8
|
3
|
-
|
4
|
-
require File.expand_path('../test_helper', __FILE__)
|
5
|
-
|
6
|
-
# issue 137 is about correctly attributing time of recursive children
|
7
|
-
|
8
|
-
class RecursiveChildrenTest < TestCase
|
9
|
-
class SlowClass
|
10
|
-
def time_sink
|
11
|
-
1234567890 ** 100 == 0
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
class SlowSearcher
|
16
|
-
def do_find(slow_objects)
|
17
|
-
slow_objects.find(&:time_sink)
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
class MainClass
|
22
|
-
def self.main_method
|
23
|
-
slow_objects = [SlowClass.new] * 100_000
|
24
|
-
slow_searcher = SlowSearcher.new
|
25
|
-
slow_searcher.do_find(slow_objects)
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
include PrinterTestHelper
|
30
|
-
|
31
|
-
def setup
|
32
|
-
# Need to use wall time for this test due to the sleep calls
|
33
|
-
RubyProf::measure_mode = RubyProf::WALL_TIME
|
34
|
-
end
|
35
|
-
|
36
|
-
def test_simple
|
37
|
-
result = RubyProf.profile do
|
38
|
-
# make array each recursive
|
39
|
-
[1].each do
|
40
|
-
MainClass.main_method
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
# methods = result.threads.first.methods.sort.reverse
|
45
|
-
|
46
|
-
printer = RubyProf::GraphPrinter.new(result)
|
47
|
-
|
48
|
-
buffer = ''
|
49
|
-
printer.print(StringIO.new(buffer))
|
50
|
-
|
51
|
-
puts buffer if ENV['SHOW_RUBY_PROF_PRINTER_OUTPUT'] == "1"
|
52
|
-
|
53
|
-
parsed_output = MetricsArray.parse(buffer)
|
54
|
-
|
55
|
-
assert( enum_find = parsed_output.metrics_for("Enumerable#find") )
|
56
|
-
assert( array_each = enum_find.child("Array#each") )
|
57
|
-
|
58
|
-
assert_operator enum_find.metrics.total, :>=, array_each.total
|
59
|
-
assert_operator enum_find.metrics.total, :>, 0
|
60
|
-
assert_in_delta enum_find.metrics.total, array_each.total, 0.02
|
61
|
-
end
|
62
|
-
|
63
|
-
end
|
@@ -1,212 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
# encoding: UTF-8
|
3
|
-
|
4
|
-
require File.expand_path('../test_helper', __FILE__)
|
5
|
-
|
6
|
-
class MeasureCpuTimeTest < TestCase
|
7
|
-
def setup
|
8
|
-
RubyProf::measure_mode = RubyProf::CPU_TIME
|
9
|
-
end
|
10
|
-
|
11
|
-
def teardown
|
12
|
-
RubyProf::measure_mode = RubyProf::WALL_TIME
|
13
|
-
end
|
14
|
-
|
15
|
-
def test_mode
|
16
|
-
assert_equal(RubyProf::CPU_TIME, RubyProf::measure_mode)
|
17
|
-
end
|
18
|
-
|
19
|
-
def test_cpu_time_enabled_defined
|
20
|
-
assert(defined?(RubyProf::CPU_TIME_ENABLED))
|
21
|
-
end
|
22
|
-
|
23
|
-
def test_class_methods
|
24
|
-
result = RubyProf.profile do
|
25
|
-
RubyProf::C7.busy_wait
|
26
|
-
end
|
27
|
-
|
28
|
-
# Length should be greater 2:
|
29
|
-
# MeasureCpuTimeTest#test_class_methods
|
30
|
-
# <Class::RubyProf::C1>#busy_wait
|
31
|
-
# ....
|
32
|
-
|
33
|
-
methods = result.threads.first.methods.sort.reverse[0..1]
|
34
|
-
assert_equal(2, methods.length)
|
35
|
-
|
36
|
-
# Check the names
|
37
|
-
assert_equal('MeasureCpuTimeTest#test_class_methods', methods[0].full_name)
|
38
|
-
assert_equal('<Class::RubyProf::C7>#busy_wait', methods[1].full_name)
|
39
|
-
|
40
|
-
# Check times
|
41
|
-
assert_in_delta(0.1, methods[0].total_time, 0.05)
|
42
|
-
assert_in_delta(0, methods[0].wait_time, 0.05)
|
43
|
-
assert_in_delta(0, methods[0].self_time, 0.05)
|
44
|
-
|
45
|
-
assert_in_delta(0.1, methods[1].total_time, 0.05)
|
46
|
-
assert_in_delta(0, methods[1].wait_time, 0.05)
|
47
|
-
assert_in_delta(0, methods[1].self_time, 0.05)
|
48
|
-
end
|
49
|
-
|
50
|
-
def test_instance_methods
|
51
|
-
result = RubyProf.profile do
|
52
|
-
RubyProf::C7.new.busy_wait
|
53
|
-
end
|
54
|
-
|
55
|
-
methods = result.threads.first.methods.sort.reverse[0..1]
|
56
|
-
assert_equal(2, methods.length)
|
57
|
-
|
58
|
-
# Methods at this point:
|
59
|
-
# MeasureCpuTimeTest#test_instance_methods
|
60
|
-
# C7#busy_wait
|
61
|
-
# ...
|
62
|
-
|
63
|
-
names = methods.map(&:full_name)
|
64
|
-
assert_equal('MeasureCpuTimeTest#test_instance_methods', names[0])
|
65
|
-
assert_equal('RubyProf::C7#busy_wait', names[1])
|
66
|
-
|
67
|
-
|
68
|
-
# Check times
|
69
|
-
assert_in_delta(0.2, methods[0].total_time, 0.03)
|
70
|
-
assert_in_delta(0, methods[0].wait_time, 0.03)
|
71
|
-
assert_in_delta(0, methods[0].self_time, 0.03)
|
72
|
-
|
73
|
-
assert_in_delta(0.2, methods[1].total_time, 0.03)
|
74
|
-
assert_in_delta(0, methods[1].wait_time, 0.03)
|
75
|
-
assert_in_delta(0, methods[1].self_time, 0.2)
|
76
|
-
end
|
77
|
-
|
78
|
-
def test_module_methods
|
79
|
-
result = RubyProf.profile do
|
80
|
-
RubyProf::C8.busy_wait
|
81
|
-
end
|
82
|
-
|
83
|
-
# Methods:
|
84
|
-
# MeasureCpuTimeTest#test_module_methods
|
85
|
-
# M1#busy_wait
|
86
|
-
# ...
|
87
|
-
|
88
|
-
methods = result.threads.first.methods.sort.reverse[0..1]
|
89
|
-
assert_equal(2, methods.length)
|
90
|
-
|
91
|
-
assert_equal('MeasureCpuTimeTest#test_module_methods', methods[0].full_name)
|
92
|
-
assert_equal('RubyProf::M7#busy_wait', methods[1].full_name)
|
93
|
-
|
94
|
-
# Check times
|
95
|
-
assert_in_delta(0.3, methods[0].total_time, 0.1)
|
96
|
-
assert_in_delta(0, methods[0].wait_time, 0.02)
|
97
|
-
assert_in_delta(0, methods[0].self_time, 0.02)
|
98
|
-
|
99
|
-
assert_in_delta(0.3, methods[1].total_time, 0.1)
|
100
|
-
assert_in_delta(0, methods[1].wait_time, 0.02)
|
101
|
-
assert_in_delta(0, methods[1].self_time, 0.1)
|
102
|
-
end
|
103
|
-
|
104
|
-
def test_module_instance_methods
|
105
|
-
result = RubyProf.profile do
|
106
|
-
RubyProf::C8.new.busy_wait
|
107
|
-
end
|
108
|
-
|
109
|
-
# Methods:
|
110
|
-
# MeasureCpuTimeTest#test_module_instance_methods
|
111
|
-
# M7#busy_wait
|
112
|
-
# ...
|
113
|
-
|
114
|
-
methods = result.threads.first.methods.sort.reverse[0..1]
|
115
|
-
assert_equal(2, methods.length)
|
116
|
-
names = methods.map(&:full_name)
|
117
|
-
assert_equal('MeasureCpuTimeTest#test_module_instance_methods', names[0])
|
118
|
-
assert_equal('RubyProf::M7#busy_wait', names[1])
|
119
|
-
|
120
|
-
# Check times
|
121
|
-
assert_in_delta(0.3, methods[0].total_time, 0.1)
|
122
|
-
assert_in_delta(0, methods[0].wait_time, 0.1)
|
123
|
-
assert_in_delta(0, methods[0].self_time, 0.1)
|
124
|
-
|
125
|
-
assert_in_delta(0.3, methods[1].total_time, 0.1)
|
126
|
-
assert_in_delta(0, methods[1].wait_time, 0.01)
|
127
|
-
assert_in_delta(0, methods[1].self_time, 0.1)
|
128
|
-
end
|
129
|
-
|
130
|
-
def test_singleton
|
131
|
-
c3 = RubyProf::C3.new
|
132
|
-
|
133
|
-
class << c3
|
134
|
-
def busy_wait
|
135
|
-
end
|
136
|
-
end
|
137
|
-
|
138
|
-
result = RubyProf.profile do
|
139
|
-
c3.busy_wait
|
140
|
-
end
|
141
|
-
|
142
|
-
methods = result.threads.first.methods.sort.reverse
|
143
|
-
assert_equal(2, methods.length)
|
144
|
-
|
145
|
-
assert_equal('MeasureCpuTimeTest#test_singleton', methods[0].full_name)
|
146
|
-
assert_equal('<Object::RubyProf::C3>#busy_wait', methods[1].full_name)
|
147
|
-
|
148
|
-
assert_in_delta(0, methods[0].total_time, 0.01)
|
149
|
-
assert_in_delta(0, methods[0].wait_time, 0.01)
|
150
|
-
assert_in_delta(0, methods[0].self_time, 0.01)
|
151
|
-
|
152
|
-
assert_in_delta(0, methods[1].total_time, 0.01)
|
153
|
-
assert_in_delta(0, methods[1].wait_time, 0.01)
|
154
|
-
assert_in_delta(0, methods[1].self_time, 0.01)
|
155
|
-
end
|
156
|
-
|
157
|
-
|
158
|
-
def test_sleeping_does_accumulate_wall_time
|
159
|
-
RubyProf::measure_mode = RubyProf::WALL_TIME
|
160
|
-
result = RubyProf.profile do
|
161
|
-
sleep 0.1
|
162
|
-
end
|
163
|
-
methods = result.threads.first.methods.sort.reverse
|
164
|
-
assert_equal(["MeasureCpuTimeTest#test_sleeping_does_accumulate_wall_time", "Kernel#sleep"], methods.map(&:full_name))
|
165
|
-
assert_in_delta(0.1, methods[1].total_time, 0.01)
|
166
|
-
assert_equal(0, methods[1].wait_time)
|
167
|
-
assert_in_delta(0.1, methods[1].self_time, 0.01)
|
168
|
-
end
|
169
|
-
|
170
|
-
def test_sleeping_does_not_accumulate_significant_cpu_time
|
171
|
-
result = RubyProf.profile do
|
172
|
-
sleep 0.1
|
173
|
-
end
|
174
|
-
methods = result.threads.first.methods.sort.reverse
|
175
|
-
assert_equal(["MeasureCpuTimeTest#test_sleeping_does_not_accumulate_significant_cpu_time", "Kernel#sleep"], methods.map(&:full_name))
|
176
|
-
assert_in_delta(0, methods[1].total_time, 0.01)
|
177
|
-
assert_equal(0, methods[1].wait_time)
|
178
|
-
assert_in_delta(0, methods[1].self_time, 0.01)
|
179
|
-
end
|
180
|
-
|
181
|
-
def test_waiting_for_threads_does_not_accumulate_cpu_time
|
182
|
-
background_thread = nil
|
183
|
-
result = RubyProf.profile do
|
184
|
-
background_thread = Thread.new{ sleep 0.1 }
|
185
|
-
background_thread.join
|
186
|
-
end
|
187
|
-
# check number of threads
|
188
|
-
assert_equal(2, result.threads.length)
|
189
|
-
fg, bg = result.threads
|
190
|
-
assert(fg.methods.map(&:full_name).include?("Thread#join"))
|
191
|
-
assert(bg.methods.map(&:full_name).include?("Kernel#sleep"))
|
192
|
-
assert_in_delta(0, fg.total_time, 0.01)
|
193
|
-
assert_in_delta(0, bg.total_time, 0.01)
|
194
|
-
end
|
195
|
-
|
196
|
-
def test_waiting_for_threads_does_accumulate_wall_time
|
197
|
-
RubyProf::measure_mode = RubyProf::WALL_TIME
|
198
|
-
background_thread = nil
|
199
|
-
result = RubyProf.profile do
|
200
|
-
background_thread = Thread.new{ sleep 0.1 }
|
201
|
-
background_thread.join
|
202
|
-
end
|
203
|
-
# check number of threads
|
204
|
-
assert_equal(2, result.threads.length)
|
205
|
-
fg, bg = result.threads
|
206
|
-
assert(fg.methods.map(&:full_name).include?("Thread#join"))
|
207
|
-
assert(bg.methods.map(&:full_name).include?("Kernel#sleep"))
|
208
|
-
assert_in_delta(0.1, fg.total_time, 0.01)
|
209
|
-
assert_in_delta(0.1, fg.wait_time, 0.01)
|
210
|
-
assert_in_delta(0.1, bg.total_time, 0.01)
|
211
|
-
end
|
212
|
-
end
|
@@ -1,32 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
# encoding: UTF-8
|
3
|
-
|
4
|
-
require File.expand_path('../test_helper', __FILE__)
|
5
|
-
|
6
|
-
class MeasureGCRunsTest < TestCase
|
7
|
-
include MemoryTestHelper
|
8
|
-
|
9
|
-
def test_gc_runs_mode
|
10
|
-
RubyProf::measure_mode = RubyProf::GC_RUNS
|
11
|
-
assert_equal(RubyProf::GC_RUNS, RubyProf::measure_mode)
|
12
|
-
end
|
13
|
-
|
14
|
-
def test_gc_runs_enabled_defined
|
15
|
-
assert(defined?(RubyProf::GC_RUNS_ENABLED))
|
16
|
-
end
|
17
|
-
|
18
|
-
if RubyProf::GC_RUNS_ENABLED
|
19
|
-
def test_gc_runs
|
20
|
-
t = RubyProf.measure_gc_runs
|
21
|
-
assert_kind_of Integer, t
|
22
|
-
|
23
|
-
GC.enable_stats if GC.respond_to?(:enable_stats)
|
24
|
-
GC.start
|
25
|
-
|
26
|
-
u = RubyProf.measure_gc_runs
|
27
|
-
assert u > t, [t, u].inspect
|
28
|
-
RubyProf::measure_mode = RubyProf::GC_RUNS
|
29
|
-
memory_test_helper
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
@@ -1,36 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
# encoding: UTF-8
|
3
|
-
|
4
|
-
require File.expand_path('../test_helper', __FILE__)
|
5
|
-
|
6
|
-
class MeasureGCTimeTest < TestCase
|
7
|
-
include MemoryTestHelper
|
8
|
-
|
9
|
-
def test_gc_time_mode
|
10
|
-
RubyProf::measure_mode = RubyProf::GC_TIME
|
11
|
-
assert_equal(RubyProf::GC_TIME, RubyProf::measure_mode)
|
12
|
-
end
|
13
|
-
|
14
|
-
def test_gc_time_enabled_defined
|
15
|
-
assert(defined?(RubyProf::GC_TIME_ENABLED))
|
16
|
-
end
|
17
|
-
|
18
|
-
if RubyProf::GC_TIME_ENABLED
|
19
|
-
def test_gc_time
|
20
|
-
RubyProf::measure_mode = RubyProf::GC_TIME
|
21
|
-
RubyProf.enable_gc_stats_if_needed
|
22
|
-
|
23
|
-
t = RubyProf.measure_gc_time
|
24
|
-
assert_kind_of Float, t
|
25
|
-
|
26
|
-
GC.start
|
27
|
-
|
28
|
-
u = RubyProf.measure_gc_time
|
29
|
-
assert u > t, [t, u].inspect
|
30
|
-
|
31
|
-
memory_test_helper
|
32
|
-
ensure
|
33
|
-
RubyProf.disable_gc_stats_if_needed
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
data/test/measure_memory_test.rb
DELETED
@@ -1,33 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
# encoding: UTF-8
|
3
|
-
|
4
|
-
require File.expand_path('../test_helper', __FILE__)
|
5
|
-
|
6
|
-
class MeasureMemoryTest < TestCase
|
7
|
-
include MemoryTestHelper
|
8
|
-
|
9
|
-
def test_memory_mode
|
10
|
-
RubyProf::measure_mode = RubyProf::MEMORY
|
11
|
-
assert_equal(RubyProf::MEMORY, RubyProf::measure_mode)
|
12
|
-
end
|
13
|
-
|
14
|
-
def test_memory_enabled_defined
|
15
|
-
assert(defined?(RubyProf::MEMORY_ENABLED))
|
16
|
-
end
|
17
|
-
|
18
|
-
if RubyProf::MEMORY_ENABLED
|
19
|
-
def test_memory
|
20
|
-
RubyProf::measure_mode = RubyProf::MEMORY
|
21
|
-
RubyProf.enable_gc_stats_if_needed
|
22
|
-
t = RubyProf.measure_memory
|
23
|
-
assert_kind_of Float, t
|
24
|
-
u = RubyProf.measure_memory
|
25
|
-
assert_operator u, :>, t
|
26
|
-
total = memory_test_helper
|
27
|
-
assert(total > 0, 'Should measure more than zero kilobytes of memory usage')
|
28
|
-
refute_equal(0, total % 1, 'Should not truncate fractional kilobyte measurements')
|
29
|
-
ensure
|
30
|
-
RubyProf.disable_gc_stats_if_needed
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|