ruby-prof 0.4.1 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (57) hide show
  1. data/CHANGES +30 -0
  2. data/README +65 -25
  3. data/Rakefile +33 -32
  4. data/bin/ruby-prof +100 -83
  5. data/examples/graph.html +65 -69
  6. data/ext/measure_allocations.h +43 -0
  7. data/ext/measure_cpu_time.h +138 -0
  8. data/ext/measure_process_time.h +41 -0
  9. data/ext/measure_wall_time.h +42 -0
  10. data/ext/ruby_prof.c +737 -653
  11. data/lib/ruby-prof.rb +41 -38
  12. data/lib/ruby-prof/abstract_printer.rb +42 -0
  13. data/lib/ruby-prof/call_tree_printer.rb +69 -0
  14. data/lib/ruby-prof/flat_printer.rb +78 -75
  15. data/lib/ruby-prof/graph_html_printer.rb +241 -228
  16. data/lib/ruby-prof/graph_printer.rb +160 -141
  17. data/lib/ruby-prof/profile_test_case.rb +80 -0
  18. data/lib/ruby-prof/rails_plugin/ruby-prof/init.rb +6 -0
  19. data/lib/ruby-prof/rails_plugin/ruby-prof/lib/profiling.rb +52 -0
  20. data/lib/ruby-prof/task.rb +147 -0
  21. data/test/basic_test.rb +65 -35
  22. data/test/duplicate_names_test.rb +20 -24
  23. data/test/gc.log +5 -0
  24. data/test/measure_mode_test.rb +79 -0
  25. data/test/module_test.rb +31 -18
  26. data/test/no_method_class_test.rb +14 -0
  27. data/test/prime1.rb +17 -0
  28. data/test/prime2.rb +26 -0
  29. data/test/prime3.rb +17 -0
  30. data/test/prime_test.rb +10 -10
  31. data/test/printers_test.rb +14 -12
  32. data/test/profile_unit_test.rb +24 -0
  33. data/test/recursive_test.rb +105 -17
  34. data/test/singleton_test.rb +38 -0
  35. data/test/start_test.rb +24 -0
  36. data/test/test_helper.rb +33 -29
  37. data/test/test_suite.rb +10 -2
  38. data/test/thread_test.rb +123 -17
  39. data/test/timing_test.rb +70 -29
  40. metadata +28 -30
  41. data/doc/created.rid +0 -1
  42. data/doc/files/LICENSE.html +0 -0
  43. data/doc/files/README.html +0 -376
  44. data/doc/files/bin/ruby-prof.html +0 -143
  45. data/doc/files/examples/flat_txt.html +0 -179
  46. data/doc/files/examples/graph_html.html +0 -948
  47. data/doc/files/examples/graph_txt.html +0 -297
  48. data/doc/files/ext/ruby_prof_c.html +0 -101
  49. data/doc/files/lib/ruby-prof/flat_printer_rb.html +0 -101
  50. data/doc/files/lib/ruby-prof/graph_html_printer_rb.html +0 -108
  51. data/doc/files/lib/ruby-prof/graph_printer_rb.html +0 -101
  52. data/doc/files/lib/ruby-prof/profiletask_rb.html +0 -109
  53. data/doc/files/lib/ruby-prof_rb.html +0 -111
  54. data/doc/files/lib/unprof_rb.html +0 -108
  55. data/doc/rdoc-style.css +0 -208
  56. data/lib/ruby-prof/profiletask.rb +0 -150
  57. data/test/clock_mode_test.rb +0 -73
@@ -1,6 +1,5 @@
1
1
  <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
2
2
  <html>
3
- <!-- :nodoc: -->
4
3
  <head>
5
4
  <style media="all" type="text/css">
