ruby-prof 0.17.0 → 0.18.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.
Files changed (185) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGES +500 -482
  3. data/LICENSE +24 -24
  4. data/README.rdoc +487 -485
  5. data/Rakefile +113 -113
  6. data/bin/ruby-prof +345 -345
  7. data/bin/ruby-prof-check-trace +45 -45
  8. data/examples/flat.txt +50 -50
  9. data/examples/graph.dot +84 -84
  10. data/examples/graph.html +823 -823
  11. data/examples/graph.txt +139 -139
  12. data/examples/multi.flat.txt +23 -23
  13. data/examples/multi.graph.html +760 -760
  14. data/examples/multi.grind.dat +114 -114
  15. data/examples/multi.stack.html +547 -547
  16. data/examples/stack.html +547 -547
  17. data/ext/ruby_prof/extconf.rb +68 -68
  18. data/ext/ruby_prof/rp_call_info.c +425 -425
  19. data/ext/ruby_prof/rp_call_info.h +53 -53
  20. data/ext/ruby_prof/rp_measure.c +40 -40
  21. data/ext/ruby_prof/rp_measure.h +45 -45
  22. data/ext/ruby_prof/rp_measure_allocations.c +76 -76
  23. data/ext/ruby_prof/rp_measure_cpu_time.c +136 -136
  24. data/ext/ruby_prof/rp_measure_gc_runs.c +73 -73
  25. data/ext/ruby_prof/rp_measure_gc_time.c +60 -60
  26. data/ext/ruby_prof/rp_measure_memory.c +77 -77
  27. data/ext/ruby_prof/rp_measure_process_time.c +71 -71
  28. data/ext/ruby_prof/rp_measure_wall_time.c +45 -45
  29. data/ext/ruby_prof/rp_method.c +630 -636
  30. data/ext/ruby_prof/rp_method.h +75 -75
  31. data/ext/ruby_prof/rp_stack.c +173 -173
  32. data/ext/ruby_prof/rp_stack.h +63 -63
  33. data/ext/ruby_prof/rp_thread.c +277 -276
  34. data/ext/ruby_prof/rp_thread.h +27 -27
  35. data/ext/ruby_prof/ruby_prof.c +794 -774
  36. data/ext/ruby_prof/ruby_prof.h +60 -59
  37. data/ext/ruby_prof/vc/ruby_prof.sln +20 -21
  38. data/ext/ruby_prof/vc/{ruby_prof_20.vcxproj → ruby_prof.vcxproj} +31 -0
  39. data/lib/ruby-prof.rb +68 -68
  40. data/lib/ruby-prof/aggregate_call_info.rb +76 -76
  41. data/lib/ruby-prof/assets/call_stack_printer.css.html +116 -116
  42. data/lib/ruby-prof/assets/call_stack_printer.js.html +384 -384
  43. data/lib/ruby-prof/call_info.rb +115 -115
  44. data/lib/ruby-prof/call_info_visitor.rb +40 -40
  45. data/lib/ruby-prof/compatibility.rb +179 -178
  46. data/lib/ruby-prof/method_info.rb +121 -121
  47. data/lib/ruby-prof/printers/abstract_printer.rb +104 -103
  48. data/lib/ruby-prof/printers/call_info_printer.rb +41 -41
  49. data/lib/ruby-prof/printers/call_stack_printer.rb +265 -265
  50. data/lib/ruby-prof/printers/call_tree_printer.rb +143 -143
  51. data/lib/ruby-prof/printers/dot_printer.rb +132 -132
  52. data/lib/ruby-prof/printers/flat_printer.rb +70 -70
  53. data/lib/ruby-prof/printers/flat_printer_with_line_numbers.rb +83 -83
  54. data/lib/ruby-prof/printers/graph_html_printer.rb +249 -249
  55. data/lib/ruby-prof/printers/graph_printer.rb +116 -116
  56. data/lib/ruby-prof/printers/multi_printer.rb +84 -84
  57. data/lib/ruby-prof/profile.rb +26 -26
  58. data/lib/ruby-prof/profile/exclude_common_methods.rb +207 -201
  59. data/lib/ruby-prof/profile/legacy_method_elimination.rb +50 -49
  60. data/lib/ruby-prof/rack.rb +174 -174
  61. data/lib/ruby-prof/task.rb +147 -147
  62. data/lib/ruby-prof/thread.rb +35 -35
  63. data/lib/ruby-prof/version.rb +3 -3
  64. data/lib/unprof.rb +10 -10
  65. data/ruby-prof.gemspec +58 -58
  66. data/test/abstract_printer_test.rb +53 -0
  67. data/test/aggregate_test.rb +136 -136
  68. data/test/basic_test.rb +128 -128
  69. data/test/block_test.rb +74 -74
  70. data/test/call_info_test.rb +78 -78
  71. data/test/call_info_visitor_test.rb +31 -31
  72. data/test/duplicate_names_test.rb +32 -32
  73. data/test/dynamic_method_test.rb +55 -55
  74. data/test/enumerable_test.rb +21 -21
  75. data/test/exceptions_test.rb +24 -16
  76. data/test/exclude_methods_test.rb +146 -146
  77. data/test/exclude_threads_test.rb +53 -53
  78. data/test/fiber_test.rb +79 -79
  79. data/test/issue137_test.rb +63 -63
  80. data/test/line_number_test.rb +80 -80
  81. data/test/measure_allocations_test.rb +26 -26
  82. data/test/measure_cpu_time_test.rb +212 -213
  83. data/test/measure_gc_runs_test.rb +32 -32
  84. data/test/measure_gc_time_test.rb +36 -36
  85. data/test/measure_memory_test.rb +33 -33
  86. data/test/measure_process_time_test.rb +61 -63
  87. data/test/measure_wall_time_test.rb +255 -255
  88. data/test/method_elimination_test.rb +84 -84
  89. data/test/module_test.rb +45 -45
  90. data/test/multi_printer_test.rb +104 -104
  91. data/test/no_method_class_test.rb +15 -15
  92. data/test/pause_resume_test.rb +166 -166
  93. data/test/prime.rb +54 -54
  94. data/test/printers_test.rb +275 -275
  95. data/test/printing_recursive_graph_test.rb +127 -127
  96. data/test/rack_test.rb +157 -157
  97. data/test/recursive_test.rb +215 -215
  98. data/test/singleton_test.rb +38 -38
  99. data/test/stack_printer_test.rb +77 -78
  100. data/test/stack_test.rb +138 -138
  101. data/test/start_stop_test.rb +112 -112
  102. data/test/test_helper.rb +267 -275
  103. data/test/thread_test.rb +187 -187
  104. data/test/unique_call_path_test.rb +202 -202
  105. data/test/yarv_test.rb +55 -55
  106. metadata +17 -96
  107. data/doc/LICENSE.html +0 -115
  108. data/doc/README_rdoc.html +0 -637
  109. data/doc/Rack.html +0 -96
  110. data/doc/Rack/RubyProf.html +0 -233
  111. data/doc/Rack/RubyProf/RackProfiler.html +0 -343
  112. data/doc/RubyProf.html +0 -974
  113. data/doc/RubyProf/AbstractPrinter.html +0 -625
  114. data/doc/RubyProf/AggregateCallInfo.html +0 -552
  115. data/doc/RubyProf/CallInfo.html +0 -579
  116. data/doc/RubyProf/CallInfoPrinter.html +0 -121
  117. data/doc/RubyProf/CallInfoVisitor.html +0 -199
  118. data/doc/RubyProf/CallStackPrinter.html +0 -1127
  119. data/doc/RubyProf/CallTreePrinter.html +0 -725
  120. data/doc/RubyProf/Cmd.html +0 -637
  121. data/doc/RubyProf/DeprecationWarnings.html +0 -148
  122. data/doc/RubyProf/DotPrinter.html +0 -258
  123. data/doc/RubyProf/FlatPrinter.html +0 -164
  124. data/doc/RubyProf/FlatPrinterWithLineNumbers.html +0 -210
  125. data/doc/RubyProf/GraphHtmlPrinter.html +0 -558
  126. data/doc/RubyProf/GraphPrinter.html +0 -140
  127. data/doc/RubyProf/MethodInfo.html +0 -676
  128. data/doc/RubyProf/MultiPrinter.html +0 -574
  129. data/doc/RubyProf/Profile.html +0 -908
  130. data/doc/RubyProf/Profile/ExcludeCommonMethods.html +0 -411
  131. data/doc/RubyProf/Profile/LegacyMethodElimination.html +0 -158
  132. data/doc/RubyProf/ProfileTask.html +0 -491
  133. data/doc/RubyProf/Thread.html +0 -275
  134. data/doc/created.rid +0 -33
  135. data/doc/css/fonts.css +0 -167
  136. data/doc/css/rdoc.css +0 -590
  137. data/doc/examples/flat_txt.html +0 -139
  138. data/doc/examples/graph_html.html +0 -910
  139. data/doc/examples/graph_txt.html +0 -248
  140. data/doc/fonts/Lato-Light.ttf +0 -0
  141. data/doc/fonts/Lato-LightItalic.ttf +0 -0
  142. data/doc/fonts/Lato-Regular.ttf +0 -0
  143. data/doc/fonts/Lato-RegularItalic.ttf +0 -0
  144. data/doc/fonts/SourceCodePro-Bold.ttf +0 -0
  145. data/doc/fonts/SourceCodePro-Regular.ttf +0 -0
  146. data/doc/images/add.png +0 -0
  147. data/doc/images/arrow_up.png +0 -0
  148. data/doc/images/brick.png +0 -0
  149. data/doc/images/brick_link.png +0 -0
  150. data/doc/images/bug.png +0 -0
  151. data/doc/images/bullet_black.png +0 -0
  152. data/doc/images/bullet_toggle_minus.png +0 -0
  153. data/doc/images/bullet_toggle_plus.png +0 -0
  154. data/doc/images/date.png +0 -0
  155. data/doc/images/delete.png +0 -0
  156. data/doc/images/find.png +0 -0
  157. data/doc/images/loadingAnimation.gif +0 -0
  158. data/doc/images/macFFBgHack.png +0 -0
  159. data/doc/images/package.png +0 -0
  160. data/doc/images/page_green.png +0 -0
  161. data/doc/images/page_white_text.png +0 -0
  162. data/doc/images/page_white_width.png +0 -0
  163. data/doc/images/plugin.png +0 -0
  164. data/doc/images/ruby.png +0 -0
  165. data/doc/images/tag_blue.png +0 -0
  166. data/doc/images/tag_green.png +0 -0
  167. data/doc/images/transparent.png +0 -0
  168. data/doc/images/wrench.png +0 -0
  169. data/doc/images/wrench_orange.png +0 -0
  170. data/doc/images/zoom.png +0 -0
  171. data/doc/index.html +0 -666
  172. data/doc/js/darkfish.js +0 -161
  173. data/doc/js/jquery.js +0 -4
  174. data/doc/js/navigation.js +0 -142
  175. data/doc/js/navigation.js.gz +0 -0
  176. data/doc/js/search.js +0 -109
  177. data/doc/js/search_index.js +0 -1
  178. data/doc/js/search_index.js.gz +0 -0
  179. data/doc/js/searcher.js +0 -229
  180. data/doc/js/searcher.js.gz +0 -0
  181. data/doc/table_of_contents.html +0 -1052
  182. data/examples/cachegrind.out.1 +0 -114
  183. data/examples/cachegrind.out.1.32313213 +0 -114
  184. data/ext/ruby_prof/vc/ruby_prof_18.vcxproj +0 -108
  185. data/ext/ruby_prof/vc/ruby_prof_19.vcxproj +0 -110
