ruby-prof 0.12.2 → 0.13.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/README.rdoc +2 -2
- data/doc/LICENSE.html +1 -1
- data/doc/README_rdoc.html +2 -2
- data/doc/Rack.html +1 -1
- data/doc/Rack/RubyProf.html +2 -2
- data/doc/RubyProf.html +1 -1
- data/doc/RubyProf/AbstractPrinter.html +1 -1
- data/doc/RubyProf/AggregateCallInfo.html +1 -1
- data/doc/RubyProf/CallInfo.html +1 -1
- data/doc/RubyProf/CallInfoPrinter.html +1 -1
- data/doc/RubyProf/CallInfoVisitor.html +1 -1
- data/doc/RubyProf/CallStackPrinter.html +30 -27
- data/doc/RubyProf/CallTreePrinter.html +1 -1
- data/doc/RubyProf/Cmd.html +1 -1
- data/doc/RubyProf/DotPrinter.html +1 -1
- data/doc/RubyProf/FlatPrinter.html +1 -1
- data/doc/RubyProf/FlatPrinterWithLineNumbers.html +1 -1
- data/doc/RubyProf/GraphHtmlPrinter.html +14 -5
- data/doc/RubyProf/GraphPrinter.html +1 -1
- data/doc/RubyProf/MethodInfo.html +1 -1
- data/doc/RubyProf/MultiPrinter.html +1 -1
- data/doc/RubyProf/Profile.html +1 -1
- data/doc/RubyProf/ProfileTask.html +1 -1
- data/doc/RubyProf/Test.html +1 -1
- data/doc/RubyProf/Thread.html +1 -1
- data/doc/created.rid +11 -10
- data/doc/examples/flat_txt.html +1 -1
- data/doc/examples/graph_txt.html +1 -1
- data/doc/index.html +2 -2
- data/doc/js/darkfish.js +9 -7
- data/doc/table_of_contents.html +1 -1
- data/ext/ruby_prof/extconf.rb +2 -0
- data/ext/ruby_prof/rp_thread.c +24 -8
- data/ext/ruby_prof/rp_thread.h +5 -4
- data/ext/ruby_prof/ruby_prof.c +26 -10
- data/ext/ruby_prof/version.h +3 -3
- data/lib/ruby-prof/printers/call_info_printer.rb +2 -1
- data/lib/ruby-prof/printers/call_stack_printer.rb +7 -4
- data/lib/ruby-prof/printers/flat_printer.rb +1 -0
- data/lib/ruby-prof/printers/graph_html_printer.rb +13 -4
- data/lib/ruby-prof/printers/graph_printer.rb +2 -1
- data/lib/ruby-prof/rack.rb +1 -1
- data/ruby-prof.gemspec +1 -1
- data/test/fiber_test.rb +65 -0
- data/test/measure_process_time_test.rb +2 -2
- data/test/multi_printer_test.rb +4 -2
- data/test/printers_test.rb +2 -0
- data/test/stack_printer_test.rb +2 -2
- data/test/test_helper.rb +2 -0
- metadata +32 -25
@@ -203,7 +203,7 @@ href="../README_rdoc.html">README</a></p>
|
|
203
203
|
|
204
204
|
<footer id="validator-badges">
|
205
205
|
<p><a href="http://validator.w3.org/check/referer">[Validate]</a>
|
206
|
-
<p>Generated by <a href="https://github.com/rdoc/rdoc">RDoc</a> 3.12.
|
206
|
+
<p>Generated by <a href="https://github.com/rdoc/rdoc">RDoc</a> 3.12.1.
|
207
207
|
<p>Generated with the <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish Rdoc Generator</a> 3.
|
208
208
|
</footer>
|
209
209
|
|
@@ -707,7 +707,7 @@
|
|
707
707
|
|
708
708
|
<footer id="validator-badges">
|
709
709
|
<p><a href="http://validator.w3.org/check/referer">[Validate]</a>
|
710
|
-
<p>Generated by <a href="https://github.com/rdoc/rdoc">RDoc</a> 3.12.
|
710
|
+
<p>Generated by <a href="https://github.com/rdoc/rdoc">RDoc</a> 3.12.1.
|
711
711
|
<p>Generated with the <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish Rdoc Generator</a> 3.
|
712
712
|
</footer>
|
713
713
|
|
@@ -401,7 +401,7 @@ base name for the pofile file, defaults to “profile”.</p>
|
|
401
401
|
|
402
402
|
<footer id="validator-badges">
|
403
403
|
<p><a href="http://validator.w3.org/check/referer">[Validate]</a>
|
404
|
-
<p>Generated by <a href="https://github.com/rdoc/rdoc">RDoc</a> 3.12.
|
404
|
+
<p>Generated by <a href="https://github.com/rdoc/rdoc">RDoc</a> 3.12.1.
|
405
405
|
<p>Generated with the <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish Rdoc Generator</a> 3.
|
406
406
|
</footer>
|
407
407
|
|
data/doc/RubyProf/Profile.html
CHANGED
@@ -815,7 +815,7 @@ prof_threads(VALUE self)
|
|
815
815
|
|
816
816
|
<footer id="validator-badges">
|
817
817
|
<p><a href="http://validator.w3.org/check/referer">[Validate]</a>
|
818
|
-
<p>Generated by <a href="https://github.com/rdoc/rdoc">RDoc</a> 3.12.
|
818
|
+
<p>Generated by <a href="https://github.com/rdoc/rdoc">RDoc</a> 3.12.1.
|
819
819
|
<p>Generated with the <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish Rdoc Generator</a> 3.
|
820
820
|
</footer>
|
821
821
|
|
@@ -526,7 +526,7 @@ rake profile TESTOPTS="--runner=fox" # use the fox test runner</pre>
|
|
526
526
|
|
527
527
|
<footer id="validator-badges">
|
528
528
|
<p><a href="http://validator.w3.org/check/referer">[Validate]</a>
|
529
|
-
<p>Generated by <a href="https://github.com/rdoc/rdoc">RDoc</a> 3.12.
|
529
|
+
<p>Generated by <a href="https://github.com/rdoc/rdoc">RDoc</a> 3.12.1.
|
530
530
|
<p>Generated with the <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish Rdoc Generator</a> 3.
|
531
531
|
</footer>
|
532
532
|
|
data/doc/RubyProf/Test.html
CHANGED
@@ -572,7 +572,7 @@
|
|
572
572
|
|
573
573
|
<footer id="validator-badges">
|
574
574
|
<p><a href="http://validator.w3.org/check/referer">[Validate]</a>
|
575
|
-
<p>Generated by <a href="https://github.com/rdoc/rdoc">RDoc</a> 3.12.
|
575
|
+
<p>Generated by <a href="https://github.com/rdoc/rdoc">RDoc</a> 3.12.1.
|
576
576
|
<p>Generated with the <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish Rdoc Generator</a> 3.
|
577
577
|
</footer>
|
578
578
|
|
data/doc/RubyProf/Thread.html
CHANGED
@@ -256,7 +256,7 @@
|
|
256
256
|
|
257
257
|
<footer id="validator-badges">
|
258
258
|
<p><a href="http://validator.w3.org/check/referer">[Validate]</a>
|
259
|
-
<p>Generated by <a href="https://github.com/rdoc/rdoc">RDoc</a> 3.12.
|
259
|
+
<p>Generated by <a href="https://github.com/rdoc/rdoc">RDoc</a> 3.12.1.
|
260
260
|
<p>Generated with the <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish Rdoc Generator</a> 3.
|
261
261
|
</footer>
|
262
262
|
|
data/doc/created.rid
CHANGED
@@ -1,5 +1,6 @@
|
|
1
|
-
|
1
|
+
Sun, 10 Mar 2013 11:08:41 +0100
|
2
2
|
bin/ruby-prof Sat, 02 Feb 2013 10:23:19 +0100
|
3
|
+
bin/ruby-prof-check-trace Sun, 10 Mar 2013 10:57:14 +0100
|
3
4
|
examples/flat.txt Tue, 29 Jan 2013 16:43:39 +0100
|
4
5
|
examples/graph.txt Tue, 29 Jan 2013 16:43:39 +0100
|
5
6
|
examples/graph.html Tue, 29 Jan 2013 16:43:39 +0100
|
@@ -10,22 +11,22 @@ lib/ruby-prof/call_info_visitor.rb Tue, 29 Jan 2013 16:44:27 +0100
|
|
10
11
|
lib/ruby-prof/compatibility.rb Sun, 03 Feb 2013 12:16:49 +0100
|
11
12
|
lib/ruby-prof/method_info.rb Tue, 29 Jan 2013 16:44:27 +0100
|
12
13
|
lib/ruby-prof/printers/abstract_printer.rb Tue, 29 Jan 2013 16:43:39 +0100
|
13
|
-
lib/ruby-prof/printers/call_info_printer.rb
|
14
|
-
lib/ruby-prof/printers/call_stack_printer.rb
|
14
|
+
lib/ruby-prof/printers/call_info_printer.rb Sun, 10 Mar 2013 10:57:14 +0100
|
15
|
+
lib/ruby-prof/printers/call_stack_printer.rb Sun, 10 Mar 2013 10:57:14 +0100
|
15
16
|
lib/ruby-prof/printers/call_tree_printer.rb Tue, 29 Jan 2013 16:43:39 +0100
|
16
17
|
lib/ruby-prof/printers/dot_printer.rb Tue, 29 Jan 2013 16:44:27 +0100
|
17
|
-
lib/ruby-prof/printers/flat_printer.rb
|
18
|
+
lib/ruby-prof/printers/flat_printer.rb Sun, 10 Mar 2013 10:57:14 +0100
|
18
19
|
lib/ruby-prof/printers/flat_printer_with_line_numbers.rb Tue, 29 Jan 2013 16:44:27 +0100
|
19
|
-
lib/ruby-prof/printers/graph_html_printer.rb
|
20
|
-
lib/ruby-prof/printers/graph_printer.rb
|
20
|
+
lib/ruby-prof/printers/graph_html_printer.rb Sun, 10 Mar 2013 10:57:14 +0100
|
21
|
+
lib/ruby-prof/printers/graph_printer.rb Sun, 10 Mar 2013 10:57:14 +0100
|
21
22
|
lib/ruby-prof/printers/multi_printer.rb Tue, 29 Jan 2013 16:43:39 +0100
|
22
23
|
lib/ruby-prof/profile.rb Tue, 29 Jan 2013 16:44:27 +0100
|
23
|
-
lib/ruby-prof/rack.rb
|
24
|
+
lib/ruby-prof/rack.rb Sun, 10 Mar 2013 10:56:55 +0100
|
24
25
|
lib/ruby-prof/task.rb Tue, 29 Jan 2013 16:43:39 +0100
|
25
26
|
lib/ruby-prof/test.rb Tue, 29 Jan 2013 16:43:39 +0100
|
26
27
|
lib/ruby-prof/thread.rb Tue, 29 Jan 2013 16:44:27 +0100
|
27
28
|
lib/unprof.rb Tue, 29 Jan 2013 16:43:39 +0100
|
28
|
-
ext/ruby_prof/ruby_prof.c Sun,
|
29
|
-
ext/ruby_prof/version.h
|
30
|
-
README.rdoc
|
29
|
+
ext/ruby_prof/ruby_prof.c Sun, 10 Mar 2013 10:57:14 +0100
|
30
|
+
ext/ruby_prof/version.h Sun, 10 Mar 2013 11:07:12 +0100
|
31
|
+
README.rdoc Sun, 10 Mar 2013 10:56:55 +0100
|
31
32
|
LICENSE Tue, 29 Jan 2013 16:43:39 +0100
|
data/doc/examples/flat_txt.html
CHANGED
@@ -185,7 +185,7 @@ total time of 8.72 seconds.</p>
|
|
185
185
|
|
186
186
|
<footer id="validator-badges">
|
187
187
|
<p><a href="http://validator.w3.org/check/referer">[Validate]</a>
|
188
|
-
<p>Generated by <a href="https://github.com/rdoc/rdoc">RDoc</a> 3.12.
|
188
|
+
<p>Generated by <a href="https://github.com/rdoc/rdoc">RDoc</a> 3.12.1.
|
189
189
|
<p>Generated with the <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish Rdoc Generator</a> 3.
|
190
190
|
</footer>
|
191
191
|
|
data/doc/examples/graph_txt.html
CHANGED
@@ -299,7 +299,7 @@ in the graph table.</p>
|
|
299
299
|
|
300
300
|
<footer id="validator-badges">
|
301
301
|
<p><a href="http://validator.w3.org/check/referer">[Validate]</a>
|
302
|
-
<p>Generated by <a href="https://github.com/rdoc/rdoc">RDoc</a> 3.12.
|
302
|
+
<p>Generated by <a href="https://github.com/rdoc/rdoc">RDoc</a> 3.12.1.
|
303
303
|
<p>Generated with the <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish Rdoc Generator</a> 3.
|
304
304
|
</footer>
|
305
305
|
|
data/doc/index.html
CHANGED
@@ -445,7 +445,7 @@ other printers to create several reports in one profiling run</p>
|
|
445
445
|
<p>To use a printer:</p>
|
446
446
|
|
447
447
|
<pre class="ruby"><span class="ruby-operator">...</span>
|
448
|
-
<span class="ruby-identifier">result</span> = <span class="ruby-constant">RubyProf</span>.<span class="ruby-identifier">
|
448
|
+
<span class="ruby-identifier">result</span> = <span class="ruby-constant">RubyProf</span>.<span class="ruby-identifier">stop</span>
|
449
449
|
<span class="ruby-identifier">printer</span> = <span class="ruby-constant">RubyProf</span><span class="ruby-operator">::</span><span class="ruby-constant">GraphPrinter</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">result</span>)
|
450
450
|
<span class="ruby-identifier">printer</span>.<span class="ruby-identifier">print</span>(<span class="ruby-constant">STDOUT</span>, :<span class="ruby-identifier">min_percent</span> =<span class="ruby-operator">></span> <span class="ruby-value">2</span>)
|
451
451
|
</pre>
|
@@ -633,7 +633,7 @@ href="http://groups.google.com/group/ruby-optimization">groups.google.com/group/
|
|
633
633
|
|
634
634
|
<footer id="validator-badges">
|
635
635
|
<p><a href="http://validator.w3.org/check/referer">[Validate]</a>
|
636
|
-
<p>Generated by <a href="https://github.com/rdoc/rdoc">RDoc</a> 3.12.
|
636
|
+
<p>Generated by <a href="https://github.com/rdoc/rdoc">RDoc</a> 3.12.1.
|
637
637
|
<p>Generated with the <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish Rdoc Generator</a> 3.
|
638
638
|
</footer>
|
639
639
|
|
data/doc/js/darkfish.js
CHANGED
@@ -109,13 +109,15 @@ function hookSearch() {
|
|
109
109
|
function highlightTarget( anchor ) {
|
110
110
|
console.debug( "Highlighting target '%s'.", anchor );
|
111
111
|
|
112
|
-
$("a[name
|
113
|
-
if (
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
112
|
+
$("a[name]").each( function() {
|
113
|
+
if ( $(this).attr("name") == anchor ) {
|
114
|
+
if ( !$(this).parent().parent().hasClass('target-section') ) {
|
115
|
+
console.debug( "Wrapping the target-section" );
|
116
|
+
$('div.method-detail').unwrap( 'div.target-section' );
|
117
|
+
$(this).parent().wrap( '<div class="target-section"></div>' );
|
118
|
+
} else {
|
119
|
+
console.debug( "Already wrapped." );
|
120
|
+
}
|
119
121
|
}
|
120
122
|
});
|
121
123
|
};
|
data/doc/table_of_contents.html
CHANGED
@@ -456,7 +456,7 @@
|
|
456
456
|
|
457
457
|
<footer id="validator-badges">
|
458
458
|
<p><a href="http://validator.w3.org/check/referer">[Validate]</a>
|
459
|
-
<p>Generated by <a href="https://github.com/rdoc/rdoc">RDoc</a> 3.12.
|
459
|
+
<p>Generated by <a href="https://github.com/rdoc/rdoc">RDoc</a> 3.12.1.
|
460
460
|
<p>Generated with the <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish Rdoc Generator</a> 3.
|
461
461
|
</footer>
|
462
462
|
|
data/ext/ruby_prof/extconf.rb
CHANGED
data/ext/ruby_prof/rp_thread.c
CHANGED
@@ -65,10 +65,13 @@ prof_thread_mark(thread_data_t *thread)
|
|
65
65
|
|
66
66
|
if (thread->methods != Qnil)
|
67
67
|
rb_gc_mark(thread->methods);
|
68
|
-
|
68
|
+
|
69
69
|
if (thread->thread_id != Qnil)
|
70
70
|
rb_gc_mark(thread->thread_id);
|
71
71
|
|
72
|
+
if (thread->fiber_id != Qnil)
|
73
|
+
rb_gc_mark(thread->fiber_id);
|
74
|
+
|
72
75
|
st_foreach(thread->method_table, mark_methods, 0);
|
73
76
|
}
|
74
77
|
|
@@ -119,20 +122,20 @@ threads_table_free(st_table *table)
|
|
119
122
|
}
|
120
123
|
|
121
124
|
size_t
|
122
|
-
threads_table_insert(prof_profile_t* profile, VALUE
|
125
|
+
threads_table_insert(prof_profile_t* profile, VALUE fiber, thread_data_t *thread_data)
|
123
126
|
{
|
124
127
|
/* Its too slow to key on the real thread id so just typecast thread instead. */
|
125
|
-
return st_insert(profile->threads_tbl, (st_data_t)
|
128
|
+
return st_insert(profile->threads_tbl, (st_data_t) fiber, (st_data_t) thread_data);
|
126
129
|
}
|
127
130
|
|
128
131
|
thread_data_t *
|
129
|
-
threads_table_lookup(prof_profile_t* profile, VALUE thread_id)
|
132
|
+
threads_table_lookup(prof_profile_t* profile, VALUE thread_id, VALUE fiber_id)
|
130
133
|
{
|
131
134
|
thread_data_t* result;
|
132
135
|
st_data_t val;
|
133
136
|
|
134
137
|
/* Its too slow to key on the real thread id so just typecast thread instead. */
|
135
|
-
if (st_lookup(profile->threads_tbl, (st_data_t)
|
138
|
+
if (st_lookup(profile->threads_tbl, (st_data_t) fiber_id, &val))
|
136
139
|
{
|
137
140
|
result = (thread_data_t *) val;
|
138
141
|
}
|
@@ -140,21 +143,22 @@ threads_table_lookup(prof_profile_t* profile, VALUE thread_id)
|
|
140
143
|
{
|
141
144
|
result = thread_data_create();
|
142
145
|
result->thread_id = thread_id;
|
146
|
+
result->fiber_id = fiber_id;
|
143
147
|
|
144
148
|
/* Insert the table */
|
145
|
-
threads_table_insert(profile,
|
149
|
+
threads_table_insert(profile, fiber_id, result);
|
146
150
|
}
|
147
151
|
return result;
|
148
152
|
}
|
149
153
|
|
150
154
|
thread_data_t *
|
151
|
-
switch_thread(void* prof, VALUE thread_id)
|
155
|
+
switch_thread(void* prof, VALUE thread_id, VALUE fiber_id)
|
152
156
|
{
|
153
157
|
prof_profile_t* profile = (prof_profile_t*)prof;
|
154
158
|
double measurement = profile->measurer->measure();
|
155
159
|
|
156
160
|
/* Get new thread information. */
|
157
|
-
thread_data_t *thread_data = threads_table_lookup(profile, thread_id);
|
161
|
+
thread_data_t *thread_data = threads_table_lookup(profile, thread_id, fiber_id);
|
158
162
|
|
159
163
|
/* Get current frame for this thread */
|
160
164
|
prof_frame_t *frame = prof_stack_peek(thread_data->stack);
|
@@ -225,6 +229,17 @@ prof_thread_id(VALUE self)
|
|
225
229
|
return thread->thread_id;
|
226
230
|
}
|
227
231
|
|
232
|
+
/* call-seq:
|
233
|
+
fiber_id -> number
|
234
|
+
|
235
|
+
Returns the fiber id of this thread. */
|
236
|
+
static VALUE
|
237
|
+
prof_fiber_id(VALUE self)
|
238
|
+
{
|
239
|
+
thread_data_t* thread = prof_get_thread(self);
|
240
|
+
return thread->fiber_id;
|
241
|
+
}
|
242
|
+
|
228
243
|
/* call-seq:
|
229
244
|
methods -> Array of MethodInfo
|
230
245
|
|
@@ -248,5 +263,6 @@ void rp_init_thread()
|
|
248
263
|
rb_undef_method(CLASS_OF(cRpThread), "new");
|
249
264
|
|
250
265
|
rb_define_method(cRpThread, "id", prof_thread_id, 0);
|
266
|
+
rb_define_method(cRpThread, "fiber_id", prof_fiber_id, 0);
|
251
267
|
rb_define_method(cRpThread, "methods", prof_thread_methods, 0);
|
252
268
|
}
|
data/ext/ruby_prof/rp_thread.h
CHANGED
@@ -5,18 +5,19 @@
|
|
5
5
|
#define __RP_THREAD__
|
6
6
|
|
7
7
|
/* Profiling information for a thread. */
|
8
|
-
typedef struct
|
8
|
+
typedef struct
|
9
9
|
{
|
10
|
-
|
11
|
-
|
10
|
+
VALUE object; /* Cache to wrapped object */
|
11
|
+
VALUE methods; /* Array of RubyProf::MethodInfo */
|
12
12
|
VALUE thread_id; /* Thread id */
|
13
|
+
VALUE fiber_id; /* Fiber id */
|
13
14
|
st_table* method_table; /* Methods called in the thread */
|
14
15
|
prof_stack_t* stack; /* Stack of frames */
|
15
16
|
} thread_data_t;
|
16
17
|
|
17
18
|
void rp_init_thread();
|
18
19
|
st_table * threads_table_create();
|
19
|
-
thread_data_t* switch_thread(void* prof, VALUE thread_id);
|
20
|
+
thread_data_t* switch_thread(void* prof, VALUE thread_id, VALUE fiber_id);
|
20
21
|
void threads_table_free(st_table *table);
|
21
22
|
VALUE prof_thread_wrap(thread_data_t *thread);
|
22
23
|
void prof_thread_mark(thread_data_t *thread);
|
data/ext/ruby_prof/ruby_prof.c
CHANGED
@@ -123,13 +123,13 @@ static prof_method_t*
|
|
123
123
|
static int
|
124
124
|
pop_frames(st_data_t key, st_data_t value, st_data_t data)
|
125
125
|
{
|
126
|
-
VALUE
|
126
|
+
VALUE fiber_id = (VALUE)key;
|
127
127
|
thread_data_t* thread_data = (thread_data_t *) value;
|
128
128
|
prof_profile_t* profile = (prof_profile_t*) data;
|
129
129
|
double measurement = profile->measurer->measure();
|
130
130
|
|
131
|
-
if (!profile->last_thread_data || profile->last_thread_data->
|
132
|
-
thread_data = switch_thread(profile,
|
131
|
+
if (!profile->last_thread_data || profile->last_thread_data->fiber_id != fiber_id)
|
132
|
+
thread_data = switch_thread(profile, Qnil, fiber_id);
|
133
133
|
else
|
134
134
|
thread_data = profile->last_thread_data;
|
135
135
|
|
@@ -155,10 +155,16 @@ static void
|
|
155
155
|
prof_trace(prof_profile_t* profile, rb_event_flag_t event, NODE *node, ID mid, VALUE klass, double measurement)
|
156
156
|
#endif
|
157
157
|
{
|
158
|
-
static VALUE
|
158
|
+
static VALUE last_fiber_id = Qnil;
|
159
159
|
|
160
160
|
VALUE thread = rb_thread_current();
|
161
161
|
VALUE thread_id = rb_obj_id(thread);
|
162
|
+
#if defined(HAVE_RB_FIBER_CURRENT)
|
163
|
+
VALUE fiber = rb_fiber_current();
|
164
|
+
VALUE fiber_id = rb_obj_id(fiber);
|
165
|
+
#else
|
166
|
+
VALUE fiber_id = thread_id;
|
167
|
+
#endif
|
162
168
|
const char* class_name = NULL;
|
163
169
|
const char* method_name = rb_id2name(mid);
|
164
170
|
const char* source_file = rb_sourcefile();
|
@@ -171,15 +177,16 @@ prof_trace(prof_profile_t* profile, rb_event_flag_t event, NODE *node, ID mid, V
|
|
171
177
|
|
172
178
|
class_name = rb_class2name(klass);
|
173
179
|
|
174
|
-
if (
|
180
|
+
if (last_fiber_id != fiber_id)
|
175
181
|
{
|
176
182
|
fprintf(trace_file, "\n");
|
177
183
|
}
|
178
184
|
|
179
|
-
fprintf(trace_file, "%
|
180
|
-
(unsigned
|
185
|
+
fprintf(trace_file, "%2lu:%2lu:%2ums %-8s %s:%2d %s#%s\n",
|
186
|
+
(unsigned long) thread_id, (unsigned long) fiber_id, (unsigned int) measurement*1000,
|
187
|
+
event_name, source_file, source_line, class_name, method_name);
|
181
188
|
fflush(trace_file);
|
182
|
-
|
189
|
+
last_fiber_id = fiber_id;
|
183
190
|
}
|
184
191
|
|
185
192
|
#ifdef RUBY_VM
|
@@ -198,6 +205,8 @@ prof_event_hook(rb_event_flag_t event, NODE *node, VALUE self, ID mid, VALUE kla
|
|
198
205
|
|
199
206
|
VALUE thread = Qnil;
|
200
207
|
VALUE thread_id = Qnil;
|
208
|
+
VALUE fiber = Qnil;
|
209
|
+
VALUE fiber_id = Qnil;
|
201
210
|
thread_data_t* thread_data = NULL;
|
202
211
|
prof_frame_t *frame = NULL;
|
203
212
|
double measurement;
|
@@ -230,6 +239,13 @@ prof_event_hook(rb_event_flag_t event, NODE *node, VALUE self, ID mid, VALUE kla
|
|
230
239
|
/* Get the current thread information. */
|
231
240
|
thread = rb_thread_current();
|
232
241
|
thread_id = rb_obj_id(thread);
|
242
|
+
#if defined(HAVE_RB_FIBER_CURRENT)
|
243
|
+
fiber = rb_fiber_current();
|
244
|
+
fiber_id = rb_obj_id(fiber);
|
245
|
+
#else
|
246
|
+
fiber = thread;
|
247
|
+
fiber_id = thread_id;
|
248
|
+
#endif
|
233
249
|
|
234
250
|
if (st_lookup(profile->exclude_threads_tbl, (st_data_t) thread_id, 0))
|
235
251
|
{
|
@@ -237,8 +253,8 @@ prof_event_hook(rb_event_flag_t event, NODE *node, VALUE self, ID mid, VALUE kla
|
|
237
253
|
}
|
238
254
|
|
239
255
|
/* Was there a context switch? */
|
240
|
-
if (!profile->last_thread_data || profile->last_thread_data->
|
241
|
-
thread_data = switch_thread(profile, thread_id);
|
256
|
+
if (!profile->last_thread_data || profile->last_thread_data->fiber_id != fiber_id)
|
257
|
+
thread_data = switch_thread(profile, thread_id, fiber_id);
|
242
258
|
else
|
243
259
|
thread_data = profile->last_thread_data;
|
244
260
|
|
data/ext/ruby_prof/version.h
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
/* Copyright (C) 2005-2013 Shugo Maeda <shugo@ruby-lang.org> and Charlie Savage <cfis@savagexi.com>
|
2
2
|
Please see the LICENSE file for copyright and distribution information */
|
3
3
|
|
4
|
-
#define RUBY_PROF_VERSION "0.
|
4
|
+
#define RUBY_PROF_VERSION "0.13.0" // as a string, for easy parsing from rake files
|
5
5
|
#define RUBY_PROF_VERSION_MAJ 0
|
6
|
-
#define RUBY_PROF_VERSION_MIN
|
7
|
-
#define RUBY_PROF_VERSION_MIC
|
6
|
+
#define RUBY_PROF_VERSION_MIN 13
|
7
|
+
#define RUBY_PROF_VERSION_MIC 0
|
@@ -12,6 +12,7 @@ module RubyProf
|
|
12
12
|
|
13
13
|
def print_header(thread)
|
14
14
|
@output << "Thread ID: #{thread.id}\n"
|
15
|
+
@output << "Fiber ID: #{thread.fiber_id}\n"
|
15
16
|
@output << "Total Time: #{thread.total_time}\n"
|
16
17
|
@output << "Sort by: #{sort_method}\n"
|
17
18
|
@output << "\n"
|
@@ -37,4 +38,4 @@ module RubyProf
|
|
37
38
|
end
|
38
39
|
end
|
39
40
|
end
|
40
|
-
end
|
41
|
+
end
|
@@ -49,9 +49,12 @@ module RubyProf
|
|
49
49
|
end
|
50
50
|
|
51
51
|
@result.threads.each do |thread|
|
52
|
-
@current_thread_id = thread.
|
52
|
+
@current_thread_id = thread.fiber_id
|
53
53
|
@overall_time = thread.total_time
|
54
|
-
|
54
|
+
thread_info = "Thread: #{thread.id}"
|
55
|
+
thread_info << ", Fiber: #{thread.fiber_id}" unless thread.id == thread.fiber_id
|
56
|
+
thread_info << " (#{"%4.2f%%" % ((@overall_time/@overall_threads_time)*100)} ~ #{@overall_time})"
|
57
|
+
@output.print "<div class=\"thread\">#{thread_info}</div>"
|
55
58
|
@output.print "<ul name=\"thread\">"
|
56
59
|
thread.methods.each do |m|
|
57
60
|
# $stderr.print m.dump
|
@@ -195,14 +198,14 @@ module RubyProf
|
|
195
198
|
@output.puts "<title>#{h title}</title>"
|
196
199
|
print_css
|
197
200
|
print_java_script
|
198
|
-
@output.puts '</head><body>'
|
201
|
+
@output.puts '</head><body><div style="display: inline-block;">'
|
199
202
|
print_title_bar
|
200
203
|
print_commands
|
201
204
|
print_help
|
202
205
|
end
|
203
206
|
|
204
207
|
def print_footer
|
205
|
-
@output.puts '<div id="sentinel"></div></body></html>'
|
208
|
+
@output.puts '<div id="sentinel"></div></div></body></html>'
|
206
209
|
end
|
207
210
|
|
208
211
|
def print_css
|