ruby-prof 1.7.1 → 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 +8 -0
- data/ext/ruby_prof/extconf.rb +23 -22
- 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_process_time.c +64 -66
- data/ext/ruby_prof/rp_measure_wall_time.c +52 -64
- data/ext/ruby_prof/rp_method.c +551 -551
- data/ext/ruby_prof/rp_stack.c +212 -212
- data/ext/ruby_prof/ruby_prof.c +50 -50
- data/ext/ruby_prof/ruby_prof.h +3 -2
- data/ext/ruby_prof/vc/ruby_prof.vcxproj +3 -3
- data/lib/ruby-prof/compatibility.rb +113 -113
- data/lib/ruby-prof/exclude_common_methods.rb +204 -204
- data/lib/ruby-prof/printers/abstract_printer.rb +156 -138
- data/lib/ruby-prof/version.rb +3 -3
- data/ruby-prof.gemspec +66 -65
- data/test/dynamic_method_test.rb +9 -21
- data/test/enumerable_test.rb +23 -21
- data/test/exclude_methods_test.rb +363 -257
- data/test/fiber_test.rb +195 -195
- data/test/gc_test.rb +104 -102
- data/test/line_number_test.rb +426 -289
- data/test/measure_allocations_test.rb +1172 -1081
- data/test/measure_memory_test.rb +1193 -1456
- data/test/measure_process_time_test.rb +3330 -2477
- data/test/measure_wall_time_test.rb +634 -568
- 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 -622
- data/test/start_stop_test.rb +4 -4
- data/test/test_helper.rb +20 -20
- data/test/thread_test.rb +229 -231
- data/test/unique_call_path_test.rb +9 -22
- data/test/yarv_test.rb +1 -5
- metadata +19 -9
- data/test/crash2.rb +0 -144
data/test/merge_test.rb
CHANGED
@@ -1,146 +1,146 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
# encoding: UTF-8
|
3
|
-
|
4
|
-
require File.expand_path('../test_helper', __FILE__)
|
5
|
-
|
6
|
-
if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('3.1.0')
|
7
|
-
|
8
|
-
require_relative './scheduler'
|
9
|
-
|
10
|
-
# -- Tests ----
|
11
|
-
class MergeTest < TestCase
|
12
|
-
def worker1
|
13
|
-
sleep(0.5)
|
14
|
-
end
|
15
|
-
|
16
|
-
def worker2
|
17
|
-
sleep(0.5)
|
18
|
-
sleep(0.5)
|
19
|
-
end
|
20
|
-
|
21
|
-
def worker3
|
22
|
-
sleep(0.5)
|
23
|
-
end
|
24
|
-
|
25
|
-
def concurrency_single_worker
|
26
|
-
scheduler = Scheduler.new
|
27
|
-
Fiber.set_scheduler(scheduler)
|
28
|
-
|
29
|
-
3.times do
|
30
|
-
Fiber.schedule do
|
31
|
-
worker1
|
32
|
-
end
|
33
|
-
end
|
34
|
-
Fiber.scheduler.close
|
35
|
-
end
|
36
|
-
|
37
|
-
def concurrency_multiple_workers
|
38
|
-
scheduler = Scheduler.new
|
39
|
-
Fiber.set_scheduler(scheduler)
|
40
|
-
|
41
|
-
3.times do |i|
|
42
|
-
Fiber.schedule do
|
43
|
-
method = "worker#{i + 1}".to_sym
|
44
|
-
send(method)
|
45
|
-
end
|
46
|
-
end
|
47
|
-
Fiber.scheduler.close
|
48
|
-
end
|
49
|
-
|
50
|
-
def test_single_worker_unmerged
|
51
|
-
result = RubyProf::Profile.profile(measure_mode: RubyProf::WALL_TIME) { concurrency_single_worker }
|
52
|
-
assert_equal(4, result.threads.size)
|
53
|
-
|
54
|
-
thread = result.threads[0]
|
55
|
-
assert_in_delta(0.5, thread.call_tree.target.total_time, 0.1)
|
56
|
-
assert_in_delta(0.0, thread.call_tree.target.self_time, 0.1)
|
57
|
-
assert_in_delta(0.0, thread.call_tree.target.wait_time, 0.1)
|
58
|
-
assert_in_delta(0.5, thread.call_tree.target.children_time, 0.1)
|
59
|
-
|
60
|
-
thread = result.threads[1]
|
61
|
-
assert_in_delta(0.5, thread.call_tree.target.total_time, 0.1)
|
62
|
-
assert_in_delta(0.0, thread.call_tree.target.self_time, 0.1)
|
63
|
-
assert_in_delta(0.0, thread.call_tree.target.wait_time, 0.1)
|
64
|
-
assert_in_delta(0.5, thread.call_tree.target.children_time, 0.1)
|
65
|
-
|
66
|
-
thread = result.threads[2]
|
67
|
-
assert_in_delta(0.5, thread.call_tree.target.total_time, 0.1)
|
68
|
-
assert_in_delta(0.0, thread.call_tree.target.self_time, 0.1)
|
69
|
-
assert_in_delta(0.0, thread.call_tree.target.wait_time, 0.1)
|
70
|
-
assert_in_delta(0.5, thread.call_tree.target.children_time, 0.1)
|
71
|
-
|
72
|
-
thread = result.threads[3]
|
73
|
-
assert_in_delta(0.5, thread.call_tree.target.total_time, 0.1)
|
74
|
-
assert_in_delta(0.0, thread.call_tree.target.self_time, 0.1)
|
75
|
-
assert_in_delta(0.0, thread.call_tree.target.wait_time, 0.1)
|
76
|
-
assert_in_delta(0.5, thread.call_tree.target.children_time, 0.1)
|
77
|
-
end
|
78
|
-
|
79
|
-
def test_single_worker_merged
|
80
|
-
result = RubyProf::Profile.profile(measure_mode: RubyProf::WALL_TIME) { concurrency_single_worker }
|
81
|
-
result.merge!
|
82
|
-
|
83
|
-
assert_equal(2, result.threads.size)
|
84
|
-
|
85
|
-
thread = result.threads[0]
|
86
|
-
assert_in_delta(0.5, thread.call_tree.target.total_time, 0.1)
|
87
|
-
assert_in_delta(0.0, thread.call_tree.target.self_time, 0.1)
|
88
|
-
assert_in_delta(0.0, thread.call_tree.target.wait_time, 0.1)
|
89
|
-
assert_in_delta(0.5, thread.call_tree.target.children_time, 0.1)
|
90
|
-
|
91
|
-
thread = result.threads[1]
|
92
|
-
assert_in_delta(1.5, thread.call_tree.target.total_time, 0.1)
|
93
|
-
assert_in_delta(0.0, thread.call_tree.target.self_time, 0.1)
|
94
|
-
assert_in_delta(0.0, thread.call_tree.target.wait_time, 0.1)
|
95
|
-
assert_in_delta(1.5, thread.call_tree.target.children_time, 0.1)
|
96
|
-
end
|
97
|
-
|
98
|
-
def test_multiple_workers_unmerged
|
99
|
-
result = RubyProf::Profile.profile(measure_mode: RubyProf::WALL_TIME) { concurrency_multiple_workers }
|
100
|
-
assert_equal(4, result.threads.count)
|
101
|
-
|
102
|
-
thread = result.threads[0]
|
103
|
-
assert_in_delta(1.0, thread.call_tree.target.total_time, 0.1)
|
104
|
-
assert_in_delta(0.0, thread.call_tree.target.self_time, 0.1)
|
105
|
-
assert_in_delta(0.0, thread.call_tree.target.wait_time, 0.1)
|
106
|
-
assert_in_delta(1.0, thread.call_tree.target.children_time, 0.1)
|
107
|
-
|
108
|
-
thread = result.threads[1]
|
109
|
-
assert_in_delta(1.0, thread.call_tree.target.total_time, 0.1)
|
110
|
-
assert_in_delta(0.0, thread.call_tree.target.self_time, 0.1)
|
111
|
-
assert_in_delta(0.5, thread.call_tree.target.wait_time, 0.1)
|
112
|
-
assert_in_delta(0.5, thread.call_tree.target.children_time, 0.1)
|
113
|
-
|
114
|
-
thread = result.threads[2]
|
115
|
-
assert_in_delta(1.0, thread.call_tree.target.total_time, 0.1)
|
116
|
-
assert_in_delta(0.0, thread.call_tree.target.self_time, 0.1)
|
117
|
-
assert_in_delta(0.0, thread.call_tree.target.wait_time, 0.1)
|
118
|
-
assert_in_delta(1.0, thread.call_tree.target.children_time, 0.1)
|
119
|
-
|
120
|
-
thread = result.threads[3]
|
121
|
-
assert_in_delta(1.0, thread.call_tree.target.total_time, 0.1)
|
122
|
-
assert_in_delta(0.0, thread.call_tree.target.self_time, 0.1)
|
123
|
-
assert_in_delta(0.5, thread.call_tree.target.wait_time, 0.1)
|
124
|
-
assert_in_delta(0.5, thread.call_tree.target.children_time, 0.1)
|
125
|
-
end
|
126
|
-
|
127
|
-
def test_multiple_workers_merged
|
128
|
-
result = RubyProf::Profile.profile(measure_mode: RubyProf::WALL_TIME) { concurrency_multiple_workers }
|
129
|
-
result.merge!
|
130
|
-
|
131
|
-
assert_equal(2, result.threads.count)
|
132
|
-
|
133
|
-
thread = result.threads[0]
|
134
|
-
assert_in_delta(1.0, thread.call_tree.target.total_time, 0.1)
|
135
|
-
assert_in_delta(0.0, thread.call_tree.target.self_time, 0.1)
|
136
|
-
assert_in_delta(0.0, thread.call_tree.target.wait_time, 0.1)
|
137
|
-
assert_in_delta(1.0, thread.call_tree.target.children_time, 0.1)
|
138
|
-
|
139
|
-
thread = result.threads[1]
|
140
|
-
assert_in_delta(3.0, thread.call_tree.target.total_time, 0.1)
|
141
|
-
assert_in_delta(0.0, thread.call_tree.target.self_time, 0.1)
|
142
|
-
assert_in_delta(1.0, thread.call_tree.target.wait_time, 0.1)
|
143
|
-
assert_in_delta(2.0, thread.call_tree.target.children_time, 0.1)
|
144
|
-
end
|
145
|
-
end
|
146
|
-
end
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# encoding: UTF-8
|
3
|
+
|
4
|
+
require File.expand_path('../test_helper', __FILE__)
|
5
|
+
|
6
|
+
if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('3.1.0')
|
7
|
+
|
8
|
+
require_relative './scheduler'
|
9
|
+
|
10
|
+
# -- Tests ----
|
11
|
+
class MergeTest < TestCase
|
12
|
+
def worker1
|
13
|
+
sleep(0.5)
|
14
|
+
end
|
15
|
+
|
16
|
+
def worker2
|
17
|
+
sleep(0.5)
|
18
|
+
sleep(0.5)
|
19
|
+
end
|
20
|
+
|
21
|
+
def worker3
|
22
|
+
sleep(0.5)
|
23
|
+
end
|
24
|
+
|
25
|
+
def concurrency_single_worker
|
26
|
+
scheduler = Scheduler.new
|
27
|
+
Fiber.set_scheduler(scheduler)
|
28
|
+
|
29
|
+
3.times do
|
30
|
+
Fiber.schedule do
|
31
|
+
worker1
|
32
|
+
end
|
33
|
+
end
|
34
|
+
Fiber.scheduler.close
|
35
|
+
end
|
36
|
+
|
37
|
+
def concurrency_multiple_workers
|
38
|
+
scheduler = Scheduler.new
|
39
|
+
Fiber.set_scheduler(scheduler)
|
40
|
+
|
41
|
+
3.times do |i|
|
42
|
+
Fiber.schedule do
|
43
|
+
method = "worker#{i + 1}".to_sym
|
44
|
+
send(method)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
Fiber.scheduler.close
|
48
|
+
end
|
49
|
+
|
50
|
+
def test_single_worker_unmerged
|
51
|
+
result = RubyProf::Profile.profile(measure_mode: RubyProf::WALL_TIME) { concurrency_single_worker }
|
52
|
+
assert_equal(4, result.threads.size)
|
53
|
+
|
54
|
+
thread = result.threads[0]
|
55
|
+
assert_in_delta(0.5, thread.call_tree.target.total_time, 0.1)
|
56
|
+
assert_in_delta(0.0, thread.call_tree.target.self_time, 0.1)
|
57
|
+
assert_in_delta(0.0, thread.call_tree.target.wait_time, 0.1)
|
58
|
+
assert_in_delta(0.5, thread.call_tree.target.children_time, 0.1)
|
59
|
+
|
60
|
+
thread = result.threads[1]
|
61
|
+
assert_in_delta(0.5, thread.call_tree.target.total_time, 0.1)
|
62
|
+
assert_in_delta(0.0, thread.call_tree.target.self_time, 0.1)
|
63
|
+
assert_in_delta(0.0, thread.call_tree.target.wait_time, 0.1)
|
64
|
+
assert_in_delta(0.5, thread.call_tree.target.children_time, 0.1)
|
65
|
+
|
66
|
+
thread = result.threads[2]
|
67
|
+
assert_in_delta(0.5, thread.call_tree.target.total_time, 0.1)
|
68
|
+
assert_in_delta(0.0, thread.call_tree.target.self_time, 0.1)
|
69
|
+
assert_in_delta(0.0, thread.call_tree.target.wait_time, 0.1)
|
70
|
+
assert_in_delta(0.5, thread.call_tree.target.children_time, 0.1)
|
71
|
+
|
72
|
+
thread = result.threads[3]
|
73
|
+
assert_in_delta(0.5, thread.call_tree.target.total_time, 0.1)
|
74
|
+
assert_in_delta(0.0, thread.call_tree.target.self_time, 0.1)
|
75
|
+
assert_in_delta(0.0, thread.call_tree.target.wait_time, 0.1)
|
76
|
+
assert_in_delta(0.5, thread.call_tree.target.children_time, 0.1)
|
77
|
+
end
|
78
|
+
|
79
|
+
def test_single_worker_merged
|
80
|
+
result = RubyProf::Profile.profile(measure_mode: RubyProf::WALL_TIME) { concurrency_single_worker }
|
81
|
+
result.merge!
|
82
|
+
|
83
|
+
assert_equal(2, result.threads.size)
|
84
|
+
|
85
|
+
thread = result.threads[0]
|
86
|
+
assert_in_delta(0.5, thread.call_tree.target.total_time, 0.1)
|
87
|
+
assert_in_delta(0.0, thread.call_tree.target.self_time, 0.1)
|
88
|
+
assert_in_delta(0.0, thread.call_tree.target.wait_time, 0.1)
|
89
|
+
assert_in_delta(0.5, thread.call_tree.target.children_time, 0.1)
|
90
|
+
|
91
|
+
thread = result.threads[1]
|
92
|
+
assert_in_delta(1.5, thread.call_tree.target.total_time, 0.1)
|
93
|
+
assert_in_delta(0.0, thread.call_tree.target.self_time, 0.1)
|
94
|
+
assert_in_delta(0.0, thread.call_tree.target.wait_time, 0.1)
|
95
|
+
assert_in_delta(1.5, thread.call_tree.target.children_time, 0.1)
|
96
|
+
end
|
97
|
+
|
98
|
+
def test_multiple_workers_unmerged
|
99
|
+
result = RubyProf::Profile.profile(measure_mode: RubyProf::WALL_TIME) { concurrency_multiple_workers }
|
100
|
+
assert_equal(4, result.threads.count)
|
101
|
+
|
102
|
+
thread = result.threads[0]
|
103
|
+
assert_in_delta(1.0, thread.call_tree.target.total_time, 0.1)
|
104
|
+
assert_in_delta(0.0, thread.call_tree.target.self_time, 0.1)
|
105
|
+
assert_in_delta(0.0, thread.call_tree.target.wait_time, 0.1)
|
106
|
+
assert_in_delta(1.0, thread.call_tree.target.children_time, 0.1)
|
107
|
+
|
108
|
+
thread = result.threads[1]
|
109
|
+
assert_in_delta(1.0, thread.call_tree.target.total_time, 0.1)
|
110
|
+
assert_in_delta(0.0, thread.call_tree.target.self_time, 0.1)
|
111
|
+
assert_in_delta(0.5, thread.call_tree.target.wait_time, 0.1)
|
112
|
+
assert_in_delta(0.5, thread.call_tree.target.children_time, 0.1)
|
113
|
+
|
114
|
+
thread = result.threads[2]
|
115
|
+
assert_in_delta(1.0, thread.call_tree.target.total_time, 0.1)
|
116
|
+
assert_in_delta(0.0, thread.call_tree.target.self_time, 0.1)
|
117
|
+
assert_in_delta(0.0, thread.call_tree.target.wait_time, 0.1)
|
118
|
+
assert_in_delta(1.0, thread.call_tree.target.children_time, 0.1)
|
119
|
+
|
120
|
+
thread = result.threads[3]
|
121
|
+
assert_in_delta(1.0, thread.call_tree.target.total_time, 0.1)
|
122
|
+
assert_in_delta(0.0, thread.call_tree.target.self_time, 0.1)
|
123
|
+
assert_in_delta(0.5, thread.call_tree.target.wait_time, 0.1)
|
124
|
+
assert_in_delta(0.5, thread.call_tree.target.children_time, 0.1)
|
125
|
+
end
|
126
|
+
|
127
|
+
def test_multiple_workers_merged
|
128
|
+
result = RubyProf::Profile.profile(measure_mode: RubyProf::WALL_TIME) { concurrency_multiple_workers }
|
129
|
+
result.merge!
|
130
|
+
|
131
|
+
assert_equal(2, result.threads.count)
|
132
|
+
|
133
|
+
thread = result.threads[0]
|
134
|
+
assert_in_delta(1.0, thread.call_tree.target.total_time, 0.1)
|
135
|
+
assert_in_delta(0.0, thread.call_tree.target.self_time, 0.1)
|
136
|
+
assert_in_delta(0.0, thread.call_tree.target.wait_time, 0.1)
|
137
|
+
assert_in_delta(1.0, thread.call_tree.target.children_time, 0.1)
|
138
|
+
|
139
|
+
thread = result.threads[1]
|
140
|
+
assert_in_delta(3.0, thread.call_tree.target.total_time, 0.1)
|
141
|
+
assert_in_delta(0.0, thread.call_tree.target.self_time, 0.1)
|
142
|
+
assert_in_delta(1.0, thread.call_tree.target.wait_time, 0.1)
|
143
|
+
assert_in_delta(2.0, thread.call_tree.target.children_time, 0.1)
|
144
|
+
end
|
145
|
+
end
|
146
|
+
end
|
data/test/method_info_test.rb
CHANGED
@@ -1,95 +1,100 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require File.expand_path('../test_helper', __FILE__)
|
4
|
-
require 'base64'
|
5
|
-
|
6
|
-
class MethodInfoTest < Minitest::Test
|
7
|
-
def test_initialize
|
8
|
-
method_info = RubyProf::MethodInfo.new(Base64, :encode64)
|
9
|
-
assert_equal("Base64", method_info.klass_name)
|
10
|
-
assert_equal(:encode64, method_info.method_name)
|
11
|
-
assert_equal("Base64#encode64", method_info.full_name)
|
12
|
-
assert_equal(0, method_info.klass_flags)
|
13
|
-
assert_match(/base64\.rb/, method_info.source_file)
|
14
|
-
assert_kind_of(Integer, method_info.line)
|
15
|
-
refute(method_info.recursive?)
|
16
|
-
|
17
|
-
assert_kind_of(RubyProf::Measurement, method_info.measurement)
|
18
|
-
assert_kind_of(RubyProf::CallTrees, method_info.call_trees)
|
19
|
-
assert_empty(method_info.allocations)
|
20
|
-
end
|
21
|
-
|
22
|
-
def test_initialize_nil_klass
|
23
|
-
error = assert_raises(NoMethodError) do
|
24
|
-
RubyProf::MethodInfo.new(nil, nil)
|
25
|
-
end
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
assert_equal(
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
method_info
|
46
|
-
assert_equal(0, method_info.
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
assert_equal(
|
94
|
-
end
|
95
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require File.expand_path('../test_helper', __FILE__)
|
4
|
+
require 'base64'
|
5
|
+
|
6
|
+
class MethodInfoTest < Minitest::Test
|
7
|
+
def test_initialize
|
8
|
+
method_info = RubyProf::MethodInfo.new(Base64, :encode64)
|
9
|
+
assert_equal("Base64", method_info.klass_name)
|
10
|
+
assert_equal(:encode64, method_info.method_name)
|
11
|
+
assert_equal("Base64#encode64", method_info.full_name)
|
12
|
+
assert_equal(0, method_info.klass_flags)
|
13
|
+
assert_match(/base64\.rb/, method_info.source_file)
|
14
|
+
assert_kind_of(Integer, method_info.line)
|
15
|
+
refute(method_info.recursive?)
|
16
|
+
|
17
|
+
assert_kind_of(RubyProf::Measurement, method_info.measurement)
|
18
|
+
assert_kind_of(RubyProf::CallTrees, method_info.call_trees)
|
19
|
+
assert_empty(method_info.allocations)
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_initialize_nil_klass
|
23
|
+
error = assert_raises(NoMethodError) do
|
24
|
+
RubyProf::MethodInfo.new(nil, nil)
|
25
|
+
end
|
26
|
+
|
27
|
+
if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('3.4')
|
28
|
+
assert_match(/undefined method `instance_method' for nil/, error.message)
|
29
|
+
else
|
30
|
+
assert_match(/undefined method 'instance_method' for nil/, error.message)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def test_initialize_nil_method_name
|
35
|
+
error = assert_raises(TypeError) do
|
36
|
+
RubyProf::MethodInfo.new(Base64, nil)
|
37
|
+
end
|
38
|
+
assert_equal("nil is not a symbol nor a string", error.to_s)
|
39
|
+
end
|
40
|
+
|
41
|
+
def test_initialize_unknown_location
|
42
|
+
method_info = RubyProf::MethodInfo.new(Array, :size)
|
43
|
+
assert_equal('Array', method_info.klass_name)
|
44
|
+
assert_equal(:size, method_info.method_name)
|
45
|
+
assert_nil(method_info.source_file)
|
46
|
+
assert_equal(0, method_info.line)
|
47
|
+
end
|
48
|
+
|
49
|
+
def test_measurement
|
50
|
+
method_info = RubyProf::MethodInfo.new(Base64, :encode64)
|
51
|
+
assert_equal(0, method_info.total_time)
|
52
|
+
assert_equal(0, method_info.self_time)
|
53
|
+
assert_equal(0, method_info.wait_time)
|
54
|
+
assert_equal(0, method_info.children_time)
|
55
|
+
assert_equal(0, method_info.called)
|
56
|
+
end
|
57
|
+
|
58
|
+
def test_compare
|
59
|
+
method_info_1 = RubyProf::MethodInfo.new(Base64, :encode64)
|
60
|
+
method_info_2 = RubyProf::MethodInfo.new(Base64, :encode64)
|
61
|
+
assert_equal(0, method_info_1 <=> method_info_2)
|
62
|
+
|
63
|
+
method_info_1 = RubyProf::MethodInfo.new(Base64, :decode64)
|
64
|
+
method_info_2 = RubyProf::MethodInfo.new(Base64, :encode64)
|
65
|
+
assert_equal(-1, method_info_1 <=> method_info_2)
|
66
|
+
|
67
|
+
method_info_1 = RubyProf::MethodInfo.new(Base64, :encode64)
|
68
|
+
method_info_2 = RubyProf::MethodInfo.new(Base64, :decode64)
|
69
|
+
assert_equal(1, method_info_1 <=> method_info_2)
|
70
|
+
end
|
71
|
+
|
72
|
+
def test_eql?
|
73
|
+
method_info_1 = RubyProf::MethodInfo.new(Base64, :encode64)
|
74
|
+
method_info_2 = RubyProf::MethodInfo.new(Base64, :encode64)
|
75
|
+
assert(method_info_1.eql?(method_info_2))
|
76
|
+
end
|
77
|
+
|
78
|
+
def test_equal?
|
79
|
+
method_info_1 = RubyProf::MethodInfo.new(Base64, :encode64)
|
80
|
+
method_info_2 = RubyProf::MethodInfo.new(Base64, :encode64)
|
81
|
+
refute(method_info_1.equal?(method_info_2))
|
82
|
+
end
|
83
|
+
|
84
|
+
def test_equality
|
85
|
+
method_info_1 = RubyProf::MethodInfo.new(Base64, :encode64)
|
86
|
+
method_info_2 = RubyProf::MethodInfo.new(Base64, :encode64)
|
87
|
+
assert(method_info_1 == method_info_2)
|
88
|
+
end
|
89
|
+
|
90
|
+
def test_hash
|
91
|
+
method_info_1 = RubyProf::MethodInfo.new(Base64, :encode64)
|
92
|
+
method_info_2 = RubyProf::MethodInfo.new(Base64, :encode64)
|
93
|
+
assert_equal(method_info_1.hash, method_info_2.hash)
|
94
|
+
end
|
95
|
+
|
96
|
+
def test_to_s
|
97
|
+
method_info = RubyProf::MethodInfo.new(Base64, :encode64)
|
98
|
+
assert_equal("Base64#encode64 (c: 0, tt: 0.0, st: 0.0, wt: 0.0, ct: 0.0)", method_info.to_s)
|
99
|
+
end
|
100
|
+
end
|