@@ -1,55 +1,55 @@
1
- #!/usr/bin/env ruby
2
- # encoding: UTF-8
3
-
4
- require File.expand_path('../test_helper', __FILE__)
5
-
6
- # tests for bugs reported by users
7
- class BugsTest < TestCase
8
- def setup
9
- RubyProf::measure_mode = RubyProf::WALL_TIME
10
- define_methods
11
- end
12
-
13
- def test_array_push_unoptimized
14
- a = nil
15
- result = RubyProf.profile do
16
- a = self.array_push_unoptimized
17
- end
18
- assert_equal 2, a.length
19
- assert_equal ["BugsTest#test_array_push_unoptimized", "BugsTest#array_push_unoptimized", 'Array#<<', "Array#push"], result.threads.first.methods.map(&:full_name)
20
- end
21
-
22
- def test_array_push_optimized
23
- a = nil
24
- result = RubyProf.profile do
25
- a = self.array_push_optimized
26
- end
27
- assert_equal 2, a.length
28
- assert_equal ["BugsTest#test_array_push_optimized", "BugsTest#array_push_optimized", "Array#push"], result.threads.first.methods.map(&:full_name)
29
- end
30
-
31
- private
32
- def define_methods
33
- return if respond_to?(:array_push_optimized)
34
- old_compile_option = RubyVM::InstructionSequence.compile_option
35
- RubyVM::InstructionSequence.compile_option = {
36
- :trace_instruction => true,
37
- :specialized_instruction => false
38
- }
39
- self.class.class_eval <<-"EOM"
40
- def array_push_unoptimized
41
- a = []
42
- a << 1
43
- a.push 2
44
- end
45
- EOM
46
- RubyVM::InstructionSequence.compile_option = old_compile_option
47
- self.class.class_eval <<-"EOM"
48
- def array_push_optimized
49
- a = []
50
- a << 1
51
- a.push 2
52
- end
53
- EOM
54
- end
55
- end
1
+ #!/usr/bin/env ruby
2
+ # encoding: UTF-8
3
+
4
+ require File.expand_path('../test_helper', __FILE__)
5
+
6
+ # tests for bugs reported by users
7
+ class BugsTest < TestCase
8
+ def setup
9
+ RubyProf::measure_mode = RubyProf::WALL_TIME
10
+ define_methods
11
+ end
12
+
13
+ def test_array_push_unoptimized
14
+ a = nil
15
+ result = RubyProf.profile do
16
+ a = self.array_push_unoptimized
17
+ end
18
+ assert_equal 2, a.length
19
+ assert_equal ["BugsTest#test_array_push_unoptimized", "BugsTest#array_push_unoptimized", 'Array#<<', "Array#push"], result.threads.first.methods.map(&:full_name)
20
+ end
21
+
22
+ def test_array_push_optimized
23
+ a = nil
24
+ result = RubyProf.profile do
25
+ a = self.array_push_optimized
26
+ end
27
+ assert_equal 2, a.length
28
+ assert_equal ["BugsTest#test_array_push_optimized", "BugsTest#array_push_optimized", "Array#push"], result.threads.first.methods.map(&:full_name)
29
+ end
30
+
31
+ private
32
+ def define_methods
33
+ return if respond_to?(:array_push_optimized)
34
+ old_compile_option = RubyVM::InstructionSequence.compile_option
35
+ RubyVM::InstructionSequence.compile_option = {
36
+ :trace_instruction => true,
37
+ :specialized_instruction => false
38
+ }
39
+ self.class.class_eval <<-"EOM"
40
+ def array_push_unoptimized
41
+ a = []
42
+ a << 1
43
+ a.push 2
44
+ end
45
+ EOM
46
+ RubyVM::InstructionSequence.compile_option = old_compile_option
47
+ self.class.class_eval <<-"EOM"
48
+ def array_push_optimized
49
+ a = []
50
+ a << 1
51
+ a.push 2
52
+ end
53
+ EOM
54
+ end
55
+ end
metadata CHANGED
@@ -1,57 +1,57 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-prof
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.17.0
4
+ version: 0.18.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shugo Maeda, Charlie Savage, Roger Pack, Stefan Kaes
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-12-17 00:00:00.000000000 Z
11
+ date: 2019-05-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: minitest
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '5.0'
19
+ version: '0'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: '5.0'
26
+ version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake-compiler
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: '1.0'
33
+ version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - "~>"
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: '1.0'
40
+ version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rdoc
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - "~>"
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
- version: '5.0'
47
+ version: '0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - "~>"
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
- version: '5.0'
54
+ version: '0'
55
55
  description: |
