ruby-prof 1.0.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 (97) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGES +523 -0
  3. data/LICENSE +25 -0
  4. data/README.rdoc +5 -0
  5. data/Rakefile +110 -0
  6. data/bin/ruby-prof +380 -0
  7. data/bin/ruby-prof-check-trace +45 -0
  8. data/ext/ruby_prof/extconf.rb +36 -0
  9. data/ext/ruby_prof/rp_allocation.c +292 -0
  10. data/ext/ruby_prof/rp_allocation.h +31 -0
  11. data/ext/ruby_prof/rp_call_info.c +283 -0
  12. data/ext/ruby_prof/rp_call_info.h +35 -0
  13. data/ext/ruby_prof/rp_measure_allocations.c +52 -0
  14. data/ext/ruby_prof/rp_measure_memory.c +42 -0
  15. data/ext/ruby_prof/rp_measure_process_time.c +63 -0
  16. data/ext/ruby_prof/rp_measure_wall_time.c +62 -0
  17. data/ext/ruby_prof/rp_measurement.c +236 -0
  18. data/ext/ruby_prof/rp_measurement.h +49 -0
  19. data/ext/ruby_prof/rp_method.c +642 -0
  20. data/ext/ruby_prof/rp_method.h +70 -0
  21. data/ext/ruby_prof/rp_profile.c +881 -0
  22. data/ext/ruby_prof/rp_profile.h +36 -0
  23. data/ext/ruby_prof/rp_stack.c +196 -0
  24. data/ext/ruby_prof/rp_stack.h +56 -0
  25. data/ext/ruby_prof/rp_thread.c +338 -0
  26. data/ext/ruby_prof/rp_thread.h +36 -0
  27. data/ext/ruby_prof/ruby_prof.c +48 -0
  28. data/ext/ruby_prof/ruby_prof.h +17 -0
  29. data/ext/ruby_prof/vc/ruby_prof.sln +31 -0
  30. data/ext/ruby_prof/vc/ruby_prof.vcxproj +143 -0
  31. data/lib/ruby-prof.rb +53 -0
  32. data/lib/ruby-prof/assets/call_stack_printer.css.html +117 -0
  33. data/lib/ruby-prof/assets/call_stack_printer.js.html +385 -0
  34. data/lib/ruby-prof/assets/call_stack_printer.png +0 -0
  35. data/lib/ruby-prof/assets/graph_printer.html.erb +356 -0
  36. data/lib/ruby-prof/call_info.rb +57 -0
  37. data/lib/ruby-prof/call_info_visitor.rb +38 -0
  38. data/lib/ruby-prof/compatibility.rb +109 -0
  39. data/lib/ruby-prof/exclude_common_methods.rb +198 -0
  40. data/lib/ruby-prof/measurement.rb +14 -0
  41. data/lib/ruby-prof/method_info.rb +90 -0
  42. data/lib/ruby-prof/printers/abstract_printer.rb +118 -0
  43. data/lib/ruby-prof/printers/call_info_printer.rb +51 -0
  44. data/lib/ruby-prof/printers/call_stack_printer.rb +269 -0
  45. data/lib/ruby-prof/printers/call_tree_printer.rb +151 -0
  46. data/lib/ruby-prof/printers/dot_printer.rb +132 -0
  47. data/lib/ruby-prof/printers/flat_printer.rb +52 -0
  48. data/lib/ruby-prof/printers/graph_html_printer.rb +64 -0
  49. data/lib/ruby-prof/printers/graph_printer.rb +114 -0
  50. data/lib/ruby-prof/printers/multi_printer.rb +127 -0
  51. data/lib/ruby-prof/profile.rb +33 -0
  52. data/lib/ruby-prof/rack.rb +171 -0
  53. data/lib/ruby-prof/task.rb +147 -0
  54. data/lib/ruby-prof/thread.rb +35 -0
  55. data/lib/ruby-prof/version.rb +3 -0
  56. data/lib/unprof.rb +10 -0
  57. data/ruby-prof.gemspec +58 -0
  58. data/test/abstract_printer_test.rb +26 -0
  59. data/test/alias_test.rb +129 -0
  60. data/test/basic_test.rb +129 -0
  61. data/test/call_info_visitor_test.rb +31 -0
  62. data/test/duplicate_names_test.rb +32 -0
  63. data/test/dynamic_method_test.rb +53 -0
  64. data/test/enumerable_test.rb +21 -0
  65. data/test/exceptions_test.rb +24 -0
  66. data/test/exclude_methods_test.rb +146 -0
  67. data/test/exclude_threads_test.rb +53 -0
  68. data/test/line_number_test.rb +161 -0
  69. data/test/marshal_test.rb +119 -0
  70. data/test/measure_allocations.rb +30 -0
  71. data/test/measure_allocations_test.rb +385 -0
  72. data/test/measure_allocations_trace_test.rb +385 -0
  73. data/test/measure_memory_trace_test.rb +756 -0
  74. data/test/measure_process_time_test.rb +849 -0
  75. data/test/measure_times.rb +54 -0
  76. data/test/measure_wall_time_test.rb +459 -0
  77. data/test/multi_printer_test.rb +71 -0
  78. data/test/no_method_class_test.rb +15 -0
  79. data/test/parser_timings.rb +24 -0
  80. data/test/pause_resume_test.rb +166 -0
  81. data/test/prime.rb +56 -0
  82. data/test/printer_call_tree_test.rb +31 -0
  83. data/test/printer_flat_test.rb +68 -0
  84. data/test/printer_graph_html_test.rb +60 -0
  85. data/test/printer_graph_test.rb +41 -0
  86. data/test/printers_test.rb +141 -0
  87. data/test/printing_recursive_graph_test.rb +81 -0
  88. data/test/rack_test.rb +157 -0
  89. data/test/recursive_test.rb +210 -0
  90. data/test/singleton_test.rb +38 -0
  91. data/test/stack_printer_test.rb +64 -0
  92. data/test/start_stop_test.rb +109 -0
  93. data/test/test_helper.rb +24 -0
  94. data/test/thread_test.rb +144 -0
  95. data/test/unique_call_path_test.rb +190 -0
  96. data/test/yarv_test.rb +56 -0
  97. metadata +189 -0
