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
data/examples/graph.txt
CHANGED
@@ -1,171 +1,170 @@
|
|
1
|
-
=Graph Profiles
|
2
|
-
|
3
|
-
Graph profiles show how long each method runs, which methods call it
|
4
|
-
and which methods it calls.
|
5
|
-
|
6
|
-
As an example, here is the output from running printers_test.rb:
|
7
|
-
|
8
|
-
|
9
|
-
Thread ID: 21277412
|
10
|
-
%total %self total self children calls Name
|
11
|
-
--------------------------------------------------------------------------------
|
12
|
-
100.00% 0.00% 8.77 0.00 8.77 1 #toplevel
|
13
|
-
8.77 0.00 8.77 1/1 Object#run_primes
|
14
|
-
--------------------------------------------------------------------------------
|
15
|
-
8.77 0.00 8.77 1/1 #toplevel
|
16
|
-
100.00% 0.00% 8.77 0.00 8.77 1 Object#run_primes
|
17
|
-
0.02 0.00 0.02 1/1 Object#make_random_array
|
18
|
-
2.09 0.00 2.09 1/1 Object#find_largest
|
19
|
-
6.66 0.00 6.66 1/1 Object#find_primes
|
20
|
-
--------------------------------------------------------------------------------
|
21
|
-
6.63 4.06 2.56 500/501 Object#is_prime
|
22
|
-
2.09 0.00 2.09 1/501 Object#find_largest
|
23
|
-
99.48% 46.34% 8.72 4.06 4.66 501 Integer#upto
|
24
|
-
0.00 0.00 0.00 61/61 Array#[]
|
25
|
-
0.00 0.00 0.00 61/61 Fixnum#>
|
26
|
-
2.09 2.09 0.00 61/61 Kernel.sleep
|
27
|
-
1.24 1.24 0.00 250862/250862 Fixnum#==
|
28
|
-
1.33 1.33 0.00 250862/250862 Fixnum#%
|
29
|
-
--------------------------------------------------------------------------------
|
30
|
-
6.66 0.01 6.64 1/1 Object#find_primes
|
31
|
-
75.93% 0.17% 6.66 0.01 6.64 1 Array#select
|
32
|
-
6.64 0.01 6.63 500/500 Object#is_prime
|
33
|
-
--------------------------------------------------------------------------------
|
34
|
-
6.66 0.00 6.66 1/1 Object#run_primes
|
35
|
-
75.93% 0.00% 6.66 0.00 6.66 1 Object#find_primes
|
36
|
-
6.66 0.01 6.64 1/1 Array#select
|
37
|
-
--------------------------------------------------------------------------------
|
38
|
-
6.64 0.01 6.63 500/500 Array#select
|
39
|
-
75.76% 0.17% 6.64 0.01 6.63 500 Object#is_prime
|
40
|
-
0.00 0.00 0.00 500/501 Fixnum#-
|
41
|
-
6.63 4.06 2.56 500/501 Integer#upto
|
42
|
-
--------------------------------------------------------------------------------
|
43
|
-
2.09 0.00 2.09 1/1 Object#run_primes
|
44
|
-
23.89% 0.00% 2.09 0.00 2.09 1 Object#find_largest
|
45
|
-
0.00 0.00 0.00 1/501 Fixnum#-
|
46
|
-
2.09 0.00 2.09 1/501 Integer#upto
|
47
|
-
0.00 0.00 0.00 1/1 Array#first
|
48
|
-
0.00 0.00 0.00 1/1 Array#length
|
49
|
-
--------------------------------------------------------------------------------
|
50
|
-
2.09 2.09 0.00 61/61 Integer#upto
|
51
|
-
23.89% 23.89% 2.09 2.09 0.00 61 Kernel.sleep
|
52
|
-
--------------------------------------------------------------------------------
|
53
|
-
1.33 1.33 0.00 250862/250862 Integer#upto
|
54
|
-
15.12% 15.12% 1.33 1.33 0.00 250862 Fixnum#%
|
55
|
-
--------------------------------------------------------------------------------
|
56
|
-
1.24 1.24 0.00 250862/250862 Integer#upto
|
57
|
-
14.13% 14.13% 1.24 1.24 0.00 250862 Fixnum#==
|
58
|
-
--------------------------------------------------------------------------------
|
59
|
-
0.02 0.00 0.02 1/1 Object#run_primes
|
60
|
-
0.18% 0.00% 0.02 0.00 0.02 1 Object#make_random_array
|
61
|
-
0.02 0.02 0.00 1/1 Array#each_index
|
62
|
-
0.00 0.00 0.00 1/1 Class#new
|
63
|
-
--------------------------------------------------------------------------------
|
64
|
-
0.02 0.02 0.00 1/1 Object#make_random_array
|
65
|
-
0.18% 0.18% 0.02 0.02 0.00 1 Array#each_index
|
66
|
-
0.00 0.00 0.00 500/500 Kernel.rand
|
67
|
-
0.00 0.00 0.00 500/500 Array#[]=
|
68
|
-
--------------------------------------------------------------------------------
|
69
|
-
0.00 0.00 0.00 500/501 Object#is_prime
|
70
|
-
0.00 0.00 0.00 1/501 Object#find_largest
|
71
|
-
0.00% 0.00% 0.00 0.00 0.00 501 Fixnum#-
|
72
|
-
--------------------------------------------------------------------------------
|
73
|
-
0.00 0.00 0.00 1/1 Kernel.rand
|
74
|
-
0.00% 0.00% 0.00 0.00 0.00 1 Integer#to_int
|
75
|
-
--------------------------------------------------------------------------------
|
76
|
-
0.00 0.00 0.00 1/1 Object#find_largest
|
77
|
-
0.00% 0.00% 0.00 0.00 0.00 1 Array#first
|
78
|
-
--------------------------------------------------------------------------------
|
79
|
-
0.00 0.00 0.00 1/1 Class#new
|
80
|
-
0.00% 0.00% 0.00 0.00 0.00 1 Array#initialize
|
81
|
-
--------------------------------------------------------------------------------
|
82
|
-
0.00 0.00 0.00 1/1 Object#find_largest
|
83
|
-
0.00% 0.00% 0.00 0.00 0.00 1 Array#length
|
84
|
-
--------------------------------------------------------------------------------
|
85
|
-
0.00 0.00 0.00 1/1 Object#make_random_array
|
86
|
-
0.00% 0.00% 0.00 0.00 0.00 1 Class#new
|
87
|
-
0.00 0.00 0.00 1/1 Array#initialize
|
88
|
-
--------------------------------------------------------------------------------
|
89
|
-
0.00 0.00 0.00 61/61 Integer#upto
|
90
|
-
0.00% 0.00% 0.00 0.00 0.00 61 Fixnum#>
|
91
|
-
--------------------------------------------------------------------------------
|
92
|
-
0.00 0.00 0.00 61/61 Integer#upto
|
93
|
-
0.00% 0.00% 0.00 0.00 0.00 61 Array#[]
|
94
|
-
--------------------------------------------------------------------------------
|
95
|
-
0.00 0.00 0.00 500/500 Array#each_index
|
96
|
-
0.00% 0.00% 0.00 0.00 0.00 500 Array#[]=
|
97
|
-
--------------------------------------------------------------------------------
|
98
|
-
0.00 0.00 0.00 500/500 Array#each_index
|
99
|
-
0.00% 0.00% 0.00 0.00 0.00 500 Kernel.rand
|
100
|
-
0.00 0.00 0.00 1/1 Integer#to_int
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
== Overview
|
105
|
-
Dashed lines divide the report into entries, with one entry
|
106
|
-
per method. Entries are sorted by total time which is the
|
107
|
-
time spent in the method plus its children.
|
108
|
-
|
109
|
-
Each entry has a primary line demarked by values in the
|
110
|
-
%total and %self columns. The primary line represents
|
111
|
-
the method being
|
112
|
-
that called this method (parents) while the lines below it
|
113
|
-
are the methods it called (children).
|
114
|
-
|
115
|
-
All values are in seconds. For the primary line, the columns represent:
|
116
|
-
|
117
|
-
%total - The percentage of time spent in this method and its children
|
118
|
-
%self - The percentage of time spent in this method
|
119
|
-
total - The time spent in this method and its children.
|
120
|
-
self - The time spent in this method.
|
121
|
-
children - The time spent in this method's children.
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
The interpretation of method names is:
|
126
|
-
* #toplevel - The root method that calls all other methods
|
127
|
-
*
|
128
|
-
* <
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
1
|
+
= Graph Profiles
|
2
|
+
|
3
|
+
Graph profiles show how long each method runs, which methods call it
|
4
|
+
and which methods it calls.
|
5
|
+
|
6
|
+
As an example, here is the output from running printers_test.rb:
|
7
|
+
|
8
|
+
|
9
|
+
Thread ID: 21277412
|
10
|
+
%total %self total self children calls Name
|
11
|
+
--------------------------------------------------------------------------------
|
12
|
+
100.00% 0.00% 8.77 0.00 8.77 1 #toplevel
|
13
|
+
8.77 0.00 8.77 1/1 Object#run_primes
|
14
|
+
--------------------------------------------------------------------------------
|
15
|
+
8.77 0.00 8.77 1/1 #toplevel
|
16
|
+
100.00% 0.00% 8.77 0.00 8.77 1 Object#run_primes
|
17
|
+
0.02 0.00 0.02 1/1 Object#make_random_array
|
18
|
+
2.09 0.00 2.09 1/1 Object#find_largest
|
19
|
+
6.66 0.00 6.66 1/1 Object#find_primes
|
20
|
+
--------------------------------------------------------------------------------
|
21
|
+
6.63 4.06 2.56 500/501 Object#is_prime
|
22
|
+
2.09 0.00 2.09 1/501 Object#find_largest
|
23
|
+
99.48% 46.34% 8.72 4.06 4.66 501 Integer#upto
|
24
|
+
0.00 0.00 0.00 61/61 Array#[]
|
25
|
+
0.00 0.00 0.00 61/61 Fixnum#>
|
26
|
+
2.09 2.09 0.00 61/61 Kernel.sleep
|
27
|
+
1.24 1.24 0.00 250862/250862 Fixnum#==
|
28
|
+
1.33 1.33 0.00 250862/250862 Fixnum#%
|
29
|
+
--------------------------------------------------------------------------------
|
30
|
+
6.66 0.01 6.64 1/1 Object#find_primes
|
31
|
+
75.93% 0.17% 6.66 0.01 6.64 1 Array#select
|
32
|
+
6.64 0.01 6.63 500/500 Object#is_prime
|
33
|
+
--------------------------------------------------------------------------------
|
34
|
+
6.66 0.00 6.66 1/1 Object#run_primes
|
35
|
+
75.93% 0.00% 6.66 0.00 6.66 1 Object#find_primes
|
36
|
+
6.66 0.01 6.64 1/1 Array#select
|
37
|
+
--------------------------------------------------------------------------------
|
38
|
+
6.64 0.01 6.63 500/500 Array#select
|
39
|
+
75.76% 0.17% 6.64 0.01 6.63 500 Object#is_prime
|
40
|
+
0.00 0.00 0.00 500/501 Fixnum#-
|
41
|
+
6.63 4.06 2.56 500/501 Integer#upto
|
42
|
+
--------------------------------------------------------------------------------
|
43
|
+
2.09 0.00 2.09 1/1 Object#run_primes
|
44
|
+
23.89% 0.00% 2.09 0.00 2.09 1 Object#find_largest
|
45
|
+
0.00 0.00 0.00 1/501 Fixnum#-
|
46
|
+
2.09 0.00 2.09 1/501 Integer#upto
|
47
|
+
0.00 0.00 0.00 1/1 Array#first
|
48
|
+
0.00 0.00 0.00 1/1 Array#length
|
49
|
+
--------------------------------------------------------------------------------
|
50
|
+
2.09 2.09 0.00 61/61 Integer#upto
|
51
|
+
23.89% 23.89% 2.09 2.09 0.00 61 Kernel.sleep
|
52
|
+
--------------------------------------------------------------------------------
|
53
|
+
1.33 1.33 0.00 250862/250862 Integer#upto
|
54
|
+
15.12% 15.12% 1.33 1.33 0.00 250862 Fixnum#%
|
55
|
+
--------------------------------------------------------------------------------
|
56
|
+
1.24 1.24 0.00 250862/250862 Integer#upto
|
57
|
+
14.13% 14.13% 1.24 1.24 0.00 250862 Fixnum#==
|
58
|
+
--------------------------------------------------------------------------------
|
59
|
+
0.02 0.00 0.02 1/1 Object#run_primes
|
60
|
+
0.18% 0.00% 0.02 0.00 0.02 1 Object#make_random_array
|
61
|
+
0.02 0.02 0.00 1/1 Array#each_index
|
62
|
+
0.00 0.00 0.00 1/1 Class#new
|
63
|
+
--------------------------------------------------------------------------------
|
64
|
+
0.02 0.02 0.00 1/1 Object#make_random_array
|
65
|
+
0.18% 0.18% 0.02 0.02 0.00 1 Array#each_index
|
66
|
+
0.00 0.00 0.00 500/500 Kernel.rand
|
67
|
+
0.00 0.00 0.00 500/500 Array#[]=
|
68
|
+
--------------------------------------------------------------------------------
|
69
|
+
0.00 0.00 0.00 500/501 Object#is_prime
|
70
|
+
0.00 0.00 0.00 1/501 Object#find_largest
|
71
|
+
0.00% 0.00% 0.00 0.00 0.00 501 Fixnum#-
|
72
|
+
--------------------------------------------------------------------------------
|
73
|
+
0.00 0.00 0.00 1/1 Kernel.rand
|
74
|
+
0.00% 0.00% 0.00 0.00 0.00 1 Integer#to_int
|
75
|
+
--------------------------------------------------------------------------------
|
76
|
+
0.00 0.00 0.00 1/1 Object#find_largest
|
77
|
+
0.00% 0.00% 0.00 0.00 0.00 1 Array#first
|
78
|
+
--------------------------------------------------------------------------------
|
79
|
+
0.00 0.00 0.00 1/1 Class#new
|
80
|
+
0.00% 0.00% 0.00 0.00 0.00 1 Array#initialize
|
81
|
+
--------------------------------------------------------------------------------
|
82
|
+
0.00 0.00 0.00 1/1 Object#find_largest
|
83
|
+
0.00% 0.00% 0.00 0.00 0.00 1 Array#length
|
84
|
+
--------------------------------------------------------------------------------
|
85
|
+
0.00 0.00 0.00 1/1 Object#make_random_array
|
86
|
+
0.00% 0.00% 0.00 0.00 0.00 1 Class#new
|
87
|
+
0.00 0.00 0.00 1/1 Array#initialize
|
88
|
+
--------------------------------------------------------------------------------
|
89
|
+
0.00 0.00 0.00 61/61 Integer#upto
|
90
|
+
0.00% 0.00% 0.00 0.00 0.00 61 Fixnum#>
|
91
|
+
--------------------------------------------------------------------------------
|
92
|
+
0.00 0.00 0.00 61/61 Integer#upto
|
93
|
+
0.00% 0.00% 0.00 0.00 0.00 61 Array#[]
|
94
|
+
--------------------------------------------------------------------------------
|
95
|
+
0.00 0.00 0.00 500/500 Array#each_index
|
96
|
+
0.00% 0.00% 0.00 0.00 0.00 500 Array#[]=
|
97
|
+
--------------------------------------------------------------------------------
|
98
|
+
0.00 0.00 0.00 500/500 Array#each_index
|
99
|
+
0.00% 0.00% 0.00 0.00 0.00 500 Kernel.rand
|
100
|
+
0.00 0.00 0.00 1/1 Integer#to_int
|
101
|
+
|
102
|
+
|
103
|
+
|
104
|
+
== Overview
|
105
|
+
Dashed lines divide the report into entries, with one entry
|
106
|
+
per method. Entries are sorted by total time which is the
|
107
|
+
time spent in the method plus its children.
|
108
|
+
|
109
|
+
Each entry has a primary line demarked by values in the
|
110
|
+
%total and %self columns. The primary line represents
|
111
|
+
the method being profiled. Lines above it are the methods
|
112
|
+
that called this method (parents) while the lines below it
|
113
|
+
are the methods it called (children).
|
114
|
+
|
115
|
+
All values are in seconds. For the primary line, the columns represent:
|
116
|
+
|
117
|
+
%total - The percentage of time spent in this method and its children
|
118
|
+
%self - The percentage of time spent in this method
|
119
|
+
total - The time spent in this method and its children.
|
120
|
+
self - The time spent in this method.
|
121
|
+
children - The time spent in this method's children.
|
122
|
+
calls - The number of times this method was called.
|
123
|
+
name - The name of the method.
|
124
|
+
|
125
|
+
The interpretation of method names is:
|
126
|
+
* #toplevel - The root method that calls all other methods
|
127
|
+
* MyObject#test - An instance method "test" of the class "MyObject"
|
128
|
+
* <Object:MyObject>#test - The <> characters indicate a singleton method on a singleton class.
|
129
|
+
|
130
|
+
For example, we see that 99.48% of the time was spent in Integer#upto and its children.
|
131
|
+
Of that time, 4.06 seconds was spent in Integer#upto itself and 4.66 in its children.
|
132
|
+
Overall, Integer#upto was called 501 times.
|
133
|
+
|
134
|
+
== Parents
|
135
|
+
In each entry, the lines above the primary line are the methods that
|
136
|
+
called the current method. If the current method is a root method then
|
137
|
+
no parents are shown.
|
138
|
+
|
139
|
+
|
140
|
+
For parent lines, the columns represent:
|
141
|
+
|
142
|
+
total - The time spent in the current method and it children on behalf of the parent method.
|
143
|
+
self - The time spent in this method on behalf of the parent method.
|
144
|
+
children - The time spent in this method's children on behalf of the parent.
|
145
|
+
calls - The number of times the parent method called this child
|
146
|
+
|
147
|
+
Looking at Integer#upto again, we see that it was called 500 times from Object#is_prime
|
148
|
+
and 1 time from find_largest. Of the 8.72 total seconds spent in Integer#upto, 6.63
|
149
|
+
were done for Object#is_prime and 2.09 for Object#find_largest.
|
150
|
+
|
151
|
+
|
152
|
+
== Children
|
153
|
+
In each entry, the lines below the primary line are the methods that
|
154
|
+
the current method called. If the current method is a leaf method then
|
155
|
+
no children are shown.
|
156
|
+
|
157
|
+
For children lines, the columns represent:
|
158
|
+
|
159
|
+
total - The time spent in the child, and its children, on behalf of the current method
|
160
|
+
self - The time spent in the child on behalf of the current method.
|
161
|
+
children - The time spent in the child's children (ie, granchildren) in behalf of the current method
|
162
|
+
calls - The number of times the child method was called by the current method.
|
163
|
+
|
164
|
+
Taking our example of Integer#upto, we see that it called five other methods - Array#[],
|
165
|
+
Fixnum#>, Kernel.sleep, Fixnum#= and Fixnum#%. Looking at Kernel.sleep, we see that
|
166
|
+
its spent 2.09 seconds working for Integer#upto and its children spent 0 time working for
|
167
|
+
Integer#upto. To see the overall time Kernel.sleep took we would have to look up its entry
|
168
|
+
in the graph table.
|
169
|
+
|
170
|
+
|
data/ext/ruby_prof.c
CHANGED
@@ -35,7 +35,7 @@
|
|
35
35
|
#include <node.h>
|
36
36
|
#include <st.h>
|
37
37
|
|
38
|
-
#define PROF_VERSION "0.4.
|
38
|
+
#define PROF_VERSION "0.4.1"
|
39
39
|
|
40
40
|
static VALUE mProf;
|
41
41
|
static VALUE cResult;
|
@@ -734,10 +734,9 @@ prof_method_id(VALUE self)
|
|
734
734
|
/* call-seq:
|
735
735
|
method_name -> string
|
736
736
|
|
737
|
-
Returns the name of this
|
738
|
-
|
739
|
-
|
740
|
-
.method */
|
737
|
+
Returns the name of this method in the format Object#method. Singletons
|
738
|
+
methods will be returned in the format <Object::Object>#method.*/
|
739
|
+
|
741
740
|
static VALUE
|
742
741
|
prof_method_name(VALUE self)
|
743
742
|
{
|
@@ -865,24 +864,27 @@ static int
|
|
865
864
|
collect_methods(st_data_t key, st_data_t value, st_data_t result)
|
866
865
|
{
|
867
866
|
prof_method_t *method = (prof_method_t *) value;
|
868
|
-
VALUE name = method_name(method->klass, method->mid);
|
869
867
|
VALUE hash = (VALUE) result;
|
868
|
+
VALUE base_name = method_name(method->klass, method->mid);
|
869
|
+
VALUE method_key = base_name;
|
870
870
|
|
871
|
-
VALUE existing_value = rb_hash_aref(hash, name);
|
872
|
-
|
873
871
|
/* Sanity check. If we have generated the same method name for another prof_method
|
874
|
-
then we
|
875
|
-
|
876
|
-
|
877
|
-
|
878
|
-
|
872
|
+
then we will overrite a pre-existing MethodInfo object in the table.
|
873
|
+
That would leave the original one unreferenced, which means it will
|
874
|
+
be garbage collected which leads to segmentation faults. */
|
875
|
+
VALUE existing_value = rb_hash_aref(hash, method_key);
|
876
|
+
|
877
|
+
int i = 1;
|
878
|
+
while(existing_value != Qnil)
|
879
879
|
{
|
880
|
-
|
881
|
-
|
882
|
-
|
883
|
-
|
880
|
+
method_key = rb_str_dup(base_name);
|
881
|
+
rb_str_cat2(method_key, "_");
|
882
|
+
rb_str_concat(method_key, rb_inspect(INT2NUM(i)));
|
883
|
+
existing_value = rb_hash_aref(hash, method_key);
|
884
|
+
i++;
|
884
885
|
}
|
885
|
-
|
886
|
+
|
887
|
+
rb_hash_aset(hash, method_key, prof_method_new(method));
|
886
888
|
|
887
889
|
return ST_CONTINUE;
|
888
890
|
}
|
@@ -1098,10 +1100,9 @@ prof_event_hook(rb_event_t event, NODE *node, VALUE self, ID mid, VALUE klass)
|
|
1098
1100
|
{
|
1099
1101
|
/* Can happen on exceptions. The stack gets unwound without RubyProf.stop
|
1100
1102
|
being called. */
|
1101
|
-
VALUE name = method_name(klass, mid);
|
1103
|
+
VALUE name = method_name(klass, mid);
|
1102
1104
|
VALUE message = rb_str_new2("ruby-prof: An error occured when leaving the method %s.\n");
|
1103
1105
|
rb_str_cat2(message, " Perhaps an exception occured in the code being profiled?\n" );
|
1104
|
-
|
1105
1106
|
rb_warn(StringValuePtr(message), StringValuePtr(name));
|
1106
1107
|
|
1107
1108
|
return;
|
@@ -1299,6 +1300,19 @@ prof_set_clock_mode(VALUE self, VALUE val)
|
|
1299
1300
|
/* ========= Profiling ============= */
|
1300
1301
|
|
1301
1302
|
|
1303
|
+
/* call-seq:
|
1304
|
+
running? -> boolean
|
1305
|
+
|
1306
|
+
Returns whether a profile is currently running.*/
|
1307
|
+
static VALUE
|
1308
|
+
prof_running(VALUE self)
|
1309
|
+
{
|
1310
|
+
if (threads_tbl != NULL)
|
1311
|
+
return Qtrue;
|
1312
|
+
else
|
1313
|
+
return Qfalse;
|
1314
|
+
}
|
1315
|
+
|
1302
1316
|
/* call-seq:
|
1303
1317
|
start -> void
|
1304
1318
|
|
@@ -1387,6 +1401,7 @@ Init_ruby_prof()
|
|
1387
1401
|
rb_define_const(mProf, "VERSION", rb_str_new2(PROF_VERSION));
|
1388
1402
|
rb_define_module_function(mProf, "start", prof_start, 0);
|
1389
1403
|
rb_define_module_function(mProf, "stop", prof_stop, 0);
|
1404
|
+
rb_define_module_function(mProf, "running?", prof_running, 0);
|
1390
1405
|
rb_define_module_function(mProf, "profile", prof_profile, 0);
|
1391
1406
|
rb_define_singleton_method(mProf, "clock_mode", prof_get_clock_mode, 0);
|
1392
1407
|
rb_define_singleton_method(mProf, "clock_mode=", prof_set_clock_mode, 1);
|
@@ -45,16 +45,15 @@ module RubyProf
|
|
45
45
|
toplevel = @result.toplevel(thread_id)
|
46
46
|
total_time = toplevel.total_time
|
47
47
|
|
48
|
-
methods = methods.values.sort do |method1, method2|
|
49
|
-
method1.self_time <=> method2.self_time
|
50
|
-
end
|
51
|
-
methods.reverse!
|
52
48
|
|
53
49
|
sum = 0
|
54
50
|
@output << "Thread ID: " << thread_id << "\n"
|
55
51
|
@output << " %self cumulative total self children calls self/call total/call name\n"
|
52
|
+
|
53
|
+
methods.sort.reverse.each do |pair|
|
54
|
+
method_name = pair[0]
|
55
|
+
method = pair[1]
|
56
56
|
|
57
|
-
for method in methods
|
58
57
|
self_percent = (method.self_time / total_time) * 100
|
59
58
|
next if self_percent < @min_percent
|
60
59
|
|
@@ -65,10 +64,10 @@ module RubyProf
|
|
65
64
|
method.total_time, # total
|
66
65
|
method.self_time, # self
|
67
66
|
method.children_time, # children
|
68
|
-
method.called,
|
69
|
-
method.self_time / method.called,
|
70
|
-
method.total_time / method.called,
|
71
|
-
|
67
|
+
method.called, # calls
|
68
|
+
method.self_time / method.called, # self/call
|
69
|
+
method.total_time / method.called, # total/call
|
70
|
+
method_name) # name
|
72
71
|
end
|
73
72
|
end
|
74
73
|
end
|