ruby-prof 0.4.0-mswin32 → 0.4.1-mswin32
Sign up to get free protection for your applications and to get access to all the features.
- data/README +220 -220
- data/Rakefile +3 -3
- data/doc/created.rid +1 -1
- data/doc/files/LICENSE.html +0 -142
- data/doc/files/README.html +2 -2
- data/doc/files/examples/flat_txt.html +8 -16
- data/doc/files/examples/graph_txt.html +10 -18
- data/doc/files/ext/ruby_prof_c.html +1 -1
- data/doc/files/lib/ruby-prof/flat_printer_rb.html +1 -1
- data/doc/files/lib/ruby-prof/graph_html_printer_rb.html +1 -1
- data/doc/files/lib/ruby-prof/graph_printer_rb.html +1 -1
- data/examples/flat.txt +55 -57
- data/examples/graph.html +827 -827
- data/examples/graph.txt +170 -171
- data/ext/ruby_prof.c +35 -20
- data/lib/ruby-prof/flat_printer.rb +8 -9
- data/lib/ruby-prof/graph_html_printer.rb +3 -2
- data/lib/ruby-prof/graph_printer.rb +4 -5
- data/lib/ruby_prof.so +0 -0
- data/test/basic_test.rb +148 -141
- data/test/clock_mode_test.rb +72 -72
- data/test/duplicate_names_test.rb +37 -0
- data/test/module_test.rb +45 -45
- data/test/prime.rb +58 -58
- data/test/prime_test.rb +23 -23
- data/test/printers_test.rb +27 -27
- data/test/recursive_test.rb +55 -55
- data/test/test_helper.rb +45 -45
- data/test/test_suite.rb +10 -9
- data/test/thread_test.rb +32 -32
- data/test/timing_test.rb +90 -90
- metadata +3 -16
- data/doc/classes/RubyProf.html +0 -563
- data/doc/classes/RubyProf/CallInfo.html +0 -274
- data/doc/classes/RubyProf/FlatPrinter.html +0 -207
- data/doc/classes/RubyProf/GraphHtmlPrinter.html +0 -538
- data/doc/classes/RubyProf/GraphPrinter.html +0 -240
- data/doc/classes/RubyProf/MethodInfo.html +0 -556
- data/doc/classes/RubyProf/ProfileTask.html +0 -395
- data/doc/classes/RubyProf/Result.html +0 -234
- data/doc/fr_class_index.html +0 -34
- data/doc/fr_file_index.html +0 -39
- data/doc/fr_method_index.html +0 -67
- data/doc/index.html +0 -24
- data/test/test.rb +0 -3
@@ -168,8 +168,9 @@ module RubyProf
|
|
168
168
|
<th>Name</th>
|
169
169
|
</tr>
|
170
170
|
|
171
|
-
<% methods
|
172
|
-
|
171
|
+
<% methods.sort.reverse.each do |pair| %>
|
172
|
+
<% name = pair[0] %>
|
173
|
+
<% method = pair[1] %>
|
173
174
|
<% method_total_percent = self.total_percent(method) %>
|
174
175
|
<% next if method_total_percent < @min_percent %>
|
175
176
|
<% method_self_percent = self.self_percent(method) %>
|
@@ -63,11 +63,10 @@ module RubyProf
|
|
63
63
|
|
64
64
|
print_heading(thread_id)
|
65
65
|
|
66
|
-
# Get methods and sort by time
|
67
|
-
methods = methods.values.sort.reverse
|
68
|
-
|
69
66
|
# Print each method
|
70
|
-
methods.each do |
|
67
|
+
methods.sort.reverse.each do |pair|
|
68
|
+
name = pair[0]
|
69
|
+
method = pair[1]
|
71
70
|
total_percentage = (method.total_time/total_time) * 100
|
72
71
|
self_percentage = (method.self_time/total_time) * 100
|
73
72
|
|
@@ -84,7 +83,7 @@ module RubyProf
|
|
84
83
|
@output << sprintf("%#{TIME_WIDTH}.2f", method.self_time)
|
85
84
|
@output << sprintf("%#{TIME_WIDTH}.2f", method.children_time)
|
86
85
|
@output << sprintf("%#{CALL_WIDTH}i", method.called)
|
87
|
-
@output << sprintf(" %s",
|
86
|
+
@output << sprintf(" %s", name)
|
88
87
|
@output << "\n"
|
89
88
|
|
90
89
|
print_children(thread_id, method)
|
data/lib/ruby_prof.so
CHANGED
Binary file
|
data/test/basic_test.rb
CHANGED
@@ -1,141 +1,148 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require 'test/unit'
|
4
|
-
require 'ruby-prof'
|
5
|
-
require 'test_helper'
|
6
|
-
|
7
|
-
class C1
|
8
|
-
def C1.hello
|
9
|
-
end
|
10
|
-
|
11
|
-
def hello
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
module M1
|
16
|
-
def hello
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
class C2
|
21
|
-
include M1
|
22
|
-
extend M1
|
23
|
-
end
|
24
|
-
|
25
|
-
class C3
|
26
|
-
def hello
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
module M4
|
31
|
-
def hello
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
module M5
|
36
|
-
include M4
|
37
|
-
def goodbye
|
38
|
-
hello
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
class C6
|
43
|
-
include M5
|
44
|
-
def test
|
45
|
-
goodbye
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
class BasicTest < Test::Unit::TestCase
|
50
|
-
def
|
51
|
-
RubyProf.
|
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
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
#
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'test/unit'
|
4
|
+
require 'ruby-prof'
|
5
|
+
require 'test_helper'
|
6
|
+
|
7
|
+
class C1
|
8
|
+
def C1.hello
|
9
|
+
end
|
10
|
+
|
11
|
+
def hello
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
module M1
|
16
|
+
def hello
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
class C2
|
21
|
+
include M1
|
22
|
+
extend M1
|
23
|
+
end
|
24
|
+
|
25
|
+
class C3
|
26
|
+
def hello
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
module M4
|
31
|
+
def hello
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
module M5
|
36
|
+
include M4
|
37
|
+
def goodbye
|
38
|
+
hello
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
class C6
|
43
|
+
include M5
|
44
|
+
def test
|
45
|
+
goodbye
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
class BasicTest < Test::Unit::TestCase
|
50
|
+
def test_running
|
51
|
+
assert(!RubyProf.running?)
|
52
|
+
RubyProf.start
|
53
|
+
assert(RubyProf.running?)
|
54
|
+
RubyProf.stop
|
55
|
+
assert(!RubyProf.running?)
|
56
|
+
end
|
57
|
+
|
58
|
+
def test_double_profile
|
59
|
+
RubyProf.start
|
60
|
+
assert_raise(RuntimeError) do
|
61
|
+
RubyProf.start
|
62
|
+
end
|
63
|
+
|
64
|
+
assert_raise(RuntimeError) do
|
65
|
+
RubyProf.profile do
|
66
|
+
puts 1
|
67
|
+
end
|
68
|
+
end
|
69
|
+
RubyProf.stop
|
70
|
+
end
|
71
|
+
|
72
|
+
def test_no_block
|
73
|
+
assert_raise(ArgumentError) do
|
74
|
+
RubyProf.profile
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
def test_class_and_instance_methods
|
79
|
+
result = RubyProf.profile do
|
80
|
+
C1.hello
|
81
|
+
C1.new.hello
|
82
|
+
end
|
83
|
+
|
84
|
+
methods = result.threads.values.first
|
85
|
+
|
86
|
+
# Length should be 6:
|
87
|
+
# 1 top level,
|
88
|
+
# 1 Class.new
|
89
|
+
# 1 Class:Object allocate
|
90
|
+
# 1 for Object.initialize
|
91
|
+
# 1 for Class hello
|
92
|
+
# 1 for Object hello
|
93
|
+
assert_equal(6, methods.length)
|
94
|
+
|
95
|
+
# Check class method
|
96
|
+
method1 = methods['<Class::C1>#hello']
|
97
|
+
assert_not_nil(method1)
|
98
|
+
|
99
|
+
# Check instance method
|
100
|
+
method1 = methods['C1#hello']
|
101
|
+
assert_not_nil(method1)
|
102
|
+
end
|
103
|
+
|
104
|
+
def test_module_methods
|
105
|
+
result = RubyProf.profile do
|
106
|
+
C2.hello
|
107
|
+
C2.new.hello
|
108
|
+
end
|
109
|
+
|
110
|
+
methods = result.threads.values.first
|
111
|
+
|
112
|
+
# Length should be 5:
|
113
|
+
# 1 top level,
|
114
|
+
# 1 Class.new
|
115
|
+
# 1 Class:Object allocate
|
116
|
+
# 1 for Object.initialize
|
117
|
+
# 1 for hello
|
118
|
+
assert_equal(5, methods.length)
|
119
|
+
|
120
|
+
# Check class method
|
121
|
+
method1 = methods['M1#hello']
|
122
|
+
assert_not_nil(method1)
|
123
|
+
assert_equal(2, method1.called)
|
124
|
+
end
|
125
|
+
|
126
|
+
def test_singleton
|
127
|
+
c3 = C3.new
|
128
|
+
|
129
|
+
class << c3
|
130
|
+
def hello
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
result = RubyProf.profile do
|
135
|
+
c3.hello
|
136
|
+
end
|
137
|
+
|
138
|
+
methods = result.threads.values.first
|
139
|
+
|
140
|
+
# Length should be 2 - one for top level
|
141
|
+
# and one for the singleton method.
|
142
|
+
assert_equal(2, methods.length)
|
143
|
+
|
144
|
+
# Check singleton method
|
145
|
+
method1 = methods['<Object::C3>#hello']
|
146
|
+
assert_not_nil(method1)
|
147
|
+
end
|
148
|
+
end
|
data/test/clock_mode_test.rb
CHANGED
@@ -1,73 +1,73 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require 'test/unit'
|
4
|
-
require 'ruby-prof'
|
5
|
-
require 'test_helper'
|
6
|
-
require 'prime'
|
7
|
-
|
8
|
-
|
9
|
-
# -- Tests ----
|
10
|
-
class ClockModeTest < Test::Unit::TestCase
|
11
|
-
def test_clock
|
12
|
-
return
|
13
|
-
RubyProf::clock_mode = RubyProf::PROCESS_TIME
|
14
|
-
assert_equal(RubyProf::PROCESS_TIME, RubyProf::clock_mode)
|
15
|
-
result = RubyProf.profile do
|
16
|
-
run_primes
|
17
|
-
end
|
18
|
-
|
19
|
-
print_results(result)
|
20
|
-
|
21
|
-
result.threads.values.each do |methods|
|
22
|
-
methods.values.each do |method|
|
23
|
-
check_parent_times(method)
|
24
|
-
check_parent_calls(method)
|
25
|
-
check_child_times(method)
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
def test_gettimeofday
|
31
|
-
return
|
32
|
-
RubyProf::clock_mode = RubyProf::WALL_TIME
|
33
|
-
assert_equal(RubyProf::WALL_TIME, RubyProf::clock_mode)
|
34
|
-
result = RubyProf.profile do
|
35
|
-
run_primes
|
36
|
-
end
|
37
|
-
|
38
|
-
print_results(result)
|
39
|
-
|
40
|
-
result.threads.values.each do |methods|
|
41
|
-
methods.values.each do |method|
|
42
|
-
check_parent_times(method)
|
43
|
-
check_parent_calls(method)
|
44
|
-
check_child_times(method)
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
def test_cpu
|
50
|
-
#return
|
51
|
-
RubyProf::clock_mode = RubyProf::CPU_TIME
|
52
|
-
assert_equal(RubyProf::CPU, RubyProf::clock_mode)
|
53
|
-
result = RubyProf.profile do
|
54
|
-
run_primes
|
55
|
-
end
|
56
|
-
|
57
|
-
print_results(result)
|
58
|
-
|
59
|
-
result.threads.values.each do |methods|
|
60
|
-
methods.values.each do |method|
|
61
|
-
check_parent_times(method)
|
62
|
-
check_parent_calls(method)
|
63
|
-
check_child_times(method)
|
64
|
-
end
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
|
-
def test_invalid
|
69
|
-
assert_raise(ArgumentError) do
|
70
|
-
RubyProf::clock_mode = 7777
|
71
|
-
end
|
72
|
-
end
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'test/unit'
|
4
|
+
require 'ruby-prof'
|
5
|
+
require 'test_helper'
|
6
|
+
require 'prime'
|
7
|
+
|
8
|
+
|
9
|
+
# -- Tests ----
|
10
|
+
class ClockModeTest < Test::Unit::TestCase
|
11
|
+
def test_clock
|
12
|
+
return
|
13
|
+
RubyProf::clock_mode = RubyProf::PROCESS_TIME
|
14
|
+
assert_equal(RubyProf::PROCESS_TIME, RubyProf::clock_mode)
|
15
|
+
result = RubyProf.profile do
|
16
|
+
run_primes
|
17
|
+
end
|
18
|
+
|
19
|
+
print_results(result)
|
20
|
+
|
21
|
+
result.threads.values.each do |methods|
|
22
|
+
methods.values.each do |method|
|
23
|
+
check_parent_times(method)
|
24
|
+
check_parent_calls(method)
|
25
|
+
check_child_times(method)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def test_gettimeofday
|
31
|
+
return
|
32
|
+
RubyProf::clock_mode = RubyProf::WALL_TIME
|
33
|
+
assert_equal(RubyProf::WALL_TIME, RubyProf::clock_mode)
|
34
|
+
result = RubyProf.profile do
|
35
|
+
run_primes
|
36
|
+
end
|
37
|
+
|
38
|
+
print_results(result)
|
39
|
+
|
40
|
+
result.threads.values.each do |methods|
|
41
|
+
methods.values.each do |method|
|
42
|
+
check_parent_times(method)
|
43
|
+
check_parent_calls(method)
|
44
|
+
check_child_times(method)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def test_cpu
|
50
|
+
#return
|
51
|
+
RubyProf::clock_mode = RubyProf::CPU_TIME
|
52
|
+
assert_equal(RubyProf::CPU, RubyProf::clock_mode)
|
53
|
+
result = RubyProf.profile do
|
54
|
+
run_primes
|
55
|
+
end
|
56
|
+
|
57
|
+
print_results(result)
|
58
|
+
|
59
|
+
result.threads.values.each do |methods|
|
60
|
+
methods.values.each do |method|
|
61
|
+
check_parent_times(method)
|
62
|
+
check_parent_calls(method)
|
63
|
+
check_child_times(method)
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
def test_invalid
|
69
|
+
assert_raise(ArgumentError) do
|
70
|
+
RubyProf::clock_mode = 7777
|
71
|
+
end
|
72
|
+
end
|
73
73
|
end
|