@@ -0,0 +1,56 @@
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
+
33
+ def define_methods
34
+ return if respond_to?(:array_push_optimized)
35
+ old_compile_option = RubyVM::InstructionSequence.compile_option
36
+ RubyVM::InstructionSequence.compile_option = {
37
+ :trace_instruction => true,
38
+ :specialized_instruction => false
39
+ }
40
+ self.class.class_eval <<-"EOM"
41
+ def array_push_unoptimized
42
+ a = []
43
+ a << 1
44
+ a.push 2
45
+ end
46
+ EOM
47
+ RubyVM::InstructionSequence.compile_option = old_compile_option
48
+ self.class.class_eval <<-"EOM"
49
+ def array_push_optimized
50
+ a = []
51
+ a << 1
52
+ a.push 2
53
+ end
54
+ EOM
55
+ end
56
+ end
metadata ADDED
@@ -0,0 +1,189 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ruby-prof
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Shugo Maeda, Charlie Savage, Roger Pack, Stefan Kaes
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2019-07-29 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: minitest
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake-compiler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rdoc
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description: |
56
+ ruby-prof is a fast code profiler for Ruby. It is a C extension and
57
+ therefore is many times faster than the standard Ruby profiler. It
58
+ supports both flat and graph profiles. For each method, graph profiles
59
+ show how long the method ran, which methods called it and which
60
+ methods it called. RubyProf generate both text and html and can output
61
+ it to standard out or to a file.
62
+ email: shugo@ruby-lang.org, cfis@savagexi.com, rogerdpack@gmail.com, skaes@railsexpress.de
63
+ executables:
64
+ - ruby-prof
65
+ - ruby-prof-check-trace
66
+ extensions:
67
+ - ext/ruby_prof/extconf.rb
68
+ extra_rdoc_files: []
69
+ files:
70
+ - CHANGES
71
+ - LICENSE
72
+ - README.rdoc
73
+ - Rakefile
74
+ - bin/ruby-prof
75
+ - bin/ruby-prof-check-trace
76
+ - ext/ruby_prof/extconf.rb
77
+ - ext/ruby_prof/rp_allocation.c
78
+ - ext/ruby_prof/rp_allocation.h
79
+ - ext/ruby_prof/rp_call_info.c
80
+ - ext/ruby_prof/rp_call_info.h
81
+ - ext/ruby_prof/rp_measure_allocations.c
82
+ - ext/ruby_prof/rp_measure_memory.c
83
+ - ext/ruby_prof/rp_measure_process_time.c
84
+ - ext/ruby_prof/rp_measure_wall_time.c
85
+ - ext/ruby_prof/rp_measurement.c
86
+ - ext/ruby_prof/rp_measurement.h
87
+ - ext/ruby_prof/rp_method.c
88
+ - ext/ruby_prof/rp_method.h
89
+ - ext/ruby_prof/rp_profile.c
90
+ - ext/ruby_prof/rp_profile.h
91
+ - ext/ruby_prof/rp_stack.c
92
+ - ext/ruby_prof/rp_stack.h
93
+ - ext/ruby_prof/rp_thread.c
94
+ - ext/ruby_prof/rp_thread.h
95
+ - ext/ruby_prof/ruby_prof.c
96
+ - ext/ruby_prof/ruby_prof.h
97
+ - ext/ruby_prof/vc/ruby_prof.sln
98
+ - ext/ruby_prof/vc/ruby_prof.vcxproj
99
+ - lib/ruby-prof.rb
100
+ - lib/ruby-prof/assets/call_stack_printer.css.html
101
+ - lib/ruby-prof/assets/call_stack_printer.js.html
102
+ - lib/ruby-prof/assets/call_stack_printer.png
103
+ - lib/ruby-prof/assets/graph_printer.html.erb
104
+ - lib/ruby-prof/call_info.rb
105
+ - lib/ruby-prof/call_info_visitor.rb
106
+ - lib/ruby-prof/compatibility.rb
107
+ - lib/ruby-prof/exclude_common_methods.rb
108
+ - lib/ruby-prof/measurement.rb
109
+ - lib/ruby-prof/method_info.rb
110
+ - lib/ruby-prof/printers/abstract_printer.rb
111
+ - lib/ruby-prof/printers/call_info_printer.rb
112
+ - lib/ruby-prof/printers/call_stack_printer.rb
113
+ - lib/ruby-prof/printers/call_tree_printer.rb
114
+ - lib/ruby-prof/printers/dot_printer.rb
115
+ - lib/ruby-prof/printers/flat_printer.rb
116
+ - lib/ruby-prof/printers/graph_html_printer.rb
117
+ - lib/ruby-prof/printers/graph_printer.rb
118
+ - lib/ruby-prof/printers/multi_printer.rb
119
+ - lib/ruby-prof/profile.rb
120
+ - lib/ruby-prof/rack.rb
121
+ - lib/ruby-prof/task.rb
122
+ - lib/ruby-prof/thread.rb
123
+ - lib/ruby-prof/version.rb
124
+ - lib/unprof.rb
125
+ - ruby-prof.gemspec
126
+ - test/abstract_printer_test.rb
127
+ - test/alias_test.rb
128
+ - test/basic_test.rb
129
+ - test/call_info_visitor_test.rb
130
+ - test/duplicate_names_test.rb
131
+ - test/dynamic_method_test.rb
132
+ - test/enumerable_test.rb
133
+ - test/exceptions_test.rb
134
+ - test/exclude_methods_test.rb
135
+ - test/exclude_threads_test.rb
136
+ - test/line_number_test.rb
137
+ - test/marshal_test.rb
138
+ - test/measure_allocations.rb
139
+ - test/measure_allocations_test.rb
140
+ - test/measure_allocations_trace_test.rb
141
+ - test/measure_memory_trace_test.rb
142
+ - test/measure_process_time_test.rb
143
+ - test/measure_times.rb
144
+ - test/measure_wall_time_test.rb
145
+ - test/multi_printer_test.rb
146
+ - test/no_method_class_test.rb
147
+ - test/parser_timings.rb
148
+ - test/pause_resume_test.rb
149
+ - test/prime.rb
150
+ - test/printer_call_tree_test.rb
151
+ - test/printer_flat_test.rb
152
+ - test/printer_graph_html_test.rb
153
+ - test/printer_graph_test.rb
154
+ - test/printers_test.rb
155
+ - test/printing_recursive_graph_test.rb
156
+ - test/rack_test.rb
157
+ - test/recursive_test.rb
158
+ - test/singleton_test.rb
159
+ - test/stack_printer_test.rb
160
+ - test/start_stop_test.rb
161
+ - test/test_helper.rb
162
+ - test/thread_test.rb
163
+ - test/unique_call_path_test.rb
164
+ - test/yarv_test.rb
165
+ homepage: https://github.com/ruby-prof/ruby-prof
166
+ licenses:
167
+ - BSD-2-Clause
168
+ metadata: {}
169
+ post_install_message:
170
+ rdoc_options: []
171
+ require_paths:
172
+ - lib
173
+ required_ruby_version: !ruby/object:Gem::Requirement
174
+ requirements:
175
+ - - ">="
176
+ - !ruby/object:Gem::Version
177
+ version: 2.4.0
178
+ required_rubygems_version: !ruby/object:Gem::Requirement
179
+ requirements:
180
+ - - ">="
181
+ - !ruby/object:Gem::Version
182
+ version: '0'
183
+ requirements: []
184
+ rubygems_version: 3.0.4
185
+ signing_key:
186
+ specification_version: 4
187
+ summary: Fast Ruby profiler
188
+ test_files:
189
+ - test/test_helper.rb