56
56
  ruby-prof is a fast code profiler for Ruby. It is a C extension and
57
57
  therefore is many times faster than the standard Ruby profiler. It
@@ -73,83 +73,6 @@ files:
73
73
  - Rakefile
74
74
  - bin/ruby-prof
75
75
  - bin/ruby-prof-check-trace
76
- - doc/LICENSE.html
77
- - doc/README_rdoc.html
78
- - doc/Rack.html
79
- - doc/Rack/RubyProf.html
80
- - doc/Rack/RubyProf/RackProfiler.html
81
- - doc/RubyProf.html
82
- - doc/RubyProf/AbstractPrinter.html
83
- - doc/RubyProf/AggregateCallInfo.html
84
- - doc/RubyProf/CallInfo.html
85
- - doc/RubyProf/CallInfoPrinter.html
86
- - doc/RubyProf/CallInfoVisitor.html
87
- - doc/RubyProf/CallStackPrinter.html
88
- - doc/RubyProf/CallTreePrinter.html
89
- - doc/RubyProf/Cmd.html
90
- - doc/RubyProf/DeprecationWarnings.html
91
- - doc/RubyProf/DotPrinter.html
92
- - doc/RubyProf/FlatPrinter.html
93
- - doc/RubyProf/FlatPrinterWithLineNumbers.html
94
- - doc/RubyProf/GraphHtmlPrinter.html
95
- - doc/RubyProf/GraphPrinter.html
96
- - doc/RubyProf/MethodInfo.html
97
- - doc/RubyProf/MultiPrinter.html
98
- - doc/RubyProf/Profile.html
99
- - doc/RubyProf/Profile/ExcludeCommonMethods.html
100
- - doc/RubyProf/Profile/LegacyMethodElimination.html
101
- - doc/RubyProf/ProfileTask.html
102
- - doc/RubyProf/Thread.html
103
- - doc/created.rid
104
- - doc/css/fonts.css
105
- - doc/css/rdoc.css
106
- - doc/examples/flat_txt.html
107
- - doc/examples/graph_html.html
108
- - doc/examples/graph_txt.html
109
- - doc/fonts/Lato-Light.ttf
110
- - doc/fonts/Lato-LightItalic.ttf
111
- - doc/fonts/Lato-Regular.ttf
112
- - doc/fonts/Lato-RegularItalic.ttf
113
- - doc/fonts/SourceCodePro-Bold.ttf
114
- - doc/fonts/SourceCodePro-Regular.ttf
115
- - doc/images/add.png
116
- - doc/images/arrow_up.png
117
- - doc/images/brick.png
118
- - doc/images/brick_link.png
119
- - doc/images/bug.png
120
- - doc/images/bullet_black.png
121
- - doc/images/bullet_toggle_minus.png
122
- - doc/images/bullet_toggle_plus.png
123
- - doc/images/date.png
124
- - doc/images/delete.png
125
- - doc/images/find.png
126
- - doc/images/loadingAnimation.gif
127
- - doc/images/macFFBgHack.png
128
- - doc/images/package.png
129
- - doc/images/page_green.png
130
- - doc/images/page_white_text.png
131
- - doc/images/page_white_width.png
132
- - doc/images/plugin.png
133
- - doc/images/ruby.png
134
- - doc/images/tag_blue.png
135
- - doc/images/tag_green.png
136
- - doc/images/transparent.png
137
- - doc/images/wrench.png
138
- - doc/images/wrench_orange.png
139
- - doc/images/zoom.png
140
- - doc/index.html
141
- - doc/js/darkfish.js
142
- - doc/js/jquery.js
143
- - doc/js/navigation.js
144
- - doc/js/navigation.js.gz
145
- - doc/js/search.js
146
- - doc/js/search_index.js
147
- - doc/js/search_index.js.gz
148
- - doc/js/searcher.js
149
- - doc/js/searcher.js.gz
150
- - doc/table_of_contents.html
151
- - examples/cachegrind.out.1
152
- - examples/cachegrind.out.1.32313213
153
76
  - examples/flat.txt
154
77
  - examples/graph.dot
155
78
  - examples/graph.html
@@ -180,9 +103,7 @@ files:
180
103
  - ext/ruby_prof/ruby_prof.c
181
104
  - ext/ruby_prof/ruby_prof.h
182
105
  - ext/ruby_prof/vc/ruby_prof.sln
183
- - ext/ruby_prof/vc/ruby_prof_18.vcxproj
184
- - ext/ruby_prof/vc/ruby_prof_19.vcxproj
185
- - ext/ruby_prof/vc/ruby_prof_20.vcxproj
106
+ - ext/ruby_prof/vc/ruby_prof.vcxproj
186
107
  - lib/ruby-prof.rb
187
108
  - lib/ruby-prof/aggregate_call_info.rb
188
109
  - lib/ruby-prof/assets/call_stack_printer.css.html
@@ -211,6 +132,7 @@ files:
211
132
  - lib/ruby-prof/version.rb
212
133
  - lib/unprof.rb
213
134
  - ruby-prof.gemspec
135
+ - test/abstract_printer_test.rb
214
136
  - test/aggregate_test.rb
215
137
  - test/basic_test.rb
216
138
  - test/block_test.rb
@@ -269,8 +191,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
269
191
  - !ruby/object:Gem::Version
270
192
  version: '0'
271
193
  requirements: []
272
- rubyforge_project:
273
- rubygems_version: 2.6.14
194
+ rubygems_version: 3.0.3
274
195
  signing_key:
275
196
  specification_version: 4
276
197
  summary: Fast Ruby profiler
