ruby-prof 0.18.0-x64-mingw32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (108) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGES +500 -0
  3. data/LICENSE +25 -0
  4. data/README.rdoc +487 -0
  5. data/Rakefile +113 -0
  6. data/bin/ruby-prof +345 -0
  7. data/bin/ruby-prof-check-trace +45 -0
  8. data/examples/flat.txt +50 -0
  9. data/examples/graph.dot +84 -0
  10. data/examples/graph.html +823 -0
  11. data/examples/graph.txt +139 -0
  12. data/examples/multi.flat.txt +23 -0
  13. data/examples/multi.graph.html +760 -0
  14. data/examples/multi.grind.dat +114 -0
  15. data/examples/multi.stack.html +547 -0
  16. data/examples/stack.html +547 -0
  17. data/ext/ruby_prof/extconf.rb +68 -0
  18. data/ext/ruby_prof/rp_call_info.c +425 -0
  19. data/ext/ruby_prof/rp_call_info.h +53 -0
  20. data/ext/ruby_prof/rp_measure.c +40 -0
  21. data/ext/ruby_prof/rp_measure.h +45 -0
  22. data/ext/ruby_prof/rp_measure_allocations.c +76 -0
  23. data/ext/ruby_prof/rp_measure_cpu_time.c +136 -0
  24. data/ext/ruby_prof/rp_measure_gc_runs.c +73 -0
  25. data/ext/ruby_prof/rp_measure_gc_time.c +60 -0
  26. data/ext/ruby_prof/rp_measure_memory.c +77 -0
  27. data/ext/ruby_prof/rp_measure_process_time.c +71 -0
  28. data/ext/ruby_prof/rp_measure_wall_time.c +45 -0
  29. data/ext/ruby_prof/rp_method.c +630 -0
  30. data/ext/ruby_prof/rp_method.h +75 -0
  31. data/ext/ruby_prof/rp_stack.c +173 -0
  32. data/ext/ruby_prof/rp_stack.h +63 -0
  33. data/ext/ruby_prof/rp_thread.c +277 -0
  34. data/ext/ruby_prof/rp_thread.h +27 -0
  35. data/ext/ruby_prof/ruby_prof.c +794 -0
  36. data/ext/ruby_prof/ruby_prof.h +60 -0
  37. data/ext/ruby_prof/vc/ruby_prof.sln +31 -0
  38. data/ext/ruby_prof/vc/ruby_prof.vcxproj +141 -0
  39. data/lib/2.6.3/ruby_prof.so +0 -0
  40. data/lib/ruby-prof.rb +68 -0
  41. data/lib/ruby-prof/aggregate_call_info.rb +76 -0
  42. data/lib/ruby-prof/assets/call_stack_printer.css.html +117 -0
  43. data/lib/ruby-prof/assets/call_stack_printer.js.html +385 -0
  44. data/lib/ruby-prof/assets/call_stack_printer.png +0 -0
  45. data/lib/ruby-prof/call_info.rb +115 -0
  46. data/lib/ruby-prof/call_info_visitor.rb +40 -0
  47. data/lib/ruby-prof/compatibility.rb +179 -0
  48. data/lib/ruby-prof/method_info.rb +121 -0
  49. data/lib/ruby-prof/printers/abstract_printer.rb +104 -0
  50. data/lib/ruby-prof/printers/call_info_printer.rb +41 -0
  51. data/lib/ruby-prof/printers/call_stack_printer.rb +265 -0
  52. data/lib/ruby-prof/printers/call_tree_printer.rb +143 -0
  53. data/lib/ruby-prof/printers/dot_printer.rb +132 -0
  54. data/lib/ruby-prof/printers/flat_printer.rb +70 -0
  55. data/lib/ruby-prof/printers/flat_printer_with_line_numbers.rb +83 -0
  56. data/lib/ruby-prof/printers/graph_html_printer.rb +249 -0
  57. data/lib/ruby-prof/printers/graph_printer.rb +116 -0
  58. data/lib/ruby-prof/printers/multi_printer.rb +84 -0
  59. data/lib/ruby-prof/profile.rb +26 -0
  60. data/lib/ruby-prof/profile/exclude_common_methods.rb +207 -0
  61. data/lib/ruby-prof/profile/legacy_method_elimination.rb +50 -0
  62. data/lib/ruby-prof/rack.rb +174 -0
  63. data/lib/ruby-prof/task.rb +147 -0
  64. data/lib/ruby-prof/thread.rb +35 -0
  65. data/lib/ruby-prof/version.rb +3 -0
  66. data/lib/unprof.rb +10 -0
  67. data/ruby-prof.gemspec +58 -0
  68. data/test/abstract_printer_test.rb +53 -0
  69. data/test/aggregate_test.rb +136 -0
  70. data/test/basic_test.rb +128 -0
  71. data/test/block_test.rb +74 -0
  72. data/test/call_info_test.rb +78 -0
  73. data/test/call_info_visitor_test.rb +31 -0
  74. data/test/duplicate_names_test.rb +32 -0
  75. data/test/dynamic_method_test.rb +55 -0
  76. data/test/enumerable_test.rb +21 -0
  77. data/test/exceptions_test.rb +24 -0
  78. data/test/exclude_methods_test.rb +146 -0
  79. data/test/exclude_threads_test.rb +53 -0
  80. data/test/fiber_test.rb +79 -0
  81. data/test/issue137_test.rb +63 -0
  82. data/test/line_number_test.rb +80 -0
  83. data/test/measure_allocations_test.rb +26 -0
  84. data/test/measure_cpu_time_test.rb +212 -0
  85. data/test/measure_gc_runs_test.rb +32 -0
  86. data/test/measure_gc_time_test.rb +36 -0
  87. data/test/measure_memory_test.rb +33 -0
  88. data/test/measure_process_time_test.rb +61 -0
  89. data/test/measure_wall_time_test.rb +255 -0
  90. data/test/method_elimination_test.rb +84 -0
  91. data/test/module_test.rb +45 -0
  92. data/test/multi_printer_test.rb +104 -0
  93. data/test/no_method_class_test.rb +15 -0
  94. data/test/pause_resume_test.rb +166 -0
  95. data/test/prime.rb +54 -0
  96. data/test/printers_test.rb +275 -0
  97. data/test/printing_recursive_graph_test.rb +127 -0
  98. data/test/rack_test.rb +157 -0
  99. data/test/recursive_test.rb +215 -0
  100. data/test/singleton_test.rb +38 -0
  101. data/test/stack_printer_test.rb +77 -0
  102. data/test/stack_test.rb +138 -0
  103. data/test/start_stop_test.rb +112 -0
  104. data/test/test_helper.rb +267 -0
  105. data/test/thread_test.rb +187 -0
  106. data/test/unique_call_path_test.rb +202 -0
  107. data/test/yarv_test.rb +55 -0
  108. metadata +199 -0
