ruby-prof 0.10.8 → 0.11.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +38 -18
- data/LICENSE +4 -3
- data/README.rdoc +30 -66
- data/Rakefile +47 -54
- data/bin/ruby-prof +24 -4
- data/ext/ruby_prof/extconf.rb +9 -16
- data/ext/ruby_prof/rp_call_info.c +369 -0
- data/ext/ruby_prof/rp_call_info.h +46 -0
- data/ext/ruby_prof/rp_measure.c +48 -0
- data/ext/ruby_prof/rp_measure.h +45 -0
- data/ext/ruby_prof/rp_measure_allocations.c +86 -0
- data/ext/ruby_prof/rp_measure_cpu_time.c +112 -0
- data/ext/ruby_prof/rp_measure_gc_runs.c +87 -0
- data/ext/ruby_prof/rp_measure_gc_time.c +73 -0
- data/ext/ruby_prof/rp_measure_memory.c +81 -0
- data/ext/ruby_prof/rp_measure_process_time.c +71 -0
- data/ext/ruby_prof/rp_measure_wall_time.c +42 -0
- data/ext/ruby_prof/rp_method.c +363 -0
- data/ext/ruby_prof/rp_method.h +55 -0
- data/ext/ruby_prof/rp_stack.c +61 -0
- data/ext/ruby_prof/rp_stack.h +40 -0
- data/ext/ruby_prof/rp_thread.c +113 -0
- data/ext/ruby_prof/rp_thread.h +20 -0
- data/ext/ruby_prof/ruby_prof.c +259 -1398
- data/ext/ruby_prof/ruby_prof.h +54 -190
- data/ext/ruby_prof/version.h +6 -3
- data/lib/1.8/ruby_prof.so +0 -0
- data/lib/1.9/ruby_prof.exp +0 -0
- data/lib/1.9/ruby_prof.ilk +0 -0
- data/lib/1.9/ruby_prof.lib +0 -0
- data/lib/1.9/ruby_prof.pdb +0 -0
- data/lib/1.9/ruby_prof.so +0 -0
- data/lib/ruby-prof.rb +14 -11
- data/lib/ruby-prof/abstract_printer.rb +10 -0
- data/lib/ruby-prof/aggregate_call_info.rb +2 -0
- data/lib/ruby-prof/call_info.rb +2 -0
- data/lib/ruby-prof/call_stack_printer.rb +2 -4
- data/lib/ruby-prof/call_tree_printer.rb +1 -0
- data/lib/ruby-prof/compatibility.rb +134 -0
- data/lib/ruby-prof/dot_printer.rb +7 -7
- data/lib/ruby-prof/flat_printer.rb +7 -7
- data/lib/ruby-prof/flat_printer_with_line_numbers.rb +2 -5
- data/lib/ruby-prof/graph_html_printer.rb +4 -2
- data/lib/ruby-prof/graph_printer.rb +4 -3
- data/lib/ruby-prof/method_info.rb +2 -0
- data/lib/ruby-prof/multi_printer.rb +2 -0
- data/lib/ruby-prof/{result.rb → profile.rb} +3 -1
- data/lib/ruby-prof/rack.rb +1 -0
- data/lib/ruby-prof/symbol_to_proc.rb +2 -0
- data/lib/ruby-prof/task.rb +1 -0
- data/lib/ruby-prof/test.rb +2 -0
- data/lib/ruby_prof.exp +0 -0
- data/lib/ruby_prof.ilk +0 -0
- data/lib/ruby_prof.lib +0 -0
- data/lib/ruby_prof.pdb +0 -0
- data/lib/ruby_prof.so +0 -0
- data/lib/unprof.rb +2 -0
- data/test/aggregate_test.rb +8 -8
- data/test/basic_test.rb +3 -251
- data/test/bug_test.rb +6 -0
- data/test/duplicate_names_test.rb +2 -2
- data/test/dynamic_method_test.rb +61 -0
- data/test/enumerable_test.rb +2 -2
- data/test/exceptions_test.rb +4 -3
- data/test/exclude_threads_test.rb +2 -2
- data/test/exec_test.rb +3 -3
- data/test/line_number_test.rb +5 -5
- data/test/measure_allocations_test.rb +25 -0
- data/test/measure_cpu_time_test.rb +212 -0
- data/test/measure_gc_runs_test.rb +29 -0
- data/test/measure_gc_time_test.rb +29 -0
- data/test/measure_memory_test.rb +36 -0
- data/test/measure_process_time_test.rb +205 -0
- data/test/measure_wall_time_test.rb +209 -0
- data/test/method_elimination_test.rb +2 -2
- data/test/module_test.rb +3 -2
- data/test/multi_printer_test.rb +2 -2
- data/test/no_method_class_test.rb +3 -1
- data/test/prime_test.rb +3 -3
- data/test/printers_test.rb +106 -8
- data/test/recursive_test.rb +7 -6
- data/test/singleton_test.rb +2 -2
- data/test/stack_printer_test.rb +2 -3
- data/test/stack_test.rb +2 -2
- data/test/start_stop_test.rb +2 -2
- data/test/test_helper.rb +81 -0
- data/test/test_suite.rb +34 -29
- data/test/thread_test.rb +24 -23
- data/test/unique_call_path_test.rb +2 -2
- metadata +101 -69
- data/ext/ruby_prof/measure_allocations.h +0 -83
- data/ext/ruby_prof/measure_cpu_time.h +0 -152
- data/ext/ruby_prof/measure_gc_runs.h +0 -76
- data/ext/ruby_prof/measure_gc_time.h +0 -57
- data/ext/ruby_prof/measure_memory.h +0 -101
- data/ext/ruby_prof/measure_process_time.h +0 -63
- data/ext/ruby_prof/measure_wall_time.h +0 -53
- data/ext/ruby_prof/mingw/Rakefile +0 -23
- data/ext/ruby_prof/mingw/build.rake +0 -38
- data/rails/environment/profile.rb +0 -24
- data/rails/example/example_test.rb +0 -9
- data/rails/profile_test_helper.rb +0 -21
- data/test/current_failures_windows +0 -8
- data/test/measurement_test.rb +0 -132
- data/test/ruby-prof-bin +0 -20
data/test/bug_test.rb
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# encoding: UTF-8
|
3
|
+
|
4
|
+
require File.expand_path("../test_helper", __FILE__)
|
5
|
+
|
6
|
+
|
7
|
+
class DynamicMethodTest < Test::Unit::TestCase
|
8
|
+
def test_dynamic_method
|
9
|
+
result = RubyProf.profile do
|
10
|
+
1.times {RubyProf::C1.new.hello}
|
11
|
+
end
|
12
|
+
|
13
|
+
# Methods called
|
14
|
+
# Kernel#sleep
|
15
|
+
# <Class::BasicObject>#allocate
|
16
|
+
# BasicObject#initialize
|
17
|
+
# RubyProf::C1#hello
|
18
|
+
# Class#new
|
19
|
+
# Integer#times
|
20
|
+
# DynamicMethodTest#test_dynamic_method
|
21
|
+
|
22
|
+
methods = result.threads.values.first.sort.reverse
|
23
|
+
assert_equal(7, methods.length)
|
24
|
+
|
25
|
+
# Check times
|
26
|
+
assert_equal("DynamicMethodTest#test_dynamic_method", methods[0].full_name)
|
27
|
+
assert_in_delta(0.2, methods[0].total_time, 0.02)
|
28
|
+
assert_in_delta(0.0, methods[0].wait_time, 0.02)
|
29
|
+
assert_in_delta(0.0, methods[0].self_time, 0.02)
|
30
|
+
|
31
|
+
assert_equal("Integer#times", methods[1].full_name)
|
32
|
+
assert_in_delta(0.2, methods[1].total_time, 0.02)
|
33
|
+
assert_in_delta(0.0, methods[1].wait_time, 0.02)
|
34
|
+
assert_in_delta(0.0, methods[1].self_time, 0.02)
|
35
|
+
|
36
|
+
assert_equal("RubyProf::C1#hello", methods[2].full_name)
|
37
|
+
assert_in_delta(0.2, methods[2].total_time, 0.02)
|
38
|
+
assert_in_delta(0.0, methods[2].wait_time, 0.02)
|
39
|
+
assert_in_delta(0.0, methods[2].self_time, 0.02)
|
40
|
+
|
41
|
+
assert_equal("Kernel#sleep", methods[3].full_name)
|
42
|
+
assert_in_delta(0.2, methods[3].total_time, 0.01)
|
43
|
+
assert_in_delta(0.0, methods[3].wait_time, 0.01)
|
44
|
+
assert_in_delta(0.2, methods[3].self_time, 0.01)
|
45
|
+
|
46
|
+
assert_equal("Class#new", methods[4].full_name)
|
47
|
+
assert_in_delta(0.0, methods[4].total_time, 0.01)
|
48
|
+
assert_in_delta(0.0, methods[4].wait_time, 0.01)
|
49
|
+
assert_in_delta(0.0, methods[4].self_time, 0.01)
|
50
|
+
|
51
|
+
assert_equal("<Class::#{RubyProf::PARENT}>#allocate", methods[5].full_name)
|
52
|
+
assert_in_delta(0.0, methods[5].total_time, 0.01)
|
53
|
+
assert_in_delta(0.0, methods[5].wait_time, 0.01)
|
54
|
+
assert_in_delta(0.0, methods[5].self_time, 0.01)
|
55
|
+
|
56
|
+
assert_equal("#{RubyProf::PARENT}#initialize", methods[6].full_name)
|
57
|
+
assert_in_delta(0.0, methods[5].total_time, 0.01)
|
58
|
+
assert_in_delta(0.0, methods[5].wait_time, 0.01)
|
59
|
+
assert_in_delta(0.0, methods[5].self_time, 0.01)
|
60
|
+
end
|
61
|
+
end
|
data/test/enumerable_test.rb
CHANGED
data/test/exceptions_test.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
|
2
|
+
# encoding: UTF-8
|
3
|
+
|
4
|
+
require File.expand_path('../test_helper', __FILE__)
|
4
5
|
|
5
6
|
class ExceptionsTest < Test::Unit::TestCase
|
6
7
|
def test_profile
|
@@ -8,7 +9,7 @@ class ExceptionsTest < Test::Unit::TestCase
|
|
8
9
|
RubyProf.profile do
|
9
10
|
raise(RuntimeError, 'Test error')
|
10
11
|
end
|
11
|
-
rescue
|
12
|
+
rescue
|
12
13
|
end
|
13
14
|
assert_not_nil(result)
|
14
15
|
end
|
data/test/exec_test.rb
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
+
# encoding: UTF-8
|
2
3
|
|
3
|
-
require '
|
4
|
-
require 'os'
|
4
|
+
require File.expand_path('../test_helper', __FILE__)
|
5
5
|
|
6
6
|
# -- Test for bug when it loads with no frames
|
7
7
|
|
8
|
-
class
|
8
|
+
class ExecTest < Test::Unit::TestCase
|
9
9
|
def test_being_able_to_run_its_binary
|
10
10
|
Dir.chdir(File.dirname(__FILE__)) do
|
11
11
|
assert system(OS.ruby_bin + " ruby-prof-bin do_nothing.rb")
|
data/test/line_number_test.rb
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
|
4
|
-
require '
|
2
|
+
# encoding: UTF-8
|
3
|
+
|
4
|
+
require File.expand_path('../test_helper', __FILE__)
|
5
5
|
|
6
6
|
class LineNumbers
|
7
7
|
def method1
|
8
|
-
|
8
|
+
3
|
9
9
|
end
|
10
10
|
|
11
11
|
def method2
|
12
|
-
|
12
|
+
3
|
13
13
|
method1
|
14
14
|
end
|
15
15
|
|
@@ -0,0 +1,25 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# encoding: UTF-8
|
3
|
+
|
4
|
+
require File.expand_path('../test_helper', __FILE__)
|
5
|
+
|
6
|
+
class MeasureAllocationsTest < Test::Unit::TestCase
|
7
|
+
def test_allocations_mode
|
8
|
+
RubyProf::measure_mode = RubyProf::ALLOCATIONS
|
9
|
+
assert_equal(RubyProf::ALLOCATIONS, RubyProf::measure_mode)
|
10
|
+
end
|
11
|
+
|
12
|
+
def test_allocations_enabled_defined
|
13
|
+
assert(defined?(RubyProf::ALLOCATIONS_ENABLED))
|
14
|
+
end
|
15
|
+
|
16
|
+
if RubyProf::ALLOCATIONS_ENABLED
|
17
|
+
def test_allocations
|
18
|
+
t = RubyProf.measure_allocations
|
19
|
+
assert_kind_of Integer, t
|
20
|
+
|
21
|
+
u = RubyProf.measure_allocations
|
22
|
+
assert u > t, [t, u].inspect
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,212 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# encoding: UTF-8
|
3
|
+
|
4
|
+
require File.expand_path('../test_helper', __FILE__)
|
5
|
+
|
6
|
+
class MeasureCpuTimeTest < Test::Unit::TestCase
|
7
|
+
def setup
|
8
|
+
# Need to use wall time for this test due to the sleep calls
|
9
|
+
RubyProf::measure_mode = RubyProf::CPU_TIME
|
10
|
+
end
|
11
|
+
|
12
|
+
def test_mode
|
13
|
+
RubyProf::measure_mode = RubyProf::CPU_TIME
|
14
|
+
assert_equal(RubyProf::CPU_TIME, RubyProf::measure_mode)
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_cpu_time_enabled_defined
|
18
|
+
assert(defined?(RubyProf::CPU_TIME_ENABLED))
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_class_methods
|
22
|
+
result = RubyProf.profile do
|
23
|
+
RubyProf::C1.hello
|
24
|
+
end
|
25
|
+
|
26
|
+
printer = RubyProf::FlatPrinter.new(result)
|
27
|
+
printer.print
|
28
|
+
|
29
|
+
# Length should be 3:
|
30
|
+
# MeasureCpuTimeTest#test_class_methods
|
31
|
+
# <Class::RubyProf::C1>#hello
|
32
|
+
# Kernel#sleep
|
33
|
+
|
34
|
+
methods = result.threads.values.first.sort.reverse
|
35
|
+
assert_equal(3, methods.length)
|
36
|
+
|
37
|
+
# Check the names
|
38
|
+
assert_equal('MeasureCpuTimeTest#test_class_methods', methods[0].full_name)
|
39
|
+
assert_equal('<Class::RubyProf::C1>#hello', methods[1].full_name)
|
40
|
+
assert_equal('Kernel#sleep', methods[2].full_name)
|
41
|
+
|
42
|
+
# Check times
|
43
|
+
assert_in_delta(0.1, methods[0].total_time, 0.01)
|
44
|
+
assert_in_delta(0, methods[0].wait_time, 0.01)
|
45
|
+
assert_in_delta(0, methods[0].self_time, 0.01)
|
46
|
+
|
47
|
+
assert_in_delta(0.1, methods[1].total_time, 0.01)
|
48
|
+
assert_in_delta(0, methods[1].wait_time, 0.01)
|
49
|
+
assert_in_delta(0, methods[1].self_time, 0.01)
|
50
|
+
|
51
|
+
assert_in_delta(0.1, methods[2].total_time, 0.01)
|
52
|
+
assert_in_delta(0, methods[2].wait_time, 0.01)
|
53
|
+
assert_in_delta(0.1, methods[2].self_time, 0.01)
|
54
|
+
end
|
55
|
+
|
56
|
+
def test_instance_methods
|
57
|
+
result = RubyProf.profile do
|
58
|
+
RubyProf::C1.new.hello
|
59
|
+
end
|
60
|
+
|
61
|
+
# Methods called
|
62
|
+
# MeasureCpuTimeTest#test_instance_methods
|
63
|
+
# Class.new
|
64
|
+
# Class:Object#allocate
|
65
|
+
# for Object#initialize
|
66
|
+
# C1#hello
|
67
|
+
# Kernel#sleep
|
68
|
+
|
69
|
+
methods = result.threads.values.first.sort.reverse
|
70
|
+
assert_equal(6, methods.length)
|
71
|
+
names = methods.map(&:full_name)
|
72
|
+
assert_equal('MeasureCpuTimeTest#test_instance_methods', names[0])
|
73
|
+
assert_equal('RubyProf::C1#hello', names[1])
|
74
|
+
assert_equal('Kernel#sleep', names[2])
|
75
|
+
assert_equal('Class#new', names[3])
|
76
|
+
# order can differ
|
77
|
+
assert(names.include?("<Class::#{RubyProf::PARENT}>#allocate"))
|
78
|
+
assert(names.include?("#{RubyProf::PARENT}#initialize"))
|
79
|
+
|
80
|
+
# Check times
|
81
|
+
assert_in_delta(0.2, methods[0].total_time, 0.02)
|
82
|
+
assert_in_delta(0, methods[0].wait_time, 0.02)
|
83
|
+
assert_in_delta(0, methods[0].self_time, 0.02)
|
84
|
+
|
85
|
+
assert_in_delta(0.2, methods[1].total_time, 0.02)
|
86
|
+
assert_in_delta(0, methods[1].wait_time, 0.02)
|
87
|
+
assert_in_delta(0, methods[1].self_time, 0.02)
|
88
|
+
|
89
|
+
assert_in_delta(0.2, methods[2].total_time, 0.02)
|
90
|
+
assert_in_delta(0, methods[2].wait_time, 0.02)
|
91
|
+
assert_in_delta(0.2, methods[2].self_time, 0.02)
|
92
|
+
|
93
|
+
assert_in_delta(0, methods[3].total_time, 0.01)
|
94
|
+
assert_in_delta(0, methods[3].wait_time, 0.01)
|
95
|
+
assert_in_delta(0, methods[3].self_time, 0.01)
|
96
|
+
|
97
|
+
assert_in_delta(0, methods[4].total_time, 0.01)
|
98
|
+
assert_in_delta(0, methods[4].wait_time, 0.01)
|
99
|
+
assert_in_delta(0, methods[4].self_time, 0.01)
|
100
|
+
|
101
|
+
assert_in_delta(0, methods[5].total_time, 0.01)
|
102
|
+
assert_in_delta(0, methods[5].wait_time, 0.01)
|
103
|
+
assert_in_delta(0, methods[5].self_time, 0.01)
|
104
|
+
end
|
105
|
+
|
106
|
+
def test_module_methods
|
107
|
+
result = RubyProf.profile do
|
108
|
+
RubyProf::C2.hello
|
109
|
+
end
|
110
|
+
|
111
|
+
# Methods:
|
112
|
+
# MeasureCpuTimeTest#test_module_methods
|
113
|
+
# M1#hello
|
114
|
+
# Kernel#sleep
|
115
|
+
|
116
|
+
methods = result.threads.values.first.sort.reverse
|
117
|
+
assert_equal(3, methods.length)
|
118
|
+
|
119
|
+
assert_equal('MeasureCpuTimeTest#test_module_methods', methods[0].full_name)
|
120
|
+
assert_equal('RubyProf::M1#hello', methods[1].full_name)
|
121
|
+
assert_equal('Kernel#sleep', methods[2].full_name)
|
122
|
+
|
123
|
+
# Check times
|
124
|
+
assert_in_delta(0.3, methods[0].total_time, 0.1)
|
125
|
+
assert_in_delta(0, methods[0].wait_time, 0.02)
|
126
|
+
assert_in_delta(0, methods[0].self_time, 0.02)
|
127
|
+
|
128
|
+
assert_in_delta(0.3, methods[1].total_time, 0.1)
|
129
|
+
assert_in_delta(0, methods[1].wait_time, 0.02)
|
130
|
+
assert_in_delta(0, methods[1].self_time, 0.02)
|
131
|
+
|
132
|
+
assert_in_delta(0.3, methods[2].total_time, 0.1)
|
133
|
+
assert_in_delta(0, methods[2].wait_time, 0.02)
|
134
|
+
assert_in_delta(0.3, methods[2].self_time, 0.1)
|
135
|
+
end
|
136
|
+
|
137
|
+
def test_module_instance_methods
|
138
|
+
result = RubyProf.profile do
|
139
|
+
RubyProf::C2.new.hello
|
140
|
+
end
|
141
|
+
|
142
|
+
# Methods:
|
143
|
+
# MeasureCpuTimeTest#test_module_instance_methods
|
144
|
+
# Class#new
|
145
|
+
# <Class::Object>#allocate
|
146
|
+
# Object#initialize
|
147
|
+
# M1#hello
|
148
|
+
# Kernel#sleep
|
149
|
+
|
150
|
+
methods = result.threads.values.first.sort.reverse
|
151
|
+
assert_equal(6, methods.length)
|
152
|
+
names = methods.map(&:full_name)
|
153
|
+
assert_equal('MeasureCpuTimeTest#test_module_instance_methods', names[0])
|
154
|
+
assert_equal('RubyProf::M1#hello', names[1])
|
155
|
+
assert_equal('Kernel#sleep', names[2])
|
156
|
+
assert_equal('Class#new', names[3])
|
157
|
+
assert(names.include?("<Class::#{RubyProf::PARENT}>#allocate"))
|
158
|
+
assert(names.include?("#{RubyProf::PARENT}#initialize"))
|
159
|
+
|
160
|
+
# Check times
|
161
|
+
assert_in_delta(0.3, methods[0].total_time, 0.1)
|
162
|
+
assert_in_delta(0, methods[0].wait_time, 0.1)
|
163
|
+
assert_in_delta(0, methods[0].self_time, 0.1)
|
164
|
+
|
165
|
+
assert_in_delta(0.3, methods[1].total_time, 0.02)
|
166
|
+
assert_in_delta(0, methods[1].wait_time, 0.01)
|
167
|
+
assert_in_delta(0, methods[1].self_time, 0.01)
|
168
|
+
|
169
|
+
assert_in_delta(0.3, methods[2].total_time, 0.02)
|
170
|
+
assert_in_delta(0, methods[2].wait_time, 0.01)
|
171
|
+
assert_in_delta(0.3, methods[2].self_time, 0.02)
|
172
|
+
|
173
|
+
assert_in_delta(0, methods[3].total_time, 0.01)
|
174
|
+
assert_in_delta(0, methods[3].wait_time, 0.01)
|
175
|
+
assert_in_delta(0, methods[3].self_time, 0.01)
|
176
|
+
|
177
|
+
assert_in_delta(0, methods[4].total_time, 0.01)
|
178
|
+
assert_in_delta(0, methods[4].wait_time, 0.01)
|
179
|
+
assert_in_delta(0, methods[4].self_time, 0.01)
|
180
|
+
|
181
|
+
assert_in_delta(0, methods[5].total_time, 0.01)
|
182
|
+
assert_in_delta(0, methods[5].wait_time, 0.01)
|
183
|
+
assert_in_delta(0, methods[5].self_time, 0.01)
|
184
|
+
end
|
185
|
+
|
186
|
+
def test_singleton
|
187
|
+
c3 = RubyProf::C3.new
|
188
|
+
|
189
|
+
class << c3
|
190
|
+
def hello
|
191
|
+
end
|
192
|
+
end
|
193
|
+
|
194
|
+
result = RubyProf.profile do
|
195
|
+
c3.hello
|
196
|
+
end
|
197
|
+
|
198
|
+
methods = result.threads.values.first.sort.reverse
|
199
|
+
assert_equal(2, methods.length)
|
200
|
+
|
201
|
+
assert_equal('MeasureCpuTimeTest#test_singleton', methods[0].full_name)
|
202
|
+
assert_equal('<Object::RubyProf::C3>#hello', methods[1].full_name)
|
203
|
+
|
204
|
+
assert_in_delta(0, methods[0].total_time, 0.01)
|
205
|
+
assert_in_delta(0, methods[0].wait_time, 0.01)
|
206
|
+
assert_in_delta(0, methods[0].self_time, 0.01)
|
207
|
+
|
208
|
+
assert_in_delta(0, methods[1].total_time, 0.01)
|
209
|
+
assert_in_delta(0, methods[1].wait_time, 0.01)
|
210
|
+
assert_in_delta(0, methods[1].self_time, 0.01)
|
211
|
+
end
|
212
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# encoding: UTF-8
|
3
|
+
|
4
|
+
require File.expand_path('../test_helper', __FILE__)
|
5
|
+
|
6
|
+
class MeasuremeGCRunsTest < Test::Unit::TestCase
|
7
|
+
def test_gc_runs_mode
|
8
|
+
RubyProf::measure_mode = RubyProf::GC_RUNS
|
9
|
+
assert_equal(RubyProf::GC_RUNS, RubyProf::measure_mode)
|
10
|
+
end
|
11
|
+
|
12
|
+
def test_gc_runs_enabled_defined
|
13
|
+
assert(defined?(RubyProf::GC_RUNS_ENABLED))
|
14
|
+
end
|
15
|
+
|
16
|
+
if RubyProf::GC_RUNS_ENABLED
|
17
|
+
def test_gc_runs
|
18
|
+
t = RubyProf.measure_gc_runs
|
19
|
+
assert_kind_of Integer, t
|
20
|
+
|
21
|
+
GC.start
|
22
|
+
|
23
|
+
u = RubyProf.measure_gc_runs
|
24
|
+
assert u > t, [t, u].inspect
|
25
|
+
RubyProf::measure_mode = RubyProf::GC_RUNS
|
26
|
+
memory_test_helper
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# encoding: UTF-8
|
3
|
+
|
4
|
+
require File.expand_path('../test_helper', __FILE__)
|
5
|
+
|
6
|
+
class MeasureGCTimeTest < Test::Unit::TestCase
|
7
|
+
def test_gc_time_mode
|
8
|
+
RubyProf::measure_mode = RubyProf::GC_TIME
|
9
|
+
assert_equal(RubyProf::GC_TIME, RubyProf::measure_mode)
|
10
|
+
end
|
11
|
+
|
12
|
+
def test_gc_time_enabled_defined
|
13
|
+
assert(defined?(RubyProf::GC_TIME_ENABLED))
|
14
|
+
end
|
15
|
+
|
16
|
+
if RubyProf::GC_TIME_ENABLED
|
17
|
+
def test_gc_time
|
18
|
+
t = RubyProf.measure_gc_time
|
19
|
+
assert_kind_of Integer, t
|
20
|
+
|
21
|
+
GC.start
|
22
|
+
|
23
|
+
u = RubyProf.measure_gc_time
|
24
|
+
assert u > t, [t, u].inspect
|
25
|
+
RubyProf::measure_mode = RubyProf::GC_TIME
|
26
|
+
memory_test_helper
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|