@@ -1,115 +0,0 @@
1
- <!DOCTYPE html>
2
-
3
- <html>
4
- <head>
5
- <meta charset="UTF-8">
6
-
7
- <title>LICENSE - ruby-prof</title>
8
-
9
- <script type="text/javascript">
10
- var rdoc_rel_prefix = "./";
11
- var index_rel_prefix = "./";
12
- </script>
13
-
14
- <script src="./js/jquery.js"></script>
15
- <script src="./js/darkfish.js"></script>
16
-
17
- <link href="./css/fonts.css" rel="stylesheet">
18
- <link href="./css/rdoc.css" rel="stylesheet">
19
-
20
-
21
-
22
- <body id="top" role="document" class="file">
23
- <nav role="navigation">
24
- <div id="project-navigation">
25
- <div id="home-section" role="region" title="Quick navigation" class="nav-section">
26
- <h2>
27
- <a href="./index.html" rel="home">Home</a>
28
- </h2>
29
-
30
- <div id="table-of-contents-navigation">
31
- <a href="./table_of_contents.html#pages">Pages</a>
32
- <a href="./table_of_contents.html#classes">Classes</a>
33
- <a href="./table_of_contents.html#methods">Methods</a>
34
- </div>
35
- </div>
36
-
37
- <div id="search-section" role="search" class="project-section initially-hidden">
38
- <form action="#" method="get" accept-charset="utf-8">
39
- <div id="search-field-wrapper">
40
- <input id="search-field" role="combobox" aria-label="Search"
41
- aria-autocomplete="list" aria-controls="search-results"
42
- type="text" name="search" placeholder="Search" spellcheck="false"
43
- title="Type to search, Up and Down to navigate, Enter to load">
44
- </div>
45
-
46
- <ul id="search-results" aria-label="Search Results"
47
- aria-busy="false" aria-expanded="false"
48
- aria-atomic="false" class="initially-hidden"></ul>
49
- </form>
50
- </div>
51
-
52
- </div>
53
-
54
-
55
-
56
- <div id="project-metadata">
57
- <div id="fileindex-section" class="nav-section">
58
- <h3>Pages</h3>
59
-
60
- <ul class="link-list">
61
-
62
- <li><a href="./LICENSE.html">LICENSE</a>
63
-
64
- <li><a href="./README_rdoc.html">README</a>
65
-
66
- <li><a href="./examples/flat_txt.html">flat</a>
67
-
68
- <li><a href="./examples/graph_html.html">graph.html</a>
69
-
70
- <li><a href="./examples/graph_txt.html">graph</a>
71
-
72
- </ul>
73
- </div>
74
-
75
- </div>
76
- </nav>
77
-
78
- <main role="main" aria-label="Page LICENSE">
79
-
80
- <p>Copyright (C) 2005 - 2014 Shugo Maeda &lt;shugo@ruby-lang.org&gt; and
81
- Charlie Savage &lt;cfis@savagexi.com&gt; Copyright (C) 2010 - 2014 Stefan
82
- Kaes &lt;skaes@railsepxress.de&gt; All rights reserved.</p>
83
-
84
- <p>Redistribution and use in source and binary forms, with or without
85
- modification, are permitted provided that the following conditions are met:</p>
86
- <ol><li>
87
- <p>Redistributions of source code must retain the above copyright notice, this
88
- list of conditions and the following disclaimer.</p>
89
- </li><li>
90
- <p>Redistributions in binary form must reproduce the above copyright notice,
91
- this list of conditions and the following disclaimer in the documentation
92
- and/or other materials provided with the distribution.</p>
93
- </li></ol>
94
-
95
- <p>THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS “AS IS&#39;&#39;
96
- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
97
- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
98
- ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
99
- FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
100
- DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
101
- SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
102
- CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
103
- LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
104
- OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
105
- DAMAGE.</p>
106
- </main>
107
-
108
-
109
-
110
- <footer id="validator-badges" role="contentinfo">
111
- <p><a href="http://validator.w3.org/check/referer">Validate</a>
112
- <p>Generated by <a href="https://rdoc.github.io/rdoc">RDoc</a> 5.1.0.
113
- <p>Based on <a href="http://deveiate.org/projects/Darkfish-RDoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
114
- </footer>
115
-
@@ -1,637 +0,0 @@
1
- <!DOCTYPE html>
2
-
3
- <html>
4
- <head>
5
- <meta charset="UTF-8">
6
-
7
- <title>README - ruby-prof</title>
8
-
9
- <script type="text/javascript">
10
- var rdoc_rel_prefix = "./";
11
- var index_rel_prefix = "./";
12
- </script>
13
-
14
- <script src="./js/jquery.js"></script>
15
- <script src="./js/darkfish.js"></script>
16
-
17
- <link href="./css/fonts.css" rel="stylesheet">
18
- <link href="./css/rdoc.css" rel="stylesheet">
19
-
20
-
21
-
22
- <body id="top" role="document" class="file">
23
- <nav role="navigation">
24
- <div id="project-navigation">
25
- <div id="home-section" role="region" title="Quick navigation" class="nav-section">
26
- <h2>
27
- <a href="./index.html" rel="home">Home</a>
28
- </h2>
29
-
30
- <div id="table-of-contents-navigation">
31
- <a href="./table_of_contents.html#pages">Pages</a>
32
- <a href="./table_of_contents.html#classes">Classes</a>
33
- <a href="./table_of_contents.html#methods">Methods</a>
34
- </div>
35
- </div>
36
-
37
- <div id="search-section" role="search" class="project-section initially-hidden">
38
- <form action="#" method="get" accept-charset="utf-8">
39
- <div id="search-field-wrapper">
40
- <input id="search-field" role="combobox" aria-label="Search"
41
- aria-autocomplete="list" aria-controls="search-results"
42
- type="text" name="search" placeholder="Search" spellcheck="false"
43
- title="Type to search, Up and Down to navigate, Enter to load">
44
- </div>
45
-
46
- <ul id="search-results" aria-label="Search Results"
47
- aria-busy="false" aria-expanded="false"
48
- aria-atomic="false" class="initially-hidden"></ul>
49
- </form>
50
- </div>
51
-
52
- </div>
53
-
54
-
55
- <div class="nav-section">
56
- <h3>Table of Contents</h3>
57
-
58
- <ul class="link-list" role="directory">
59
- <li><a href="#label-ruby-prof">ruby-prof</a>
60
- <li><a href="#label-Overview">Overview</a>
61
- <li><a href="#label-Requirements">Requirements</a>
62
- <li><a href="#label-Install">Install</a>
63
- <li><a href="#label-Usage">Usage</a>
64
- <li><a href="#label-ruby-prof+Executable">ruby-prof Executable</a>
65
- <li><a href="#label-ruby-prof+Convenience+API">ruby-prof Convenience API</a>
66
- <li><a href="#label-Profiling+Selected+Threads+-28Core+API-29">Profiling Selected Threads (Core API)</a>
67
- <li><a href="#label-Method+Elimination+-28Deprecated-29">Method Elimination (Deprecated)</a>
68
- <li><a href="#label-Method+Exclusion">Method Exclusion</a>
69
- <li><a href="#label-Profiling+Rails">Profiling Rails</a>
70
- <li><a href="#label-Reports">Reports</a>
71
- <li><a href="#label-Printers">Printers</a>
72
- <li><a href="#label-Measurements">Measurements</a>
73
- <li><a href="#label-Patching+ruby">Patching ruby</a>
74
- <li><a href="#label-Measure+modes">Measure modes</a>
75
- <li><a href="#label-Multi-threaded+Applications">Multi-threaded Applications</a>
76
- <li><a href="#label-Performance">Performance</a>
77
- <li><a href="#label-Editing+links">Editing links</a>
78
- <li><a href="#label-License">License</a>
79
- <li><a href="#label-API+Documentation">API Documentation</a>
80
- <li><a href="#label-Development">Development</a>
81
- </ul>
82
- </div>
83
-
84
-
85
- <div id="project-metadata">
86
- <div id="fileindex-section" class="nav-section">
87
- <h3>Pages</h3>
88
-
89
- <ul class="link-list">
90
-
91
- <li><a href="./LICENSE.html">LICENSE</a>
92
-
93
- <li><a href="./README_rdoc.html">README</a>
94
-
95
- <li><a href="./examples/flat_txt.html">flat</a>
96
-
97
- <li><a href="./examples/graph_html.html">graph.html</a>
98
-
99
- <li><a href="./examples/graph_txt.html">graph</a>
100
-
101
- </ul>
102
- </div>
103
-
104
- </div>
105
- </nav>
106
-
107
- <main role="main" aria-label="Page README.rdoc">
108
-
109
- <h1 id="label-ruby-prof">ruby-prof<span><a href="#label-ruby-prof">&para;</a> <a href="#top">&uarr;</a></span></h1>
110
-
111
- <p><a href="https://travis-ci.org/ruby-prof/ruby-prof"><img
112
- src="https://travis-ci.org/ruby-prof/ruby-prof.png?branch=master"
113
- alt="Build Status" /></a></p>
114
-
115
- <h2 id="label-Overview">Overview<span><a href="#label-Overview">&para;</a> <a href="#top">&uarr;</a></span></h2>
116
-
117
- <p>ruby-prof is a fast code profiler for MRI Ruby. Its features include:</p>
118
- <ul><li>
119
- <p>Speed - it is a C extension and therefore many times faster than the
120
- standard Ruby profiler.</p>
121
- </li><li>
122
- <p>Modes - Ruby prof can measure a number of different parameters, including
123
- call times, memory usage and object allocations.</p>
124
- </li><li>
125
- <p>Reports - can generate text and cross-referenced html reports</p>
126
- <ul><li>
127
- <p>Flat Profiles - similar to the reports generated by the standard Ruby
128
- profiler</p>
129
- </li><li>
130
- <p>Graph profiles - similar to GProf, these show how long a method runs, which
131
- methods call it and which methods it calls.</p>
132
- </li><li>
133
- <p>Call tree profiles - outputs results in the calltree format suitable for
134
- the KCacheGrind profiling tool.</p>
135
- </li><li>
136
- <p>Many more – see reports section of this README.</p>
137
- </li></ul>
138
- </li><li>
139
- <p>Threads - supports profiling multiple threads simultaneously</p>
140
- </li></ul>
141
-
142
- <h2 id="label-Requirements">Requirements<span><a href="#label-Requirements">&para;</a> <a href="#top">&uarr;</a></span></h2>
143
-
144
- <p>ruby-prof requires Ruby 1.9.3 or higher. Please note some ruby releases
145
- have known bugs which cause ruby-prof problems, like incorrect
146
- measurements. We suggest to use the latest minor patch level release if
147
- possible. In particular, on the 2.1 branch of ruby you should use at least
148
- 2.1.7.</p>
149
-
150
- <p>If you are running Linux or Unix you&#39;ll need a C compiler so the
151
- extension can be compiled when it is installed.</p>
152
-
153
- <p>If you are running Windows, then you may need to install the Windows
154
- specific RubyGem which includes an already built extension (see Install
155
- section).</p>
156
-
157
- <h2 id="label-Install">Install<span><a href="#label-Install">&para;</a> <a href="#top">&uarr;</a></span></h2>
158
-
159
- <p>The easiest way to install ruby-prof is by using Ruby Gems. To install:</p>
160
-
161
- <pre class="ruby"><span class="ruby-identifier">gem</span> <span class="ruby-identifier">install</span> <span class="ruby-identifier">ruby</span><span class="ruby-operator">-</span><span class="ruby-identifier">prof</span>
162
- </pre>
163
-
164
- <p>If you&#39;re on windows then please install the devkit first so that it
165
- can compile.</p>
166
-
167
- <h2 id="label-Usage">Usage<span><a href="#label-Usage">&para;</a> <a href="#top">&uarr;</a></span></h2>
168
-
169
- <p>There are three major options for running ruby-prof: via the command line,
170
- via its convenience API or via its core API.</p>
171
-
172
- <h3 id="label-ruby-prof+Executable">ruby-prof Executable<span><a href="#label-ruby-prof+Executable">&para;</a> <a href="#top">&uarr;</a></span></h3>
173
-
174
- <p>The first is to use ruby-prof to run the Ruby program you want to profile.
175
- For more information refer to the documentation of the ruby-prof command:
176
- `$ ruby-prof -h.`</p>
177
-
178
- <h3 id="label-ruby-prof+Convenience+API">ruby-prof Convenience API<span><a href="#label-ruby-prof+Convenience+API">&para;</a> <a href="#top">&uarr;</a></span></h3>
179
-
180
- <p>The second way is to use the ruby-prof convenience API to profile
181
- particular segments of code.</p>
182
-
183
- <pre class="ruby"><span class="ruby-identifier">require</span> <span class="ruby-string">&#39;ruby-prof&#39;</span>
184
-
185
- <span class="ruby-comment"># profile the code</span>
186
- <span class="ruby-constant">RubyProf</span>.<span class="ruby-identifier">start</span>
187
- <span class="ruby-comment"># ... code to profile ...</span>
188
- <span class="ruby-identifier">result</span> = <span class="ruby-constant">RubyProf</span>.<span class="ruby-identifier">stop</span>
189
-
190
- <span class="ruby-comment"># print a flat profile to text</span>
191
- <span class="ruby-identifier">printer</span> = <span class="ruby-constant">RubyProf</span><span class="ruby-operator">::</span><span class="ruby-constant">FlatPrinter</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">result</span>)
192
- <span class="ruby-identifier">printer</span>.<span class="ruby-identifier">print</span>(<span class="ruby-constant">STDOUT</span>)
193
- </pre>
194
-
195
- <p>Alternatively, you can use a block to tell ruby-prof what to profile:</p>
196
-
197
- <pre class="ruby"><span class="ruby-identifier">require</span> <span class="ruby-string">&#39;ruby-prof&#39;</span>
198
-
199
- <span class="ruby-comment"># profile the code</span>
200
- <span class="ruby-identifier">result</span> = <span class="ruby-constant">RubyProf</span>.<span class="ruby-identifier">profile</span> <span class="ruby-keyword">do</span>
201
- <span class="ruby-comment"># ... code to profile ...</span>
202
- <span class="ruby-keyword">end</span>
203
-
204
- <span class="ruby-comment"># print a graph profile to text</span>
205
- <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>)
206
- <span class="ruby-identifier">printer</span>.<span class="ruby-identifier">print</span>(<span class="ruby-constant">STDOUT</span>, {})
207
- </pre>
208
-
209
- <p>ruby-prof also supports pausing and resuming profiling runs.</p>
210
-
211
- <pre class="ruby"><span class="ruby-identifier">require</span> <span class="ruby-string">&#39;ruby-prof&#39;</span>
212
-
213
- <span class="ruby-comment"># profile the code</span>
214
- <span class="ruby-constant">RubyProf</span>.<span class="ruby-identifier">start</span>
215
- <span class="ruby-comment"># ... code to profile ...</span>
216
-
217
- <span class="ruby-constant">RubyProf</span>.<span class="ruby-identifier">pause</span>
218
- <span class="ruby-comment"># ... other code ...</span>
219
-
220
- <span class="ruby-constant">RubyProf</span>.<span class="ruby-identifier">resume</span>
221
- <span class="ruby-comment"># ... code to profile ...</span>
222
- <span class="ruby-identifier">result</span> = <span class="ruby-constant">RubyProf</span>.<span class="ruby-identifier">stop</span>
223
- </pre>
224
-
225
- <p>Note that resume will only work if start has been called previously. In
226
- addition, resume can also take a block:</p>
227
-
228
- <pre class="ruby"><span class="ruby-identifier">require</span> <span class="ruby-string">&#39;ruby-prof&#39;</span>
229
-
230
- <span class="ruby-constant">RubyProf</span>.<span class="ruby-identifier">resume</span> <span class="ruby-keyword">do</span>
231
- <span class="ruby-comment"># ... code to profile...</span>
232
- <span class="ruby-keyword">end</span>
233
-
234
- <span class="ruby-identifier">result</span> = <span class="ruby-constant">RubyProf</span>.<span class="ruby-identifier">stop</span>
235
- </pre>
236
-
237
- <p>With this usage, resume will automatically call pause at the end of the
238
- block.</p>
239
-
240
- <h3 id="label-Profiling+Selected+Threads+-28Core+API-29">Profiling Selected Threads (Core API)<span><a href="#label-Profiling+Selected+Threads+-28Core+API-29">&para;</a> <a href="#top">&uarr;</a></span></h3>
241
-
242
- <p>The convenience API does not support running multiple profiles in separate
243
- threads concurrently, but the <a
244
- href="RubyProf/Profile.html">RubyProf::Profile</a> API does. In fact, the
245
- convenience layer uses the Profile API internally. It all revolves around
246
- Profile objects:</p>
247
- <dl class="rdoc-list note-list"><dt><a href="RubyProf/Profile.html#method-c-new">RubyProf::Profile.new</a>
248
- <dd>
249
- <p>Create a profile object given an options hash (see below)</p>
250
-
251
- <p>The following options are available when creating Profile instances:</p>
252
- <dl class="rdoc-list note-list"><dt>measure_mode
253
- <dd>
254
- <p>One of the defined measure modes</p>
255
- </dd><dt>exclude_threads
256
- <dd>
257
- <p>Array of threads which should not be profiled.</p>
258
- </dd><dt>include_threads
259
- <dd>
260
- <p>Array of threads which should be profiled. All other threads will be
261
- ignored.</p>
262
- </dd><dt>merge_fibers
263
- <dd>
264
- <p>Whether profiling data for a given thread&#39;s fibers should all be
265
- subsumed under a single entry. Basically only useful to produce callgrind
266
- profiles.</p>
267
- </dd></dl>
268
- </dd><dt><a href="RubyProf/Profile.html#method-i-start">RubyProf::Profile#start</a>
269
- <dd>
270
- <p>Start profiling</p>
271
- </dd><dt><a href="RubyProf/Profile.html#method-i-pause">RubyProf::Profile#pause</a>
272
- <dd>
273
- <p>Pause profiling</p>
274
- </dd><dt><a href="RubyProf/Profile.html#method-i-resume">RubyProf::Profile#resume</a>
275
- <dd>
276
- <p>Resume profiling</p>
277
- </dd><dt><a href="RubyProf/Profile.html#method-i-stop">RubyProf::Profile#stop</a>
278
- <dd>
279
- <p>Stop profiling and return self</p>
280
- </dd><dt><a href="RubyProf/Profile.html#method-i-profile">RubyProf::Profile#profile</a>
281
- <dd>
282
- <p>Perform a profile run and return result. Accepts the same arguments as <a
283
- href="RubyProf/Profile.html#method-c-new">RubyProf::Profile.new</a>.</p>
284
- </dd></dl>
285
-
286
- <h2 id="label-Method+Elimination+-28Deprecated-29">Method Elimination (Deprecated)<span><a href="#label-Method+Elimination+-28Deprecated-29">&para;</a> <a href="#top">&uarr;</a></span></h2>
287
-
288
- <p>ruby-prof supports eliminating specific methods and threads from profiling
289
- results. This is useful for reducing connectivity in the call graph, making
290
- it easier to identify the source of performance problems when using a graph
291
- printer.</p>
292
-
293
- <p>For example, consider <code>Integer#times</code>: it&#39;s hardly ever
294
- useful to know how much time is spent in the method itself. We&#39;re much
295
- more interested in how much the passed in block contributes to the time
296
- spent in the method which contains the <code>Integer#times</code> call.</p>
297
-
298
- <p>Methods are eliminated from the collected data by calling
299
- <code>eliminate_methods!</code> on the profiling result, before submitting
300
- it to a printer.</p>
301
-
302
- <pre class="ruby"><span class="ruby-identifier">result</span> = <span class="ruby-constant">RubyProf</span>.<span class="ruby-identifier">stop</span>
303
- <span class="ruby-identifier">result</span>.<span class="ruby-identifier">eliminate_methods!</span>([<span class="ruby-node">/Integer#times/</span>])
304
- </pre>
305
-
306
- <p>The argument given to <code>eliminate_methods!</code> is either an array of
307
- regular expressions, or the name of a file containing a list of regular
308
- expressions (line separated text).</p>
309
-
310
- <p>After eliminating methods the resulting profile will appear exactly as if
311
- those methods had been inlined at their call sites.</p>
312
-
313
- <h2 id="label-Method+Exclusion">Method Exclusion<span><a href="#label-Method+Exclusion">&para;</a> <a href="#top">&uarr;</a></span></h2>
314
-
315
- <p>ruby-prof supports exluding methods from profiling. The effect on collected
316
- metrics are identical to eliminating methods from the profiling result in a
317
- prost process step. The interface is slightly different though:</p>
318
-
319
- <pre>profile = RubyProf.new(...)
320
- profile.exclude_methods!(Integer, :times, ...)
321
- profile.start</pre>
322
-
323
- <p>A convenience method is provided to exclude a large number of methods which
324
- usually clutter up profiles:</p>
325
-
326
- <pre class="ruby"><span class="ruby-identifier">profile</span>.<span class="ruby-identifier">exclude_common_methods!</span>
327
- </pre>
328
-
329
- <p>However, this is a somewhat opinionated method collection. It&#39;s usually
330
- better to view it as an inspiration instead of using it directly (see <a
331
- href="https://github.com/ruby-prof/ruby-prof/blob/e087b7d7ca11eecf1717d95a5c5fea1e36ea3136/lib/ruby-prof/profile/exclude_common_methods.rb">github.com/ruby-prof/ruby-prof/blob/e087b7d7ca11eecf1717d95a5c5fea1e36ea3136/lib/ruby-prof/profile/exclude_common_methods.rb</a>).</p>
332
-
333
- <h2 id="label-Profiling+Rails">Profiling Rails<span><a href="#label-Profiling+Rails">&para;</a> <a href="#top">&uarr;</a></span></h2>
334
-
335
- <p>To profile a Rails application it is vital to run it using production like
336
- settings (cache classes, cache view lookups, etc.). Otherwise, Rail&#39;s
337
- dependency loading code will overwhelm any time spent in the application
338
- itself (our tests show that Rails dependency loading causes a roughly 6x
339
- slowdown). The best way to do this is create a new Rails environment,
340
- profile.rb.</p>
341
-
342
- <p>So to profile Rails:</p>
343
- <ol><li>
344
- <p>Create a new profile.rb environment. Make sure to turn on
345
- <code>cache_classes</code> and <code>cache_template_loading</code>.
346
- Otherwise your profiling results will be overwhelmed by the time Rails
347
- spends loading required files. You should likely turn off caching.</p>
348
- </li><li>
349
- <p>Add the ruby-prof to your gemfile:</p>
350
-
351
- <pre class="ruby"><span class="ruby-identifier">group</span> :<span class="ruby-identifier">profile</span> <span class="ruby-keyword">do</span>
352
- <span class="ruby-identifier">gem</span> <span class="ruby-string">&#39;ruby-prof&#39;</span>
353
- <span class="ruby-keyword">end</span>
354
- </pre>
355
- </li><li>
356
- <p>Add the ruby prof rack adapter to your middleware stack. One way to do
357
- this is by adding the following code to <code>config.ru</code>:</p>
358
-
359
- <pre class="ruby"><span class="ruby-keyword">if</span> <span class="ruby-constant">Rails</span>.<span class="ruby-identifier">env</span>.<span class="ruby-identifier">profile?</span>
360
- <span class="ruby-identifier">use</span> <span class="ruby-constant">Rack</span><span class="ruby-operator">::</span><span class="ruby-constant">RubyProf</span>, :<span class="ruby-identifier">path</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-string">&#39;/temp/profile&#39;</span>
361
- <span class="ruby-keyword">end</span>
362
- </pre>
363
-
364
- <p>The path is where you want profiling results to be stored. By default the
365
- rack adapter will generate a html call graph report and flat text report.</p>
366
- </li><li>
367
- <p>Now make a request to your running server. New profiling information will
368
- be generated for each request. Note that each request will overwrite the
369
- profiling reports created by the previous request!</p>
370
- </li></ol>
371
-
372
- <h2 id="label-Reports">Reports<span><a href="#label-Reports">&para;</a> <a href="#top">&uarr;</a></span></h2>
373
-
374
- <p>ruby-prof can generate a number of different reports:</p>
375
- <ul><li>
376
- <p>Flat Reports</p>
377
- </li><li>
378
- <p>Graph Reports</p>
379
- </li><li>
380
- <p>HTML Graph Reports</p>
381
- </li><li>
382
- <p>Call graphs</p>
383
- </li><li>
384
- <p>Call stack reports</p>
385
- </li><li>
386
- <p>More!</p>
387
- </li></ul>
388
-
389
- <p>Flat profiles show the overall time spent in each method. They are a good
390
- way of quickly identifying which methods take the most time. An example of
391
- a flat profile and an explanation can be found in <a
392
- href="http://github.com/ruby-prof/ruby-prof/tree/master/examples/flat.txt">examples/flat.txt</a>.</p>
393
-
394
- <p>There are several varieties of these - run <code>ruby-prof --help</code></p>
395
-
396
- <p>Graph profiles also show the overall time spent in each method. In
397
- addition, they also show which methods call the current method and which
398
- methods its calls. Thus they are good for understanding how methods gets
399
- called and provide insight into the flow of your program. An example text
400
- graph profile is located at <a
401
- href="http://github.com/ruby-prof/ruby-prof/tree/master/examples/graph.txt">examples/graph.txt</a>.</p>
402
-
403
- <p>HTML Graph profiles are the same as graph profiles, except output is
404
- generated in hyper-linked HTML. Since graph profiles can be quite large,
405
- the embedded links make it much easier to navigate the results. An example
406
- html graph profile is located at <a
407
- href="http://github.com/ruby-prof/ruby-prof/tree/master/examples/graph.html">examples/graph.html</a>.</p>
408
-
409
- <p>Call graphs output results in the calltree profile format which is used by
410
- KCachegrind. Call graph support was generously donated by Carl Shimer. More
411
- information about the format can be found at the <a
412
- href="http://kcachegrind.sourceforge.net/cgi-bin/show.cgi/KcacheGrindCalltreeFormat">KCachegrind</a>
413
- site.</p>
414
-
415
- <p>Call stack reports produce a HTML visualization of the time spent in each
416
- execution path of the profiled code. An example can be found at <a
417
- href="http://github.com/ruby-prof/ruby-prof/tree/master/examples/stack.html">examples/stack.html</a>.</p>
418
-
419
- <p>Another good example: <a
420
- href="http://twitpic.com/28z94a">twitpic.com/28z94a</a></p>
421
-
422
- <p>Finally, there&#39;s a so called MultiPrinter which can generate several
423
- reports in one profiling run. See <a
424
- href="http://github.com/ruby-prof/ruby-prof/tree/master/examples/multi.stack.html">examples/multi.stack.html</a>.</p>
425
-
426
- <p>There is also a graphviz .dot visualiser.</p>
427
-
428
- <h2 id="label-Printers">Printers<span><a href="#label-Printers">&para;</a> <a href="#top">&uarr;</a></span></h2>
429
-
430
- <p>Reports are created by printers. Supported printers include:</p>
431
- <dl class="rdoc-list note-list"><dt><a href="RubyProf/FlatPrinter.html">RubyProf::FlatPrinter</a>
432
- <dd>
433
- <p>Creates a flat report in text format</p>
434
- </dd><dt><a href="RubyProf/FlatPrinterWithLineNumbers.html">RubyProf::FlatPrinterWithLineNumbers</a>
435
- <dd>
436
- <p>Same as above but more verbose</p>
437
- </dd><dt><a href="RubyProf/GraphPrinter.html">RubyProf::GraphPrinter</a>
438
- <dd>
439
- <p>Creates a call graph report in text format</p>
440
- </dd><dt><a href="RubyProf/GraphHtmlPrinter.html">RubyProf::GraphHtmlPrinter</a>
441
- <dd>
442
- <p>Creates a call graph report in HTML (separate files per thread)</p>
443
- </dd><dt><a href="RubyProf/DotPrinter.html">RubyProf::DotPrinter</a>
444
- <dd>
445
- <p>Creates a call graph report in GraphViz&#39;s DOT format which can be
446
- converted to an image</p>
447
- </dd><dt><a href="RubyProf/CallTreePrinter.html">RubyProf::CallTreePrinter</a>
448
- <dd>
449
- <p>Creates a call tree report compatible with KCachegrind</p>
450
- </dd><dt><a href="RubyProf/CallStackPrinter.html">RubyProf::CallStackPrinter</a>
451
- <dd>
452
- <p>Creates a HTML visualization of the Ruby stack</p>
453
- </dd><dt><a href="RubyProf/MultiPrinter.html">RubyProf::MultiPrinter</a>
454
- <dd>
455
- <p>Uses the other printers to create several reports in one profiling run</p>
456
- </dd></dl>
457
-
458
- <p>Most printers are used in the following way:</p>
459
-
460
- <pre class="ruby"><span class="ruby-identifier">result</span> = <span class="ruby-constant">RubyProf</span>.<span class="ruby-identifier">stop</span>
461
- <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>)
462
- <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">&gt;</span> <span class="ruby-value">2</span>)
463
- </pre>
464
-
465
- <p>The first parameter is any writable IO object such as <code>STDOUT</code>
466
- or a file. The second parameter, specifies the minimum percentage a method
467
- must take to be printed. Percentages should be specified as integers in
468
- the range 0 to 100. For more information please see the documentation for
469
- the different printers.</p>
470
-
471
- <p>The other option is <code>:print_file =&gt; true</code> (default false),
472
- which adds the filename to the output (GraphPrinter only).</p>
473
-
474
- <p><code>MultiPrinter</code> and <code>CallTreePrinter</code>differ from the
475
- other printers in that they require a directory path and a profile basename
476
- for the files they produce:</p>
477
-
478
- <pre class="ruby"><span class="ruby-identifier">printer</span> = <span class="ruby-constant">RubyProf</span><span class="ruby-operator">::</span><span class="ruby-constant">MultiPrinter</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">result</span>)
479
- <span class="ruby-identifier">printer</span>.<span class="ruby-identifier">print</span>(:<span class="ruby-identifier">path</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-string">&quot;.&quot;</span>, :<span class="ruby-identifier">profile</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-string">&quot;profile&quot;</span>)
480
- </pre>
481
-
482
- <p>The values given in the example above are the defaults.</p>
483
-
484
- <h2 id="label-Measurements">Measurements<span><a href="#label-Measurements">&para;</a> <a href="#top">&uarr;</a></span></h2>
485
-
486
- <p>Depending on the mode and platform, ruby-prof can measure various aspects
487
- of a Ruby program. Supported measurements include:</p>
488
- <dl class="rdoc-list note-list"><dt>RubyProf::WALL_TIME
489
- <dd>
490
- <p>Wall time measures the real-world time elapsed between any two moments. If
491
- there are other processes concurrently running on the system that use
492
- significant CPU or disk time during a profiling run then the reported
493
- results will be larger than expected.</p>
494
- </dd><dt>RubyProf::PROCESS_TIME
495
- <dd>
496
- <p>Process time measures the time used by a process between any two moments.
497
- It is unaffected by other processes concurrently running on the system.
498
- Note that Windows does not support measuring process times.</p>
499
- </dd><dt>RubyProf::CPU_TIME
500
- <dd>
501
- <p>CPU time uses the CPU clock counter to measure time. The returned values
502
- are dependent on the correctly setting the CPU&#39;s frequency. This mode
503
- is only supported on Pentium or PowerPC platforms (linux only).</p>
504
- </dd><dt>RubyProf::ALLOCATIONS
505
- <dd>
506
- <p>Object allocation reports show how many objects each method in a program
507
- allocates. This support was added by Sylvain Joyeux and requires a patched
508
- Ruby interpreter. See below.</p>
509
- </dd><dt>RubyProf::MEMORY
510
- <dd>
511
- <p>Memory usage reports show how much memory each method in a program uses.
512
- This support was added by Alexander Dymo and requires a patched Ruby
513
- interpreter. See below.</p>
514
- </dd><dt>RubyProf::GC_TIME
515
- <dd>
516
- <p>Garbage collection time reports how much time is spent in Ruby&#39;s
517
- garbage collector during a profiling session. This support was added by
518
- Jeremy Kemper and requires a patched Ruby interpreter. See below.</p>
519
- </dd><dt>RubyProf::GC_RUNS
520
- <dd>
521
- <p>Garbage collection runs report how many times Ruby&#39;s garbage collector
522
- is invoked during a profiling session. This support was added by Jeremy
523
- Kemper and requires a patched Ruby interpreter. See below.</p>
524
- </dd></dl>
525
-
526
- <h2 id="label-Patching+ruby">Patching ruby<span><a href="#label-Patching+ruby">&para;</a> <a href="#top">&uarr;</a></span></h2>
527
-
528
- <p>All of the patches to Ruby are included in the railsexpress patchsets for
529
- rvm, see <a
530
- href="https://github.com/skaes/rvm-patchsets">github.com/skaes/rvm-patchsets</a>.
531
- You can also use these patches manually with other ruby managers
532
- (ruby-install, ruby-build, etc.).</p>
533
-
534
- <p>Note if you rebuild your ruby with patches you must uninstall and reinstall
535
- the ruby-prof gem to take advantage of the new capabilities.</p>
536
-
537
- <h2 id="label-Measure+modes">Measure modes<span><a href="#label-Measure+modes">&para;</a> <a href="#top">&uarr;</a></span></h2>
538
-
539
- <p>To set the measurement:</p>
540
-
541
- <pre class="ruby"><span class="ruby-constant">RubyProf</span>.<span class="ruby-identifier">measure_mode</span> = <span class="ruby-constant">RubyProf</span><span class="ruby-operator">::</span><span class="ruby-constant">WALL_TIME</span>
542
- <span class="ruby-constant">RubyProf</span>.<span class="ruby-identifier">measure_mode</span> = <span class="ruby-constant">RubyProf</span><span class="ruby-operator">::</span><span class="ruby-constant">PROCESS_TIME</span>
543
- <span class="ruby-constant">RubyProf</span>.<span class="ruby-identifier">measure_mode</span> = <span class="ruby-constant">RubyProf</span><span class="ruby-operator">::</span><span class="ruby-constant">CPU_TIME</span>
544
- <span class="ruby-constant">RubyProf</span>.<span class="ruby-identifier">measure_mode</span> = <span class="ruby-constant">RubyProf</span><span class="ruby-operator">::</span><span class="ruby-constant">ALLOCATIONS</span>
545
- <span class="ruby-constant">RubyProf</span>.<span class="ruby-identifier">measure_mode</span> = <span class="ruby-constant">RubyProf</span><span class="ruby-operator">::</span><span class="ruby-constant">MEMORY</span>
546
- <span class="ruby-constant">RubyProf</span>.<span class="ruby-identifier">measure_mode</span> = <span class="ruby-constant">RubyProf</span><span class="ruby-operator">::</span><span class="ruby-constant">GC_TIME</span>
547
- <span class="ruby-constant">RubyProf</span>.<span class="ruby-identifier">measure_mode</span> = <span class="ruby-constant">RubyProf</span><span class="ruby-operator">::</span><span class="ruby-constant">GC_RUNS</span>
548
- </pre>
549
-
550
- <p>The default value is <code>RubyProf::WALL_TIME</code>.</p>
551
-
552
- <p>You may also specify the measure mode by using the
553
- <code>RUBY_PROF_MEASURE_MODE</code> environment variable:</p>
554
-
555
- <pre class="ruby"><span class="ruby-identifier">export</span> <span class="ruby-constant">RUBY_PROF_MEASURE_MODE</span>=<span class="ruby-identifier">wall</span>
556
- <span class="ruby-identifier">export</span> <span class="ruby-constant">RUBY_PROF_MEASURE_MODE</span>=<span class="ruby-identifier">process</span>
557
- <span class="ruby-identifier">export</span> <span class="ruby-constant">RUBY_PROF_MEASURE_MODE</span>=<span class="ruby-identifier">cpu</span>
558
- <span class="ruby-identifier">export</span> <span class="ruby-constant">RUBY_PROF_MEASURE_MODE</span>=<span class="ruby-identifier">allocations</span>
559
- <span class="ruby-identifier">export</span> <span class="ruby-constant">RUBY_PROF_MEASURE_MODE</span>=<span class="ruby-identifier">memory</span>
560
- <span class="ruby-identifier">export</span> <span class="ruby-constant">RUBY_PROF_MEASURE_MODE</span>=<span class="ruby-identifier">gc_time</span>
561
- <span class="ruby-identifier">export</span> <span class="ruby-constant">RUBY_PROF_MEASURE_MODE</span>=<span class="ruby-identifier">gc_runs</span>
562
- </pre>
563
-
564
- <p>On Linux, process time is measured using the clock method provided by the C
565
- runtime library. Note that the clock method does not report time spent in
566
- the kernel or child processes and therefore does not measure time spent in
567
- methods such as Kernel.sleep method. If you need to measure these values,
568
- then use wall time. Wall time is measured using the gettimeofday kernel
569
- method.</p>
570
-
571
- <p>If you set the clock mode to <code>PROCESS_TIME</code>, then timings are
572
- read using the clock method provided by the C runtime library. Note
573
- though, these values are wall times on Windows and not process times like
574
- on Linux. Wall time is measured using the GetLocalTime API.</p>
575
-
576
- <p>If you use wall time, the results will be affected by other processes
577
- running on your computer, network delays, disk access, etc. As result, for
578
- the best results, try to make sure your computer is only performing your
579
- profiling run and is otherwise quiescent.</p>
580
-
581
- <h2 id="label-Multi-threaded+Applications">Multi-threaded Applications<span><a href="#label-Multi-threaded+Applications">&para;</a> <a href="#top">&uarr;</a></span></h2>
582
-
583
- <p>Unfortunately, Ruby does not provide an internal API for detecting thread
584
- context switches. As a result, the timings ruby-prof reports for each
585
- thread may be slightly inaccurate. In particular, this will happen for
586
- newly spawned threads that go to sleep immediately (their first call). For
587
- instance, if you use Ruby&#39;s timeout library to wait for 2 seconds, the
588
- 2 seconds will be assigned to the foreground thread and not the newly
589
- created background thread. These errors can largely be avoided if the
590
- background thread performs any operation before going to sleep.</p>
591
-
592
- <h2 id="label-Performance">Performance<span><a href="#label-Performance">&para;</a> <a href="#top">&uarr;</a></span></h2>
593
-
594
- <p>Significant effort has been put into reducing ruby-prof&#39;s overhead as
595
- much as possible. Our tests show that the overhead associated with
596
- profiling code varies considerably with the code being profiled. Most
597
- programs will run approximately twice as slow while highly recursive
598
- programs (like the fibonacci series test) will run three times slower.</p>
599
-
600
- <h2 id="label-Editing+links">Editing links<span><a href="#label-Editing+links">&para;</a> <a href="#top">&uarr;</a></span></h2>
601
-
602
- <p>Use <code>RUBY_PROF_EDITOR_URI</code> environment variable to open source
603
- code files in your favorite text editor. For example,
604
- <code>RUBY_PROF_EDITOR_URI=atm</code> will produce links for Atom text
605
- editor.</p>
606
-
607
- <h2 id="label-License">License<span><a href="#label-License">&para;</a> <a href="#top">&uarr;</a></span></h2>
608
-
609
- <p>See <a href="LICENSE.html">LICENSE</a> for license information.</p>
610
-
611
- <h2 id="label-API+Documentation">API Documentation<span><a href="#label-API+Documentation">&para;</a> <a href="#top">&uarr;</a></span></h2>
612
-
613
- <p>The ruby-prof API documentation for the latest released gem version can be
614
- found here: <a
615
- href="http://www.rubydoc.info/gems/ruby-prof">www.rubydoc.info/gems/ruby-prof</a>/</p>
616
-
617
- <p>The ruby-prof API documentation for the master branch is available here: <a
618
- href="http://www.rubydoc.info/github/ruby-prof/ruby-prof">www.rubydoc.info/github/ruby-prof/ruby-prof</a>/</p>
619
-
620
- <h2 id="label-Development">Development<span><a href="#label-Development">&para;</a> <a href="#top">&uarr;</a></span></h2>
621
-
622
- <p>Code is located at <a
623
- href="https://github.com/ruby-prof/ruby-prof">github.com/ruby-prof/ruby-prof</a></p>
624
-
625
- <p>Google group/mailing list: <a
626
- href="http://groups.google.com/group/ruby-optimization">groups.google.com/group/ruby-optimization</a>
627
- or open a github issue.</p>
628
- </main>
629
-
630
-
631
-
632
- <footer id="validator-badges" role="contentinfo">
633
- <p><a href="http://validator.w3.org/check/referer">Validate</a>
634
- <p>Generated by <a href="https://rdoc.github.io/rdoc">RDoc</a> 5.1.0.
635
- <p>Based on <a href="http://deveiate.org/projects/Darkfish-RDoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
636
- </footer>
637
-