ruby-prof 0.8.2 → 0.9.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.
- data/CHANGES +23 -13
- data/{README → README.rdoc} +118 -111
- data/Rakefile +14 -26
- data/bin/ruby-prof +16 -4
- data/examples/empty.png +0 -0
- data/examples/graph.dot +106 -0
- data/examples/graph.png +0 -0
- data/examples/minus.png +0 -0
- data/examples/multi.flat.txt +23 -0
- data/examples/multi.graph.html +906 -0
- data/examples/multi.grind.dat +194 -0
- data/examples/multi.stack.html +573 -0
- data/examples/plus.png +0 -0
- data/examples/stack.html +573 -0
- data/ext/ruby_prof/extconf.rb +0 -1
- data/ext/ruby_prof/measure_allocations.h +6 -6
- data/ext/ruby_prof/measure_cpu_time.h +5 -5
- data/ext/ruby_prof/measure_gc_runs.h +1 -1
- data/ext/ruby_prof/measure_gc_time.h +1 -1
- data/ext/ruby_prof/measure_memory.h +4 -4
- data/ext/ruby_prof/measure_process_time.h +1 -1
- data/ext/ruby_prof/measure_wall_time.h +1 -1
- data/ext/ruby_prof/ruby_prof.c +240 -167
- data/ext/ruby_prof/ruby_prof.h +12 -10
- data/ext/ruby_prof/version.h +3 -3
- data/lib/ruby-prof.rb +7 -1
- data/lib/ruby-prof/abstract_printer.rb +5 -5
- data/lib/ruby-prof/aggregate_call_info.rb +9 -3
- data/lib/ruby-prof/call_info.rb +66 -1
- data/lib/ruby-prof/call_stack_printer.rb +751 -0
- data/lib/ruby-prof/call_tree_printer.rb +2 -2
- data/lib/ruby-prof/dot_printer.rb +151 -0
- data/lib/ruby-prof/empty.png +0 -0
- data/lib/ruby-prof/flat_printer.rb +16 -16
- data/lib/ruby-prof/flat_printer_with_line_numbers.rb +13 -13
- data/lib/ruby-prof/graph_html_printer.rb +58 -36
- data/lib/ruby-prof/graph_printer.rb +30 -30
- data/lib/ruby-prof/method_info.rb +24 -4
- data/lib/ruby-prof/minus.png +0 -0
- data/lib/ruby-prof/multi_printer.rb +54 -0
- data/lib/ruby-prof/plus.png +0 -0
- data/lib/ruby-prof/rack.rb +28 -0
- data/lib/ruby-prof/result.rb +70 -0
- data/lib/ruby-prof/symbol_to_proc.rb +1 -1
- data/lib/ruby-prof/task.rb +19 -19
- data/lib/ruby-prof/test.rb +3 -3
- data/lib/ruby_prof.so +0 -0
- data/rails/environment/profile.rb +2 -2
- data/rails/example/example_test.rb +2 -2
- data/rails/profile_test_helper.rb +1 -1
- data/test/aggregate_test.rb +21 -6
- data/test/basic_test.rb +3 -3
- data/test/duplicate_names_test.rb +2 -2
- data/test/enumerable_test.rb +2 -2
- data/test/exceptions_test.rb +2 -2
- data/test/exclude_threads_test.rb +45 -45
- data/test/exec_test.rb +2 -2
- data/test/line_number_test.rb +11 -11
- data/test/measurement_test.rb +4 -3
- data/test/method_elimination_test.rb +74 -0
- data/test/module_test.rb +7 -7
- data/test/multi_printer_test.rb +81 -0
- data/test/no_method_class_test.rb +2 -2
- data/test/prime.rb +7 -10
- data/test/printers_test.rb +57 -47
- data/test/recursive_test.rb +23 -62
- data/test/singleton_test.rb +3 -2
- data/test/stack_printer_test.rb +74 -0
- data/test/stack_test.rb +1 -1
- data/test/start_stop_test.rb +2 -2
- data/test/test_suite.rb +9 -0
- data/test/thread_test.rb +17 -17
- data/test/unique_call_path_test.rb +4 -4
- metadata +29 -8
data/test/module_test.rb
CHANGED
@@ -16,7 +16,7 @@ module Bar
|
|
16
16
|
sleep(0.5)
|
17
17
|
Foo::hello
|
18
18
|
end
|
19
|
-
|
19
|
+
|
20
20
|
def hello
|
21
21
|
sleep(0.5)
|
22
22
|
Bar::hello
|
@@ -32,23 +32,23 @@ class ModuleTest < Test::Unit::TestCase
|
|
32
32
|
end
|
33
33
|
|
34
34
|
methods = result.threads.values.first.sort.reverse
|
35
|
-
|
35
|
+
|
36
36
|
# Length should be 5
|
37
37
|
assert_equal(5, methods.length)
|
38
|
-
|
38
|
+
|
39
39
|
method = methods[0]
|
40
40
|
assert_equal('ModuleTest#test_nested_modules', method.full_name)
|
41
|
-
|
41
|
+
|
42
42
|
method = methods[1]
|
43
43
|
assert_equal('Bar#hello', method.full_name)
|
44
44
|
|
45
45
|
method = methods[2]
|
46
46
|
assert_equal('Kernel#sleep', method.full_name)
|
47
|
-
|
47
|
+
|
48
48
|
method = methods[3]
|
49
49
|
assert_equal('<Module::Bar>#hello', method.full_name)
|
50
|
-
|
50
|
+
|
51
51
|
method = methods[4]
|
52
52
|
assert_equal('<Module::Foo>#hello', method.full_name)
|
53
|
-
end
|
53
|
+
end
|
54
54
|
end
|
@@ -0,0 +1,81 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'test/unit'
|
4
|
+
require 'ruby-prof'
|
5
|
+
require 'tmpdir'
|
6
|
+
|
7
|
+
# Test data
|
8
|
+
# A
|
9
|
+
# / \
|
10
|
+
# B C
|
11
|
+
# \
|
12
|
+
# B
|
13
|
+
|
14
|
+
class MSTPT
|
15
|
+
def a
|
16
|
+
100.times{b}
|
17
|
+
300.times{c}
|
18
|
+
c;c;c
|
19
|
+
end
|
20
|
+
|
21
|
+
def b
|
22
|
+
sleep 0
|
23
|
+
end
|
24
|
+
|
25
|
+
def c
|
26
|
+
5.times{b}
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
class MultiPrinterTest < Test::Unit::TestCase
|
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_all_profiles_can_be_created
|
37
|
+
start_time = Time.now
|
38
|
+
RubyProf.start
|
39
|
+
5.times{MSTPT.new.a}
|
40
|
+
result = RubyProf.stop
|
41
|
+
end_time = Time.now
|
42
|
+
expected_time = end_time - start_time
|
43
|
+
stack = graph = nil
|
44
|
+
assert_nothing_raised { stack, graph = print(result) }
|
45
|
+
re = Regexp.new('
|
46
|
+
\s*<table>
|
47
|
+
\s*<tr>
|
48
|
+
\s*<th>Thread ID</th>
|
49
|
+
\s*<th>Total Time</th>
|
50
|
+
\s*</tr>
|
51
|
+
\s*
|
52
|
+
\s*<tr>
|
53
|
+
\s*<td><a href="#\d+">\d+</a></td>
|
54
|
+
\s*<td>([\.0-9]+)</td>
|
55
|
+
\s*</tr>
|
56
|
+
\s*
|
57
|
+
\s*</table>')
|
58
|
+
assert graph =~ re
|
59
|
+
display_time = $1.to_f
|
60
|
+
difference = (expected_time-display_time).abs
|
61
|
+
assert_in_delta expected_time, display_time, 0.001
|
62
|
+
end
|
63
|
+
|
64
|
+
private
|
65
|
+
def print(result)
|
66
|
+
test = caller.first =~ /in `(.*)'/ ? $1 : "test"
|
67
|
+
path = Dir::tmpdir
|
68
|
+
profile = "ruby_prof_#{test}"
|
69
|
+
printer = RubyProf::MultiPrinter.new(result)
|
70
|
+
printer.print(:path => path, :profile => profile,
|
71
|
+
:threshold => 0, :min_percent => 0, :title => "ruby_prof #{test}")
|
72
|
+
if RUBY_PLATFORM =~ /darwin/ && ENV['SHOW_RUBY_PROF_PRINTER_OUTPUT']=="1"
|
73
|
+
system("open '#{printer.stack_profile}'")
|
74
|
+
end
|
75
|
+
if GC.respond_to?(:dump_file_and_line_info)
|
76
|
+
GC.start
|
77
|
+
GC.dump_file_and_line_info("heap.dump")
|
78
|
+
end
|
79
|
+
[File.open(printer.stack_profile){|f|f.read}, File.open(printer.graph_profile){|f|f.read}]
|
80
|
+
end
|
81
|
+
end
|
@@ -2,7 +2,7 @@
|
|
2
2
|
require 'ruby-prof'
|
3
3
|
|
4
4
|
# Make sure this works with no class or method
|
5
|
-
result = RubyProf.profile do
|
5
|
+
result = RubyProf.profile do
|
6
6
|
sleep 1
|
7
7
|
end
|
8
8
|
|
@@ -10,4 +10,4 @@ methods = result.threads.values.first
|
|
10
10
|
global_method = methods.sort_by {|method| method.full_name}.first
|
11
11
|
if global_method.full_name != 'Global#[No method]'
|
12
12
|
raise(RuntimeError, "Wrong method name. Expected: Global#[No method]. Actual: #{global_method.full_name}")
|
13
|
-
end
|
13
|
+
end
|
data/test/prime.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# A silly little test program that finds prime numbers. It
|
2
2
|
# is intentionally badly designed to show off the use
|
3
3
|
# of ruby-prof.
|
4
|
-
#
|
4
|
+
#
|
5
5
|
# Source from http://people.cs.uchicago.edu/~bomb154/154/maclabs/profilers-lab/
|
6
6
|
|
7
7
|
def make_random_array(length, maxnum)
|
@@ -9,10 +9,10 @@ def make_random_array(length, maxnum)
|
|
9
9
|
result.each_index do |i|
|
10
10
|
result[i] = rand(maxnum)
|
11
11
|
end
|
12
|
-
|
12
|
+
|
13
13
|
result
|
14
14
|
end
|
15
|
-
|
15
|
+
|
16
16
|
def is_prime(x)
|
17
17
|
y = 2
|
18
18
|
y.upto(x-1) do |i|
|
@@ -43,16 +43,13 @@ def find_largest(primes)
|
|
43
43
|
largest
|
44
44
|
end
|
45
45
|
|
46
|
-
def run_primes
|
47
|
-
length = 10
|
48
|
-
maxnum = 1000
|
49
|
-
|
46
|
+
def run_primes(length=10, maxnum=1000)
|
50
47
|
# Create random numbers
|
51
48
|
random_array = make_random_array(length, maxnum)
|
52
|
-
|
49
|
+
|
53
50
|
# Find the primes
|
54
51
|
primes = find_primes(random_array)
|
55
|
-
|
52
|
+
|
56
53
|
# Find the largest primes
|
57
54
|
# largest = find_largest(primes)
|
58
|
-
end
|
55
|
+
end
|
data/test/printers_test.rb
CHANGED
@@ -1,41 +1,52 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
require 'test/unit'
|
3
3
|
require 'ruby-prof'
|
4
|
-
require
|
4
|
+
require 'prime'
|
5
5
|
|
6
6
|
# -- Tests ----
|
7
7
|
class PrintersTest < Test::Unit::TestCase
|
8
|
-
|
8
|
+
|
9
9
|
def go
|
10
|
-
run_primes
|
10
|
+
run_primes(10000)
|
11
11
|
end
|
12
|
-
|
12
|
+
|
13
13
|
def setup
|
14
14
|
RubyProf::measure_mode = RubyProf::WALL_TIME # WALL_TIME so we can use sleep in our test
|
15
15
|
@result = RubyProf.profile do
|
16
|
-
run_primes
|
16
|
+
run_primes(10000)
|
17
17
|
go
|
18
18
|
end
|
19
|
-
|
19
|
+
|
20
20
|
end
|
21
|
-
|
21
|
+
|
22
22
|
def test_printers
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
23
|
+
assert_nothing_raised do
|
24
|
+
output = ENV['SHOW_RUBY_PROF_PRINTER_OUTPUT'] == "1" ? STDOUT : StringIO.new('')
|
25
|
+
|
26
|
+
printer = RubyProf::FlatPrinter.new(@result)
|
27
|
+
printer.print(output)
|
28
|
+
|
29
|
+
printer = RubyProf::FlatPrinterWithLineNumbers.new(@result)
|
30
|
+
printer.print(output)
|
31
|
+
|
32
|
+
printer = RubyProf::GraphHtmlPrinter.new(@result)
|
33
|
+
printer.print(output)
|
34
|
+
|
35
|
+
printer = RubyProf::GraphPrinter.new(@result)
|
36
|
+
printer.print(output)
|
37
|
+
|
38
|
+
printer = RubyProf::CallTreePrinter.new(@result)
|
39
|
+
printer.print(output)
|
40
|
+
|
41
|
+
printer = RubyProf::DotPrinter.new(@result)
|
42
|
+
File.open("examples/graph.dot", "w") {|f| printer.print(f)}
|
43
|
+
|
44
|
+
printer = RubyProf::CallStackPrinter.new(@result)
|
45
|
+
File.open("examples/stack.html", "w") {|f| printer.print(f, :application => "primes")}
|
46
|
+
|
47
|
+
printer = RubyProf::MultiPrinter.new(@result)
|
48
|
+
printer.print(:path => "examples", :profile => "multi", :application => "primes")
|
49
|
+
end
|
39
50
|
end
|
40
51
|
|
41
52
|
def test_flat_string
|
@@ -45,32 +56,32 @@ class PrintersTest < Test::Unit::TestCase
|
|
45
56
|
|
46
57
|
def helper_test_flat_string klass
|
47
58
|
output = ''
|
48
|
-
|
59
|
+
|
49
60
|
printer = klass.new(@result)
|
50
61
|
printer.print(output)
|
51
|
-
|
62
|
+
|
52
63
|
assert_match(/Thread ID: -?\d+/i, output)
|
53
64
|
assert_match(/Total: \d+\.\d+/i, output)
|
54
65
|
assert_match(/Object#run_primes/i, output)
|
55
66
|
output
|
56
67
|
end
|
57
|
-
|
68
|
+
|
58
69
|
def test_flat_string_with_numbers
|
59
70
|
output = helper_test_flat_string RubyProf::FlatPrinterWithLineNumbers
|
60
|
-
assert_match(/prime.rb/, output)
|
71
|
+
assert_match(/prime.rb/, output)
|
61
72
|
assert_no_match(/ruby_runtime:0/, output)
|
62
73
|
assert_match(/called from/, output)
|
63
|
-
|
74
|
+
|
64
75
|
# should combine common parents
|
65
76
|
if RUBY_VERSION < '1.9'
|
66
77
|
assert_equal(3, output.scan(/Object#is_prime/).length)
|
67
|
-
|
68
|
-
|
69
|
-
|
78
|
+
else
|
79
|
+
# 1.9
|
80
|
+
assert_equal(2, output.scan(/Object#is_prime/).length)
|
70
81
|
end
|
71
|
-
|
82
|
+
assert_no_match(/\.\/test\/prime.rb/, output) # don't use relative paths
|
72
83
|
end
|
73
|
-
|
84
|
+
|
74
85
|
def test_graph_html_string
|
75
86
|
output = ''
|
76
87
|
printer = RubyProf::GraphHtmlPrinter.new(@result)
|
@@ -80,7 +91,7 @@ class PrintersTest < Test::Unit::TestCase
|
|
80
91
|
assert_match( %r{<th>Total Time</th>}i, output )
|
81
92
|
assert_match( /Object#run_primes/i, output )
|
82
93
|
end
|
83
|
-
|
94
|
+
|
84
95
|
def test_graph_string
|
85
96
|
output = ''
|
86
97
|
printer = RubyProf::GraphPrinter.new(@result)
|
@@ -90,7 +101,7 @@ class PrintersTest < Test::Unit::TestCase
|
|
90
101
|
assert_match( /Total Time: \d+\.\d+/i, output )
|
91
102
|
assert_match( /Object#run_primes/i, output )
|
92
103
|
end
|
93
|
-
|
104
|
+
|
94
105
|
def test_call_tree_string
|
95
106
|
output = ''
|
96
107
|
printer = RubyProf::CallTreePrinter.new(@result)
|
@@ -99,33 +110,32 @@ class PrintersTest < Test::Unit::TestCase
|
|
99
110
|
assert_match(/events: wall_time/i, output)
|
100
111
|
assert_no_match(/d\d\d\d\d\d/, output) # old bug looked [in error] like Object::run_primes(d5833116)
|
101
112
|
end
|
102
|
-
|
113
|
+
|
103
114
|
def do_nothing
|
104
115
|
start = Time.now
|
105
116
|
while(Time.now == start)
|
106
117
|
end
|
107
118
|
end
|
108
|
-
|
119
|
+
|
109
120
|
def test_all_with_small_percentiles
|
110
|
-
|
121
|
+
|
111
122
|
result = RubyProf.profile do
|
112
123
|
sleep 2
|
113
|
-
do_nothing
|
124
|
+
do_nothing
|
114
125
|
end
|
115
|
-
|
126
|
+
|
116
127
|
# RubyProf::CallTreePrinter doesn't "do" a min_percent
|
117
128
|
# RubyProf::FlatPrinter only outputs if self time > percent...
|
118
129
|
# RubyProf::FlatPrinterWithLineNumbers same
|
119
130
|
for klass in [ RubyProf::GraphPrinter, RubyProf::GraphHtmlPrinter]
|
120
|
-
puts klass
|
121
131
|
printer = klass.new(result)
|
122
132
|
out = ''
|
123
133
|
output = printer.print(out, :min_percent => 0.00000001 )
|
124
|
-
assert_match(/do_nothing/, out)
|
134
|
+
assert_match(/do_nothing/, out)
|
125
135
|
end
|
126
|
-
|
127
|
-
end
|
128
|
-
|
129
|
-
|
130
|
-
|
136
|
+
|
137
|
+
end
|
138
|
+
|
139
|
+
|
140
|
+
|
131
141
|
end
|
data/test/recursive_test.rb
CHANGED
@@ -34,13 +34,13 @@ class RecursiveTest < Test::Unit::TestCase
|
|
34
34
|
end
|
35
35
|
|
36
36
|
methods = result.threads.values.first.sort.reverse
|
37
|
-
|
37
|
+
|
38
38
|
if RUBY_VERSION < '1.9'
|
39
|
-
assert_equal(
|
39
|
+
assert_equal(5, methods.length) # includes Fixnum+, Fixnum==...
|
40
40
|
else
|
41
|
-
assert_equal(
|
41
|
+
assert_equal(3, methods.length) # which don't show up in 1.9
|
42
42
|
end
|
43
|
-
|
43
|
+
|
44
44
|
method = methods[0]
|
45
45
|
assert_equal('RecursiveTest#test_simple', method.full_name)
|
46
46
|
assert_equal(1, method.called)
|
@@ -56,13 +56,13 @@ class RecursiveTest < Test::Unit::TestCase
|
|
56
56
|
|
57
57
|
method = methods[1]
|
58
58
|
assert_equal('Object#simple', method.full_name)
|
59
|
-
assert_equal(
|
59
|
+
assert_equal(2, method.called)
|
60
60
|
assert_in_delta(2, method.total_time, 0.02)
|
61
61
|
assert_in_delta(0, method.self_time, 0.02)
|
62
62
|
assert_in_delta(0, method.wait_time, 0.02)
|
63
63
|
assert_in_delta(2, method.children_time, 0.02)
|
64
64
|
|
65
|
-
assert_equal(
|
65
|
+
assert_equal(2, method.call_infos.length)
|
66
66
|
call_info = method.call_infos[0]
|
67
67
|
assert_equal('RecursiveTest#test_simple->Object#simple', call_info.call_sequence)
|
68
68
|
if RUBY_VERSION < '1.9'
|
@@ -70,6 +70,7 @@ class RecursiveTest < Test::Unit::TestCase
|
|
70
70
|
else
|
71
71
|
assert_equal(2, call_info.children.length)
|
72
72
|
end
|
73
|
+
|
73
74
|
method = methods[2]
|
74
75
|
assert_equal('Kernel#sleep', method.full_name)
|
75
76
|
assert_equal(2, method.called)
|
@@ -84,24 +85,11 @@ class RecursiveTest < Test::Unit::TestCase
|
|
84
85
|
assert_equal(0, call_info.children.length)
|
85
86
|
|
86
87
|
call_info = method.call_infos[1]
|
87
|
-
assert_equal('RecursiveTest#test_simple->Object#simple->Object#simple
|
88
|
+
assert_equal('RecursiveTest#test_simple->Object#simple->Object#simple->Kernel#sleep', call_info.call_sequence)
|
88
89
|
assert_equal(0, call_info.children.length)
|
89
90
|
|
90
|
-
method = methods[3]
|
91
|
-
assert_equal('Object#simple(d1)', method.full_name)
|
92
|
-
assert_equal(1, method.called)
|
93
|
-
assert_in_delta(1, method.total_time, 0.01)
|
94
|
-
assert_in_delta(0, method.self_time, 0.01)
|
95
|
-
assert_in_delta(0, method.wait_time, 0.01)
|
96
|
-
assert_in_delta(1, method.children_time, 0.01)
|
97
|
-
|
98
|
-
assert_equal(1, method.call_infos.length)
|
99
|
-
call_info = method.call_infos[0]
|
100
|
-
assert_equal('RecursiveTest#test_simple->Object#simple->Object#simple(d1)', call_info.call_sequence)
|
101
91
|
if RUBY_VERSION < '1.9'
|
102
|
-
|
103
|
-
|
104
|
-
method = methods[4]
|
92
|
+
method = methods[3]
|
105
93
|
assert_equal('Fixnum#-', method.full_name)
|
106
94
|
assert_equal(2, method.called)
|
107
95
|
assert_in_delta(0, method.total_time, 0.01)
|
@@ -115,10 +103,10 @@ class RecursiveTest < Test::Unit::TestCase
|
|
115
103
|
assert_equal(0, call_info.children.length)
|
116
104
|
|
117
105
|
call_info = method.call_infos[1]
|
118
|
-
assert_equal('RecursiveTest#test_simple->Object#simple->Object#simple
|
106
|
+
assert_equal('RecursiveTest#test_simple->Object#simple->Object#simple->Fixnum#-', call_info.call_sequence)
|
119
107
|
assert_equal(0, call_info.children.length)
|
120
108
|
|
121
|
-
method = methods[
|
109
|
+
method = methods[4]
|
122
110
|
assert_equal('Fixnum#==', method.full_name)
|
123
111
|
assert_equal(2, method.called)
|
124
112
|
assert_in_delta(0, method.total_time, 0.01)
|
@@ -132,11 +120,8 @@ class RecursiveTest < Test::Unit::TestCase
|
|
132
120
|
assert_equal(0, call_info.children.length)
|
133
121
|
|
134
122
|
call_info = method.call_infos[1]
|
135
|
-
assert_equal('RecursiveTest#test_simple->Object#simple->Object#simple
|
123
|
+
assert_equal('RecursiveTest#test_simple->Object#simple->Object#simple->Fixnum#==', call_info.call_sequence)
|
136
124
|
assert_equal(0, call_info.children.length)
|
137
|
-
|
138
|
-
else
|
139
|
-
assert_equal(1, call_info.children.length)
|
140
125
|
end
|
141
126
|
end
|
142
127
|
|
@@ -147,9 +132,9 @@ class RecursiveTest < Test::Unit::TestCase
|
|
147
132
|
|
148
133
|
methods = result.threads.values.first.sort.reverse
|
149
134
|
if RUBY_VERSION < '1.9'
|
150
|
-
assert_equal(
|
135
|
+
assert_equal(6, methods.length) # includes Fixnum+ and Fixnum==, which aren't included in 1.9
|
151
136
|
else
|
152
|
-
assert_equal(
|
137
|
+
assert_equal(4, methods.length) # which don't show up in 1.9
|
153
138
|
end
|
154
139
|
method = methods[0]
|
155
140
|
assert_equal('RecursiveTest#test_cycle', method.full_name)
|
@@ -166,26 +151,26 @@ class RecursiveTest < Test::Unit::TestCase
|
|
166
151
|
|
167
152
|
method = methods[1]
|
168
153
|
assert_equal('Object#cycle', method.full_name)
|
169
|
-
assert_equal(
|
154
|
+
assert_equal(2, method.called)
|
170
155
|
assert_in_delta(2, method.total_time, 0.05)
|
171
156
|
assert_in_delta(0, method.self_time, 0.01)
|
172
157
|
assert_in_delta(0, method.wait_time, 0.01)
|
173
158
|
assert_in_delta(2, method.children_time, 0.05)
|
174
159
|
|
175
|
-
assert_equal(
|
160
|
+
assert_equal(2, method.call_infos.length)
|
176
161
|
call_info = method.call_infos[0]
|
177
162
|
assert_equal('RecursiveTest#test_cycle->Object#cycle', call_info.call_sequence)
|
178
163
|
assert_equal(1, call_info.children.length)
|
179
164
|
|
180
165
|
method = methods[2]
|
181
166
|
assert_equal('Object#sub_cycle', method.full_name)
|
182
|
-
assert_equal(
|
167
|
+
assert_equal(2, method.called)
|
183
168
|
assert_in_delta(2, method.total_time, 0.05)
|
184
169
|
assert_in_delta(0, method.self_time, 0.05)
|
185
170
|
assert_in_delta(0, method.wait_time, 0.05)
|
186
171
|
assert_in_delta(2, method.children_time, 0.05)
|
187
172
|
|
188
|
-
assert_equal(
|
173
|
+
assert_equal(2, method.call_infos.length)
|
189
174
|
call_info = method.call_infos[0]
|
190
175
|
assert_equal('RecursiveTest#test_cycle->Object#cycle->Object#sub_cycle', call_info.call_sequence)
|
191
176
|
if RUBY_VERSION < '1.9'
|
@@ -208,33 +193,11 @@ class RecursiveTest < Test::Unit::TestCase
|
|
208
193
|
assert_equal(0, call_info.children.length)
|
209
194
|
|
210
195
|
call_info = method.call_infos[1]
|
211
|
-
assert_equal('RecursiveTest#test_cycle->Object#cycle->Object#sub_cycle->Object#cycle
|
196
|
+
assert_equal('RecursiveTest#test_cycle->Object#cycle->Object#sub_cycle->Object#cycle->Object#sub_cycle->Kernel#sleep', call_info.call_sequence)
|
212
197
|
assert_equal(0, call_info.children.length)
|
213
198
|
|
214
|
-
method = methods[4]
|
215
|
-
assert_equal('Object#cycle(d1)', method.full_name)
|
216
|
-
assert_equal(1, method.called)
|
217
|
-
assert_in_delta(1, method.total_time, 0.05)
|
218
|
-
assert_in_delta(0, method.self_time, 0.01)
|
219
|
-
assert_in_delta(0, method.wait_time, 0.01)
|
220
|
-
assert_in_delta(1, method.children_time, 0.05)
|
221
|
-
|
222
|
-
assert_equal(1, method.call_infos.length)
|
223
|
-
call_info = method.call_infos[0]
|
224
|
-
assert_equal('RecursiveTest#test_cycle->Object#cycle->Object#sub_cycle->Object#cycle(d1)', call_info.call_sequence)
|
225
|
-
assert_equal(1, call_info.children.length)
|
226
|
-
|
227
|
-
method = methods[5]
|
228
|
-
assert_equal('Object#sub_cycle(d1)', method.full_name)
|
229
|
-
assert_equal(1, method.called)
|
230
|
-
assert_in_delta(1, method.total_time, 0.01)
|
231
|
-
assert_in_delta(0, method.self_time, 0.01)
|
232
|
-
assert_in_delta(0, method.wait_time, 0.01)
|
233
|
-
call_info = method.call_infos[0]
|
234
|
-
assert_equal('RecursiveTest#test_cycle->Object#cycle->Object#sub_cycle->Object#cycle(d1)->Object#sub_cycle(d1)', call_info.call_sequence)
|
235
199
|
if RUBY_VERSION < '1.9'
|
236
|
-
|
237
|
-
method = methods[6]
|
200
|
+
method = methods[4]
|
238
201
|
assert_equal('Fixnum#-', method.full_name)
|
239
202
|
assert_equal(2, method.called)
|
240
203
|
assert_in_delta(0, method.total_time, 0.01)
|
@@ -248,10 +211,10 @@ class RecursiveTest < Test::Unit::TestCase
|
|
248
211
|
assert_equal(0, call_info.children.length)
|
249
212
|
|
250
213
|
call_info = method.call_infos[1]
|
251
|
-
assert_equal('RecursiveTest#test_cycle->Object#cycle->Object#sub_cycle->Object#cycle
|
214
|
+
assert_equal('RecursiveTest#test_cycle->Object#cycle->Object#sub_cycle->Object#cycle->Object#sub_cycle->Fixnum#-', call_info.call_sequence)
|
252
215
|
assert_equal(0, call_info.children.length)
|
253
216
|
|
254
|
-
method = methods[
|
217
|
+
method = methods[5]
|
255
218
|
assert_equal('Fixnum#==', method.full_name)
|
256
219
|
assert_equal(2, method.called)
|
257
220
|
assert_in_delta(0, method.total_time, 0.01)
|
@@ -265,10 +228,8 @@ class RecursiveTest < Test::Unit::TestCase
|
|
265
228
|
assert_equal(0, call_info.children.length)
|
266
229
|
|
267
230
|
call_info = method.call_infos[1]
|
268
|
-
assert_equal('RecursiveTest#test_cycle->Object#cycle->Object#sub_cycle->Object#cycle
|
231
|
+
assert_equal('RecursiveTest#test_cycle->Object#cycle->Object#sub_cycle->Object#cycle->Object#sub_cycle->Fixnum#==', call_info.call_sequence)
|
269
232
|
assert_equal(0, call_info.children.length)
|
270
|
-
else
|
271
|
-
assert_equal(1, call_info.children.length)
|
272
233
|
end
|
273
234
|
|
274
235
|
end
|