@@ -0,0 +1,202 @@
1
+ #!/usr/bin/env ruby
2
+ # encoding: UTF-8
3
+
4
+ require File.expand_path('../test_helper', __FILE__)
5
+
6
+ class UniqueCallPath
7
+ def method_a(i)
8
+ if i==1
9
+ method_b
10
+ else
11
+ method_c
12
+ end
13
+ end
14
+
15
+ def method_b
16
+ method_c
17
+ end
18
+
19
+ def method_c
20
+ end
21
+
22
+ def method_k(i)
23
+ method_a(i)
24
+ end
25
+ end
26
+
27
+
28
+ # -- Tests ----
29
+ class UniqueCallPathTest < TestCase
30
+ def test_root_method
31
+ unique_call_path = UniqueCallPath.new
32
+
33
+ result = RubyProf.profile do
34
+ unique_call_path.method_a(1)
35
+ end
36
+
37
+ root_methods = Array.new
38
+ result.threads.each do |thread|
39
+ thread.methods.each do | m |
40
+ if m.root?
41
+ root_methods.push(m)
42
+ end
43
+ end
44
+ end
45
+
46
+ assert_equal(1, root_methods.length)
47
+ assert_equal("UniqueCallPathTest#test_root_method", root_methods[0].full_name)
48
+ end
49
+
50
+ def test_root_children
51
+ unique_call_path = UniqueCallPath.new
52
+
53
+ result = RubyProf.profile do
54
+ unique_call_path.method_a(1)
55
+ unique_call_path.method_k(2)
56
+ end
57
+
58
+ root_methods = Array.new
59
+ result.threads.each do |thread|
60
+ thread.methods.each do | m |
61
+ if m.root?
62
+ root_methods.push(m)
63
+ end
64
+ end
65
+ end
66
+
67
+ assert_equal(1, root_methods.length)
68
+
69
+ root_children = Array.new
70
+ root_methods[0].children.each do | c |
71
+ if c.parent.target.eql?(root_methods[0])
72
+ root_children.push(c)
73
+ end
74
+ end
75
+
76
+ children = root_children.sort do |c1, c2|
77
+ c1.target.full_name <=> c2.target.full_name
78
+ end
79
+
80
+ assert_equal(2, children.length)
81
+ assert_equal("UniqueCallPath#method_a", children[0].target.full_name)
82
+ assert_equal("UniqueCallPath#method_k", children[1].target.full_name)
83
+ end
84
+
85
+ def test_children_of
86
+ unique_call_path = UniqueCallPath.new
87
+
88
+ result = RubyProf.profile do
89
+ unique_call_path.method_a(1)
90
+ unique_call_path.method_k(2)
91
+ end
92
+
93
+ root_methods = Array.new
94
+ result.threads.each do |thread|
95
+ thread.methods.each do | m |
96
+ if m.root?
97
+ root_methods.push(m)
98
+ end
99
+ end
100
+ end
101
+
102
+ assert_equal(1, root_methods.length)
103
+ method = root_methods[0]
104
+ assert_equal('UniqueCallPathTest#test_children_of', method.full_name)
105
+
106
+ call_info_a = nil
107
+ root_methods[0].children.each do | c |
108
+ if c.target.full_name == "UniqueCallPath#method_a"
109
+ call_info_a = c
110
+ break
111
+ end
112
+ end
113
+
114
+ assert !call_info_a.nil?
115
+
116
+ children_of_a = Array.new
117
+
118
+ call_info_a.children.each do | c |
119
+ if c.parent.eql?(call_info_a)
120
+ children_of_a.push(c)
121
+ end
122
+ end
123
+
124
+ assert_equal(2, call_info_a.target.children.length)
125
+
126
+ children_of_a = children_of_a.sort do |c1, c2|
127
+ c1.target.full_name <=> c2.target.full_name
128
+ end
129
+
130
+ assert_equal(1, children_of_a.length)
131
+ assert_equal("UniqueCallPath#method_b", children_of_a[0].target.full_name)
132
+ end
133
+
134
+ def test_id2ref
135
+ unique_call_path = UniqueCallPath.new
136
+
137
+ result = RubyProf.profile do
138
+ unique_call_path.method_a(1)
139
+ end
140
+
141
+ root_methods = Array.new
142
+ result.threads.each do |thread|
143
+ thread.methods.each do | m |
144
+ if m.root?
145
+ root_methods.push(m)
146
+ end
147
+ end
148
+ end
149
+
150
+ child = root_methods[0].children[0]
151
+
152
+ refute_equal(0, child.object_id)
153
+ #assert_equal(RubyProf::CallInfo.id2ref(child.id).target.full_name, child.target.full_name)
154
+ end
155
+
156
+ def test_unique_path
157
+ unique_call_path = UniqueCallPath.new
158
+
159
+ result = RubyProf.profile do
160
+ unique_call_path.method_a(1)
161
+ unique_call_path.method_k(1)
162
+ end
163
+
164
+ root_methods = Array.new
165
+ result.threads.each do |thread|
166
+ thread.methods.each do | m |
167
+ if m.root?
168
+ root_methods.push(m)
169
+ end
170
+ end
171
+ end
172
+
173
+ assert_equal(1, root_methods.length)
174
+
175
+ call_info_a = nil
176
+ root_methods[0].children.each do | c |
177
+ if c.target.full_name == "UniqueCallPath#method_a"
178
+ call_info_a = c
179
+ break
180
+ end
181
+ end
182
+
183
+ assert !call_info_a.nil?
184
+
185
+ children_of_a = Array.new
186
+ call_info_a.children.each do |c|
187
+ if c.parent.eql?(call_info_a)
188
+ children_of_a.push(c)
189
+ end
190
+ end
191
+
192
+ assert_equal(2, call_info_a.target.children.length)
193
+
194
+ children_of_a = children_of_a.sort do |c1, c2|
195
+ c1.target.full_name <=> c2.target.full_name
196
+ end
197
+
198
+ assert_equal(1, children_of_a.length)
199
+ assert_equal(1, children_of_a[0].called)
200
+ assert_equal("UniqueCallPath#method_b", children_of_a[0].target.full_name)
201
+ end
202
+ end
data/test/yarv_test.rb ADDED
@@ -0,0 +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
metadata ADDED
@@ -0,0 +1,199 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ruby-prof
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.18.0
5
+ platform: x64-mingw32
6
+ authors:
7
+ - Shugo Maeda, Charlie Savage, Roger Pack, Stefan Kaes
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2019-05-27 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
+ extra_rdoc_files: []
68
+ files:
69
+ - CHANGES
70
+ - LICENSE
71
+ - README.rdoc
72
+ - Rakefile
73
+ - bin/ruby-prof
74
+ - bin/ruby-prof-check-trace
75
+ - examples/flat.txt
76
+ - examples/graph.dot
77
+ - examples/graph.html
78
+ - examples/graph.txt
79
+ - examples/multi.flat.txt
80
+ - examples/multi.graph.html
81
+ - examples/multi.grind.dat
82
+ - examples/multi.stack.html
83
+ - examples/stack.html
84
+ - ext/ruby_prof/extconf.rb
85
+ - ext/ruby_prof/rp_call_info.c
86
+ - ext/ruby_prof/rp_call_info.h
87
+ - ext/ruby_prof/rp_measure.c
88
+ - ext/ruby_prof/rp_measure.h
89
+ - ext/ruby_prof/rp_measure_allocations.c
90
+ - ext/ruby_prof/rp_measure_cpu_time.c
91
+ - ext/ruby_prof/rp_measure_gc_runs.c
92
+ - ext/ruby_prof/rp_measure_gc_time.c
93
+ - ext/ruby_prof/rp_measure_memory.c
94
+ - ext/ruby_prof/rp_measure_process_time.c
95
+ - ext/ruby_prof/rp_measure_wall_time.c
96
+ - ext/ruby_prof/rp_method.c
97
+ - ext/ruby_prof/rp_method.h
98
+ - ext/ruby_prof/rp_stack.c
99
+ - ext/ruby_prof/rp_stack.h
100
+ - ext/ruby_prof/rp_thread.c
101
+ - ext/ruby_prof/rp_thread.h
102
+ - ext/ruby_prof/ruby_prof.c
103
+ - ext/ruby_prof/ruby_prof.h
104
+ - ext/ruby_prof/vc/ruby_prof.sln
105
+ - ext/ruby_prof/vc/ruby_prof.vcxproj
106
+ - lib/2.6.3/ruby_prof.so
107
+ - lib/ruby-prof.rb
108
+ - lib/ruby-prof/aggregate_call_info.rb
109
+ - lib/ruby-prof/assets/call_stack_printer.css.html
110
+ - lib/ruby-prof/assets/call_stack_printer.js.html
111
+ - lib/ruby-prof/assets/call_stack_printer.png
112
+ - lib/ruby-prof/call_info.rb
113
+ - lib/ruby-prof/call_info_visitor.rb
114
+ - lib/ruby-prof/compatibility.rb
115
+ - lib/ruby-prof/method_info.rb
116
+ - lib/ruby-prof/printers/abstract_printer.rb
117
+ - lib/ruby-prof/printers/call_info_printer.rb
118
+ - lib/ruby-prof/printers/call_stack_printer.rb
119
+ - lib/ruby-prof/printers/call_tree_printer.rb
120
+ - lib/ruby-prof/printers/dot_printer.rb
121
+ - lib/ruby-prof/printers/flat_printer.rb
122
+ - lib/ruby-prof/printers/flat_printer_with_line_numbers.rb
123
+ - lib/ruby-prof/printers/graph_html_printer.rb
124
+ - lib/ruby-prof/printers/graph_printer.rb
125
+ - lib/ruby-prof/printers/multi_printer.rb
126
+ - lib/ruby-prof/profile.rb
127
+ - lib/ruby-prof/profile/exclude_common_methods.rb
128
+ - lib/ruby-prof/profile/legacy_method_elimination.rb
129
+ - lib/ruby-prof/rack.rb
130
+ - lib/ruby-prof/task.rb
131
+ - lib/ruby-prof/thread.rb
132
+ - lib/ruby-prof/version.rb
133
+ - lib/unprof.rb
134
+ - ruby-prof.gemspec
135
+ - test/abstract_printer_test.rb
136
+ - test/aggregate_test.rb
137
+ - test/basic_test.rb
138
+ - test/block_test.rb
139
+ - test/call_info_test.rb
140
+ - test/call_info_visitor_test.rb
141
+ - test/duplicate_names_test.rb
142
+ - test/dynamic_method_test.rb
143
+ - test/enumerable_test.rb
144
+ - test/exceptions_test.rb
145
+ - test/exclude_methods_test.rb
146
+ - test/exclude_threads_test.rb
147
+ - test/fiber_test.rb
148
+ - test/issue137_test.rb
149
+ - test/line_number_test.rb
150
+ - test/measure_allocations_test.rb
151
+ - test/measure_cpu_time_test.rb
152
+ - test/measure_gc_runs_test.rb
153
+ - test/measure_gc_time_test.rb
154
+ - test/measure_memory_test.rb
155
+ - test/measure_process_time_test.rb
156
+ - test/measure_wall_time_test.rb
157
+ - test/method_elimination_test.rb
158
+ - test/module_test.rb
159
+ - test/multi_printer_test.rb
160
+ - test/no_method_class_test.rb
161
+ - test/pause_resume_test.rb
162
+ - test/prime.rb
163
+ - test/printers_test.rb
164
+ - test/printing_recursive_graph_test.rb
165
+ - test/rack_test.rb
166
+ - test/recursive_test.rb
167
+ - test/singleton_test.rb
168
+ - test/stack_printer_test.rb
169
+ - test/stack_test.rb
170
+ - test/start_stop_test.rb
171
+ - test/test_helper.rb
172
+ - test/thread_test.rb
173
+ - test/unique_call_path_test.rb
174
+ - test/yarv_test.rb
175
+ homepage: https://github.com/ruby-prof/ruby-prof
176
+ licenses:
177
+ - BSD-2-Clause
178
+ metadata: {}
179
+ post_install_message:
180
+ rdoc_options: []
181
+ require_paths:
182
+ - lib
183
+ required_ruby_version: !ruby/object:Gem::Requirement
184
+ requirements:
185
+ - - ">="
186
+ - !ruby/object:Gem::Version
187
+ version: 1.9.3
188
+ required_rubygems_version: !ruby/object:Gem::Requirement
189
+ requirements:
190
+ - - ">="
191
+ - !ruby/object:Gem::Version
192
+ version: '0'
193
+ requirements: []
194
+ rubygems_version: 3.0.3
195
+ signing_key:
196
+ specification_version: 4
197
+ summary: Fast Ruby profiler
198
+ test_files:
199
+ - test/test_helper.rb