6
5
  table {
@@ -55,7 +54,7 @@
55
54
  of control through a program and which methods take the most time.</p>
56
55
  <p>Below is the output from running printers_test.rb reproduced in HTML. </p>
57
56
  <p>Profile Report</p>
58
- <!-- Threads Table -->
57
+
59
58
  <table>
60
59
  <tr>
61
60
  <th>Thread ID</th>
@@ -66,7 +65,7 @@ of control through a program and which methods take the most time.</p>
66
65
  <td>8.766</td>
67
66
  </tr>
68
67
  </table>
69
- <!-- Methods Tables -->
68
+
70
69
  <h2><a name="21277412">Thread 21277412</a></h2>
71
70
  <table>
72
71
  <tr>
@@ -78,7 +77,7 @@ of control through a program and which methods take the most time.</p>
78
77
  <th> Calls</th>
79
78
  <th>Name</th>
80
79
  </tr>
81
- <!-- Parents -->
80
+
82
81
  <tr class="method">
83
82
  <td> 100.00%</td>
84
83
  <td> 0.00%</td>
@@ -88,7 +87,7 @@ of control through a program and which methods take the most time.</p>
88
87
  <td> 1</td>
89
88
  <td><a name="_toplevel_21277412">#toplevel</a></td>
90
89
  </tr>
91
- <!-- Children -->
90
+
92
91
  <tr>
93
92
  <td>&nbsp;</td>
94
93
  <td>&nbsp;</td>
@@ -98,11 +97,11 @@ of control through a program and which methods take the most time.</p>
98
97
  <td> 1/1</td>
99
98
  <td><a href="#Object_run_primes_21277412">Object#run_primes</a></td>
100
99
  </tr>
101
- <!-- Create divider row -->
100
+
102
101
  <tr class="break">
103
102
  <td colspan="7"></td>
104
103
  </tr>
105
- <!-- Parents -->
104
+
106
105
  <tr>
107
106
  <td>&nbsp;</td>
108
107
  <td>&nbsp;</td>
@@ -121,7 +120,7 @@ of control through a program and which methods take the most time.</p>
121
120
  <td> 1</td>
122
121
  <td><a name="Object_run_primes_21277412">Object#run_primes</a></td>
123
122
  </tr>
124
- <!-- Children -->
123
+
125
124
  <tr>
126
125
  <td>&nbsp;</td>
127
126
  <td>&nbsp;</td>
@@ -149,11 +148,11 @@ of control through a program and which methods take the most time.</p>
149
148
  <td> 1/1</td>
150
149
  <td><a href="#Object_find_primes_21277412">Object#find_primes</a></td>
151
150
  </tr>
152
- <!-- Create divider row -->
151
+
153
152
  <tr class="break">
154
153
  <td colspan="7"></td>
155
154
  </tr>
156
- <!-- Parents -->
155
+
157
156
  <tr>
158
157
  <td>&nbsp;</td>
159
158
  <td>&nbsp;</td>
@@ -181,7 +180,7 @@ of control through a program and which methods take the most time.</p>
181
180
  <td> 501</td>
182
181
  <td><a name="Integer_upto_21277412">Integer#upto</a></td>
183
182
  </tr>
184
- <!-- Children -->
183
+
185
184
  <tr>
186
185
  <td>&nbsp;</td>
187
186
  <td>&nbsp;</td>
@@ -227,11 +226,11 @@ of control through a program and which methods take the most time.</p>
227
226
  <td> 250862/250862</td>
228
227
  <td><a href="#Fixnum_%_21277412">Fixnum#%</a></td>
229
228
  </tr>
230
- <!-- Create divider row -->
229
+
231
230
  <tr class="break">
232
231
  <td colspan="7"></td>
233
232
  </tr>
234
- <!-- Parents -->
233
+
235
234
  <tr>
236
235
  <td>&nbsp;</td>
237
236
  <td>&nbsp;</td>
@@ -250,7 +249,7 @@ of control through a program and which methods take the most time.</p>
250
249
  <td> 1</td>
251
250
  <td><a name="Array_select_21277412">Array#select</a></td>
252
251
  </tr>
253
- <!-- Children -->
252
+
254
253
  <tr>
255
254
  <td>&nbsp;</td>
256
255
  <td>&nbsp;</td>
@@ -260,11 +259,11 @@ of control through a program and which methods take the most time.</p>
260
259
  <td> 500/500</td>
261
260
  <td><a href="#Object_is_prime_21277412">Object#is_prime</a></td>
262
261
  </tr>
263
- <!-- Create divider row -->
262
+
264
263
  <tr class="break">
265
264
  <td colspan="7"></td>
266
265
  </tr>
267
- <!-- Parents -->
266
+
268
267
  <tr>
269
268
  <td>&nbsp;</td>
270
269
  <td>&nbsp;</td>
@@ -283,7 +282,6 @@ of control through a program and which methods take the most time.</p>
283
282
  <td> 1</td>
284
283
  <td><a name="Object_find_primes_21277412">Object#find_primes</a></td>
285
284
  </tr>
286
- <!-- Children -->
287
285
  <tr>
288
286
  <td>&nbsp;</td>
289
287
  <td>&nbsp;</td>
@@ -293,11 +291,10 @@ of control through a program and which methods take the most time.</p>
293
291
  <td> 1/1</td>
294
292
  <td><a href="#Array_select_21277412">Array#select</a></td>
295
293
  </tr>
296
- <!-- Create divider row -->
297
294
  <tr class="break">
298
295
  <td colspan="7"></td>
299
296
  </tr>
300
- <!-- Parents -->
297
+
301
298
  <tr>
302
299
  <td>&nbsp;</td>
303
300
  <td>&nbsp;</td>
@@ -316,7 +313,7 @@ of control through a program and which methods take the most time.</p>
316
313
  <td> 500</td>
317
314
  <td><a name="Object_is_prime_21277412">Object#is_prime</a></td>
318
315
  </tr>
319
- <!-- Children -->
316
+
320
317
  <tr>
321
318
  <td>&nbsp;</td>
322
319
  <td>&nbsp;</td>
@@ -335,11 +332,11 @@ of control through a program and which methods take the most time.</p>
335
332
  <td> 500/501</td>
336
333
  <td><a href="#Integer_upto_21277412">Integer#upto</a></td>
337
334
  </tr>
338
- <!-- Create divider row -->
335
+
339
336
  <tr class="break">
340
337
  <td colspan="7"></td>
341
338
  </tr>
342
- <!-- Parents -->
339
+
343
340
  <tr>
344
341
  <td>&nbsp;</td>
345
342
  <td>&nbsp;</td>
@@ -358,7 +355,7 @@ of control through a program and which methods take the most time.</p>
358
355
  <td> 1</td>
359
356
  <td><a name="Object_find_largest_21277412">Object#find_largest</a></td>
360
357
  </tr>
361
- <!-- Children -->
358
+
362
359
  <tr>
363
360
  <td>&nbsp;</td>
364
361
  <td>&nbsp;</td>
@@ -395,11 +392,11 @@ of control through a program and which methods take the most time.</p>
395
392
  <td> 1/1</td>
396
393
  <td><a href="#Array_length_21277412">Array#length</a></td>
397
394
  </tr>
398
- <!-- Create divider row -->
395
+
399
396
  <tr class="break">
400
397
  <td colspan="7"></td>
401
398
  </tr>
402
- <!-- Parents -->
399
+
403
400
  <tr>
404
401
  <td>&nbsp;</td>
405
402
  <td>&nbsp;</td>
@@ -418,12 +415,12 @@ of control through a program and which methods take the most time.</p>
418
415
  <td> 61</td>
419
416
  <td><a name="Kernel_sleep_21277412">Kernel.sleep</a></td>
420
417
  </tr>
421
- <!-- Children -->
422
- <!-- Create divider row -->
418
+
419
+
423
420
  <tr class="break">
424
421
  <td colspan="7"></td>
425
422
  </tr>
426
- <!-- Parents -->
423
+
427
424
  <tr>
428
425
  <td>&nbsp;</td>
429
426
  <td>&nbsp;</td>
@@ -442,12 +439,11 @@ of control through a program and which methods take the most time.</p>
442
439
  <td> 250862</td>
443
440
  <td><a name="Fixnum_%_21277412">Fixnum#%</a></td>
444
441
  </tr>
445
- <!-- Children -->
446
- <!-- Create divider row -->
442
+
447
443
  <tr class="break">
448
444
  <td colspan="7"></td>
449
445
  </tr>
450
- <!-- Parents -->
446
+
451
447
  <tr>
452
448
  <td>&nbsp;</td>
453
449
  <td>&nbsp;</td>
@@ -466,12 +462,12 @@ of control through a program and which methods take the most time.</p>
466
462
  <td> 250862</td>
467
463
  <td><a name="Fixnum____21277412">Fixnum#==</a></td>
468
464
  </tr>
469
- <!-- Children -->
470
- <!-- Create divider row -->
465
+
466
+
471
467
  <tr class="break">
472
468
  <td colspan="7"></td>
473
469
  </tr>
474
- <!-- Parents -->
470
+
475
471
  <tr>
476
472
  <td>&nbsp;</td>
477
473
  <td>&nbsp;</td>
@@ -490,7 +486,7 @@ of control through a program and which methods take the most time.</p>
490
486
  <td> 1</td>
491
487
  <td><a name="Object_make_random_array_21277412">Object#make_random_array</a></td>
492
488
  </tr>
493
- <!-- Children -->
489
+
494
490
  <tr>
495
491
  <td>&nbsp;</td>
496
492
  <td>&nbsp;</td>
@@ -509,11 +505,11 @@ of control through a program and which methods take the most time.</p>
509
505
  <td> 1/1</td>
510
506
  <td><a href="#Class_new_21277412">Class#new</a></td>
511
507
  </tr>
512
- <!-- Create divider row -->
508
+
513
509
  <tr class="break">
514
510
  <td colspan="7"></td>
515
511
  </tr>
516
- <!-- Parents -->
512
+
517
513
  <tr>
518
514
  <td>&nbsp;</td>
519
515
  <td>&nbsp;</td>
@@ -532,7 +528,7 @@ of control through a program and which methods take the most time.</p>
532
528
  <td> 1</td>
533
529
  <td><a name="Array_each_index_21277412">Array#each_index</a></td>
534
530
  </tr>
535
- <!-- Children -->
531
+
536
532
  <tr>
537
533
  <td>&nbsp;</td>
538
534
  <td>&nbsp;</td>
@@ -551,11 +547,11 @@ of control through a program and which methods take the most time.</p>
551
547
  <td> 500/500</td>
552
548
  <td><a href="#Array_[]__21277412">Array#[]=</a></td>
553
549
  </tr>
554
- <!-- Create divider row -->
550
+
555
551
  <tr class="break">
556
552
  <td colspan="7"></td>
557
553
  </tr>
558
- <!-- Parents -->
554
+
559
555
  <tr>
560
556
  <td>&nbsp;</td>
561
557
  <td>&nbsp;</td>
@@ -583,12 +579,12 @@ of control through a program and which methods take the most time.</p>
583
579
  <td> 501</td>
584
580
  <td><a name="Fixnum_-_21277412">Fixnum#-</a></td>
585
581
  </tr>
586
- <!-- Children -->
587
- <!-- Create divider row -->
582
+
583
+
588
584
  <tr class="break">
589
585
  <td colspan="7"></td>
590
586
  </tr>
591
- <!-- Parents -->
587
+
592
588
  <tr>
593
589
  <td>&nbsp;</td>
594
590
  <td>&nbsp;</td>
@@ -607,12 +603,12 @@ of control through a program and which methods take the most time.</p>
607
603
  <td> 1</td>
608
604
  <td><a name="Integer_to_int_21277412">Integer#to_int</a></td>
609
605
  </tr>
610
- <!-- Children -->
611
- <!-- Create divider row -->
606
+
607
+
612
608
  <tr class="break">
613
609
  <td colspan="7"></td>
614
610
  </tr>
615
- <!-- Parents -->
611
+
616
612
  <tr>
617
613
  <td>&nbsp;</td>
618
614
  <td>&nbsp;</td>
@@ -631,12 +627,12 @@ of control through a program and which methods take the most time.</p>
631
627
  <td> 1</td>
632
628
  <td><a name="Array_first_21277412">Array#first</a></td>
633
629
  </tr>
634
- <!-- Children -->
635
- <!-- Create divider row -->
630
+
631
+
636
632
  <tr class="break">
637
633
  <td colspan="7"></td>
638
634
  </tr>
639
- <!-- Parents -->
635
+
640
636
  <tr>
641
637
  <td>&nbsp;</td>
642
638
  <td>&nbsp;</td>
@@ -655,12 +651,12 @@ of control through a program and which methods take the most time.</p>
655
651
  <td> 1</td>
656
652
  <td><a name="Array_initialize_21277412">Array#initialize</a></td>
657
653
  </tr>
658
- <!-- Children -->
659
- <!-- Create divider row -->
654
+
655
+
660
656
  <tr class="break">
661
657
  <td colspan="7"></td>
662
658
  </tr>
663
- <!-- Parents -->
659
+
664
660
  <tr>
665
661
  <td>&nbsp;</td>
666
662
  <td>&nbsp;</td>
@@ -679,12 +675,12 @@ of control through a program and which methods take the most time.</p>
679
675
  <td> 1</td>
680
676
  <td><a name="Array_length_21277412">Array#length</a></td>
681
677
  </tr>
682
- <!-- Children -->
683
- <!-- Create divider row -->
678
+
679
+
684
680
  <tr class="break">
685
681
  <td colspan="7"></td>
686
682
  </tr>
687
- <!-- Parents -->
683
+
688
684
  <tr>
689
685
  <td>&nbsp;</td>
690
686
  <td>&nbsp;</td>
@@ -703,7 +699,7 @@ of control through a program and which methods take the most time.</p>
703
699
  <td> 1</td>
704
700
  <td><a name="Class_new_21277412">Class#new</a></td>
705
701
  </tr>
706
- <!-- Children -->
702
+
707
703
  <tr>
708
704
  <td>&nbsp;</td>
709
705
  <td>&nbsp;</td>
@@ -713,11 +709,11 @@ of control through a program and which methods take the most time.</p>
713
709
  <td> 1/1</td>
714
710
  <td><a href="#Array_initialize_21277412">Array#initialize</a></td>
715
711
  </tr>
716
- <!-- Create divider row -->
712
+
717
713
  <tr class="break">
718
714
  <td colspan="7"></td>
719
715
  </tr>
720
- <!-- Parents -->
716
+
721
717
  <tr>
722
718
  <td>&nbsp;</td>
723
719
  <td>&nbsp;</td>
@@ -736,12 +732,12 @@ of control through a program and which methods take the most time.</p>
736
732
  <td> 61</td>
737
733
  <td><a name="Fixnum_>_21277412">Fixnum#_</a></td>
738
734
  </tr>
739
- <!-- Children -->
740
- <!-- Create divider row -->
735
+
736
+
741
737
  <tr class="break">
742
738
  <td colspan="7"></td>
743
739
  </tr>
744
- <!-- Parents -->
740
+
745
741
  <tr>
746
742
  <td>&nbsp;</td>
747
743
  <td>&nbsp;</td>
@@ -760,12 +756,12 @@ of control through a program and which methods take the most time.</p>
760
756
  <td> 61</td>
761
757
  <td><a name="Array_[]_21277412">Array#[]</a></td>
762
758
  </tr>
763
- <!-- Children -->
764
- <!-- Create divider row -->
759
+
760
+
765
761
  <tr class="break">
766
762
  <td colspan="7"></td>
767
763
  </tr>
768
- <!-- Parents -->
764
+
769
765
  <tr>
770
766
  <td>&nbsp;</td>
771
767
  <td>&nbsp;</td>
@@ -784,12 +780,12 @@ of control through a program and which methods take the most time.</p>
784
780
  <td> 500</td>
785
781
  <td><a name="Array_[]__21277412">Array#[]=</a></td>
786
782
  </tr>
787
- <!-- Children -->
788
- <!-- Create divider row -->
783
+
784
+
789
785
  <tr class="break">
790
786
  <td colspan="7"></td>
791
787
  </tr>
792
- <!-- Parents -->
788
+
793
789
  <tr>
794
790
  <td>&nbsp;</td>
795
791
  <td>&nbsp;</td>
@@ -808,7 +804,7 @@ of control through a program and which methods take the most time.</p>
808
804
  <td> 500</td>
809
805
  <td><a name="Kernel_rand_21277412">Kernel.rand</a></td>
810
806
  </tr>
811
- <!-- Children -->
807
+
812
808
  <tr>
813
809
  <td>&nbsp;</td>
814
810
  <td>&nbsp;</td>
@@ -818,7 +814,7 @@ of control through a program and which methods take the most time.</p>
818
814
  <td> 1/1</td>
819
815
  <td><a href="#Integer_to_int_21277412">Integer#to_int</a></td>
820
816
  </tr>
821
- <!-- Create divider row -->
817
+
822
818
  <tr class="break">
823
819
  <td colspan="7"></td>
824
820
  </tr>
@@ -0,0 +1,43 @@
1
+ /* :nodoc:
2
+ * Copyright (C) 2007 Shugo Maeda <shugo@ruby-lang.org>
3
+ * Charlie Savage <cfis@savagexi.com>
4
+ * All rights reserved.
5
+ *
6
+ * Redistribution and use in source and binary forms, with or without
7
+ * modification, are permitted provided that the following conditions
8
+ * are met:
9
+ * 1. Redistributions of source code must retain the above copyright
10
+ * notice, this list of conditions and the following disclaimer.
11
+ * 2. Redistributions in binary form must reproduce the above copyright
12
+ * notice, this list of conditions and the following disclaimer in the
13
+ * documentation and/or other materials provided with the distribution.
14
+ *
15
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
16
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
19
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25
+ * SUCH DAMAGE. */
26
+
27
+
28
+ #if defined(HAVE_RB_OS_ALLOCATED_OBJECTS)
29
+ #define MEASURE_ALLOCATIONS 3
30
+
31
+ static prof_measure_t
32
+ measure_allocations()
33
+ {
34
+ return rb_os_allocated_objects();
35
+ }
36
+
37
+ static double
38
+ convert_allocations(prof_measure_t c)
39
+ {
40
+ return c;
41
+ }
42
+
43
+ #endif