ruby-prof 0.13.1 → 0.14.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (85) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGES +14 -0
  3. data/README.rdoc +1 -1
  4. data/Rakefile +2 -3
  5. data/bin/ruby-prof +4 -4
  6. data/bin/ruby-prof-check-trace +45 -0
  7. data/doc/LICENSE.html +49 -88
  8. data/doc/README_rdoc.html +92 -106
  9. data/doc/Rack.html +47 -116
  10. data/doc/Rack/RubyProf.html +119 -174
  11. data/doc/RubyProf.html +184 -216
  12. data/doc/RubyProf/AbstractPrinter.html +131 -162
  13. data/doc/RubyProf/AggregateCallInfo.html +136 -166
  14. data/doc/RubyProf/CallInfo.html +113 -154
  15. data/doc/RubyProf/CallInfoPrinter.html +56 -123
  16. data/doc/RubyProf/CallInfoVisitor.html +87 -216
  17. data/doc/RubyProf/CallStackPrinter.html +222 -215
  18. data/doc/RubyProf/CallTreePrinter.html +91 -142
  19. data/doc/RubyProf/Cmd.html +115 -157
  20. data/doc/RubyProf/DotPrinter.html +88 -140
  21. data/doc/RubyProf/FlatPrinter.html +66 -129
  22. data/doc/RubyProf/FlatPrinterWithLineNumbers.html +69 -132
  23. data/doc/RubyProf/GraphHtmlPrinter.html +115 -166
  24. data/doc/RubyProf/GraphPrinter.html +58 -125
  25. data/doc/RubyProf/MethodInfo.html +147 -172
  26. data/doc/RubyProf/MultiPrinter.html +104 -150
  27. data/doc/RubyProf/Profile.html +125 -179
  28. data/doc/RubyProf/ProfileTask.html +117 -157
  29. data/doc/RubyProf/Test.html +115 -154
  30. data/doc/RubyProf/Thread.html +87 -147
  31. data/doc/created.rid +13 -14
  32. data/doc/examples/flat_txt.html +51 -90
  33. data/doc/examples/graph_html.html +852 -0
  34. data/doc/examples/graph_txt.html +64 -92
  35. data/doc/fonts.css +167 -0
  36. data/doc/fonts/Lato-Light.ttf +0 -0
  37. data/doc/fonts/Lato-LightItalic.ttf +0 -0
  38. data/doc/fonts/Lato-Regular.ttf +0 -0
  39. data/doc/fonts/Lato-RegularItalic.ttf +0 -0
  40. data/doc/fonts/SourceCodePro-Bold.ttf +0 -0
  41. data/doc/fonts/SourceCodePro-Regular.ttf +0 -0
  42. data/doc/images/add.png +0 -0
  43. data/doc/images/arrow_up.png +0 -0
  44. data/doc/images/delete.png +0 -0
  45. data/doc/images/tag_blue.png +0 -0
  46. data/doc/index.html +75 -65
  47. data/doc/js/darkfish.js +0 -15
  48. data/doc/js/search.js +20 -5
  49. data/doc/js/search_index.js +1 -1
  50. data/doc/rdoc.css +255 -218
  51. data/doc/table_of_contents.html +751 -353
  52. data/ext/ruby_prof/extconf.rb +20 -22
  53. data/ext/ruby_prof/rp_measure_allocations.c +9 -5
  54. data/ext/ruby_prof/rp_measure_gc_runs.c +8 -0
  55. data/ext/ruby_prof/rp_measure_gc_time.c +5 -2
  56. data/ext/ruby_prof/rp_measure_wall_time.c +1 -0
  57. data/ext/ruby_prof/rp_method.c +0 -9
  58. data/ext/ruby_prof/rp_method.h +1 -6
  59. data/ext/ruby_prof/ruby_prof.c +32 -112
  60. data/ext/ruby_prof/ruby_prof.h +9 -10
  61. data/lib/ruby-prof.rb +2 -1
  62. data/lib/ruby-prof/aggregate_call_info.rb +4 -6
  63. data/lib/ruby-prof/call_info_visitor.rb +42 -44
  64. data/lib/ruby-prof/printers/graph_html_printer.rb +0 -8
  65. data/lib/ruby-prof/profile.rb +4 -4
  66. data/lib/ruby-prof/rack.rb +47 -47
  67. data/lib/ruby-prof/task.rb +0 -0
  68. data/lib/ruby-prof/thread.rb +22 -22
  69. data/lib/ruby-prof/version.rb +3 -0
  70. data/ruby-prof.gemspec +7 -11
  71. data/test/call_info_test.rb +78 -78
  72. data/test/call_info_visitor_test.rb +31 -31
  73. data/test/fiber_test.rb +2 -2
  74. data/test/measure_gc_runs_test.rb +1 -1
  75. data/test/measure_process_time_test.rb +7 -6
  76. data/test/printers_test.rb +4 -8
  77. data/test/recursive_test.rb +5 -9
  78. data/test/test_helper.rb +1 -1
  79. data/test/unique_call_path_test.rb +7 -29
  80. data/test/yarv_test.rb +55 -0
  81. metadata +63 -55
  82. data/ext/ruby_prof/version.h +0 -7
  83. data/lib/ruby-prof/test.rb +0 -150
  84. data/test/exec_test.rb +0 -14
  85. data/test/test_suite.rb +0 -37
@@ -8,26 +8,25 @@
8
8
  #include <stdio.h>
9
9
 
10
10
  #if RUBY_VERSION == 186
11
- # error 1.8.6 is not supported. Please upgrade to 1.8.7 or 1.9.2 or higher.
11
+ # error 1.8.6 is not supported. Please upgrade to 1.9.3 or higher.
12
+ #endif
13
+
14
+ #if RUBY_VERSION == 187
15
+ # error 1.8.7 is not supported. Please upgrade to 1.9.3 or higher.
12
16
  #endif
13
17
 
14
18
  #if RUBY_VERSION == 190
15
- # error 1.9.0 is not supported. Please upgrade to 1.9.2 or higher.
19
+ # error 1.9.0 is not supported. Please upgrade to 1.9.3 or higher.
16
20
  #endif
17
21
 
18
22
  #if RUBY_VERSION == 191
19
- # error 1.9.1 is not supported. Please upgrade to 1.9.2 or higher.
23
+ # error 1.9.1 is not supported. Please upgrade to 1.9.3 or higher.
20
24
  #endif
21
25
 
22
- #ifndef RUBY_VM
23
- #include <node.h>
24
- typedef rb_event_t rb_event_flag_t;
25
- #define rb_sourcefile() (node ? node->nd_file : 0)
26
- #define rb_sourceline() (node ? nd_line(node) : 0)
26
+ #if RUBY_VERSION == 192
27
+ # error 1.9.2 is not supported. Please upgrade to 1.9.3 or higher.
27
28
  #endif
28
29
 
29
- #include "version.h"
30
-
31
30
  #include "rp_measure.h"
32
31
  #include "rp_method.h"
33
32
  #include "rp_call_info.h"
data/lib/ruby-prof.rb CHANGED
@@ -8,6 +8,7 @@ rescue LoadError
8
8
  require "ruby_prof"
9
9
  end
10
10
 
11
+ require 'ruby-prof/version'
11
12
  require 'ruby-prof/aggregate_call_info'
12
13
  require 'ruby-prof/call_info'
13
14
  require 'ruby-prof/call_info_visitor'
@@ -64,4 +65,4 @@ module RubyProf
64
65
  end
65
66
  end
66
67
 
67
- RubyProf::figure_measure_mode
68
+ RubyProf::figure_measure_mode
@@ -56,16 +56,14 @@ module RubyProf
56
56
  private
57
57
 
58
58
  def aggregate(method_name)
59
- self.call_infos.inject(0) do |sum, call_info|
60
- sum += call_info.send(method_name)
61
- sum
59
+ call_infos.inject(0) do |sum, call_info|
60
+ sum + call_info.send(method_name)
62
61
  end
63
62
  end
64
63
 
65
64
  def aggregate_without_recursion(method_name)
66
- self.call_infos.inject(0) do |sum, call_info|
67
- sum += call_info.send(method_name) unless call_info.recursive
68
- sum
65
+ call_infos.inject(0) do |sum, call_info|
66
+ call_info.recursive ? sum : sum + call_info.send(method_name)
69
67
  end
70
68
  end
71
69
  end
@@ -1,44 +1,42 @@
1
- # The call info visitor class does a depth-first traversal
2
- # across a thread's call stack. At each call_info node,
3
- # the visitor executes the block provided in the
4
- # #visit method. The block is passed two parameters, the
5
- # event and the call_info instance. Event will be
6
- # either :enter or :exit.
7
- #
8
- # visitor = RubyProf::CallInfoVisitor.new(result.threads.first)
9
- #
10
- # method_names = Array.new
11
- #
12
- # visitor.visit do |call_info, event|
13
- # method_names << call_info.target.full_name if event == :enter
14
- # end
15
- #
16
- # puts method_names
17
-
18
- module RubyProf
19
- class CallInfoVisitor
20
- attr_reader :block, :thread
21
-
22
- def initialize(thread)
23
- @thread = thread
24
- end
25
-
26
- def visit(&block)
27
- @block = block
28
-
29
- self.thread.top_methods.each do |method_info|
30
- method_info.call_infos.each do |call_info|
31
- self.visit_call_info(call_info)
32
- end
33
- end
34
- end
35
-
36
- def visit_call_info(call_info)
37
- self.block.call(call_info, :enter)
38
- call_info.children.each do |child|
39
- visit_call_info(child)
40
- end
41
- self.block.call(call_info, :exit)
42
- end
43
- end
44
- end
1
+ # The call info visitor class does a depth-first traversal
2
+ # across a thread's call stack. At each call_info node,
3
+ # the visitor executes the block provided in the
4
+ # #visit method. The block is passed two parameters, the
5
+ # event and the call_info instance. Event will be
6
+ # either :enter or :exit.
7
+ #
8
+ # visitor = RubyProf::CallInfoVisitor.new(result.threads.first)
9
+ #
10
+ # method_names = Array.new
11
+ #
12
+ # visitor.visit do |call_info, event|
13
+ # method_names << call_info.target.full_name if event == :enter
14
+ # end
15
+ #
16
+ # puts method_names
17
+
18
+ module RubyProf
19
+ class CallInfoVisitor
20
+
21
+ def initialize(thread)
22
+ @thread = thread
23
+ end
24
+
25
+ def visit(&block)
26
+ @thread.top_methods.each do |method_info|
27
+ method_info.call_infos.each do |call_info|
28
+ visit_call_info(call_info, &block)
29
+ end
30
+ end
31
+ end
32
+
33
+ private
34
+ def visit_call_info(call_info, &block)
35
+ yield call_info, :enter
36
+ call_info.children.each do |child|
37
+ visit_call_info(child, &block)
38
+ end
39
+ yield call_info, :exit
40
+ end
41
+ end
42
+ end
@@ -138,16 +138,12 @@ module RubyProf
138
138
  <table>
139
139
  <tr>
140
140
  <th>Thread ID</th>
141
- <% if RUBY_VERSION >= "1.9" %>
142
141
  <th>Fiber ID</th>
143
- <% end %>
144
142
  <th>Total Time</th>
145
143
  </tr>
146
144
  <% for thread in @result.threads %>
147
145
  <tr>
148
- <% if RUBY_VERSION >= "1.9" %>
149
146
  <td><%= thread.id %></td>
150
- <% end %>
151
147
  <td><a href="#<%= thread.fiber_id %>"><%= thread.fiber_id %></a></td>
152
148
  <td><%= thread.total_time %></td>
153
149
  </tr>
@@ -158,11 +154,7 @@ module RubyProf
158
154
  <% for thread in @result.threads
159
155
  methods = thread.methods
160
156
  total_time = thread.total_time %>
161
- <% if RUBY_VERSION >= "1.9" %>
162
157
  <h2><a name="<%= thread.fiber_id %>">Thread <%= thread.id %>, Fiber: <%= thread.fiber_id %></a></h2>
163
- <% else %>
164
- <h2><a name="<%= thread.fiber_id %>">Thread <%= thread.fiber_id %></a></h2>
165
- <% end %>
166
158
  <table>
167
159
  <thead>
168
160
  <tr>
@@ -22,11 +22,11 @@ module RubyProf
22
22
  visitor.visit do |call_info, event|
23
23
  case event
24
24
  when :enter
25
- visited_methods[call_info.target] += 1
26
- call_info.recursive = (visited_methods[call_info.target] > 1)
25
+ if (visited_methods[call_info.target] += 1) > 1
26
+ call_info.recursive = true
27
+ end
27
28
  when :exit
28
- visited_methods[call_info.target] -= 1
29
- if visited_methods[call_info.target] == 0
29
+ if (visited_methods[call_info.target] -= 1) == 0
30
30
  visited_methods.delete(call_info.target)
31
31
  end
32
32
  end
@@ -1,48 +1,48 @@
1
- # encoding: utf-8
2
- require 'tmpdir'
3
-
4
- module Rack
5
- class RubyProf
6
- def initialize(app, options = {})
7
- @app = app
8
- @options = options
9
- @options[:min_percent] ||= 1
10
- @tmpdir = options[:path] || Dir.tmpdir
11
- @printer_klasses = @options[:printers] || {::RubyProf::FlatPrinter => 'flat.txt',
12
- ::RubyProf::GraphPrinter => 'graph.txt',
13
- ::RubyProf::GraphHtmlPrinter => 'graph.html',
14
- ::RubyProf::CallStackPrinter => 'call_stack.html'}
15
-
16
- @skip_paths = options[:skip_paths] || [%r{^/assets}, %r{\.css$}, %r{\.js$}, %r{\.png$}, %r{\.jpeg$}, %r{\.jpg$}, %r{\.gif$}]
17
- end
18
-
19
- def call(env)
20
- request = Rack::Request.new(env)
21
-
22
- if @skip_paths.any? {|skip_path| skip_path =~ request.path}
23
- @app.call(env)
24
- else
25
- result = nil
26
- data = ::RubyProf::Profile.profile do
27
- result = @app.call(env)
28
- end
29
-
30
- path = request.path.gsub('/', '-')
31
- path.slice!(0)
32
-
33
- print(data, path)
34
- result
35
- end
36
- end
37
-
38
- def print(data, path)
39
- @printer_klasses.each do |printer_klass, base_name|
40
- printer = printer_klass.new(data)
41
- file_name = ::File.join(@tmpdir, "#{path}-#{base_name}")
42
- ::File.open(file_name, 'wb') do |file|
43
- printer.print(file, @options)
44
- end
45
- end
46
- end
47
- end
1
+ # encoding: utf-8
2
+ require 'tmpdir'
3
+
4
+ module Rack
5
+ class RubyProf
6
+ def initialize(app, options = {})
7
+ @app = app
8
+ @options = options
9
+ @options[:min_percent] ||= 1
10
+ @tmpdir = options[:path] || Dir.tmpdir
11
+ @printer_klasses = @options[:printers] || {::RubyProf::FlatPrinter => 'flat.txt',
12
+ ::RubyProf::GraphPrinter => 'graph.txt',
13
+ ::RubyProf::GraphHtmlPrinter => 'graph.html',
14
+ ::RubyProf::CallStackPrinter => 'call_stack.html'}
15
+
16
+ @skip_paths = options[:skip_paths] || [%r{^/assets}, %r{\.css$}, %r{\.js$}, %r{\.png$}, %r{\.jpeg$}, %r{\.jpg$}, %r{\.gif$}]
17
+ end
18
+
19
+ def call(env)
20
+ request = Rack::Request.new(env)
21
+
22
+ if @skip_paths.any? {|skip_path| skip_path =~ request.path}
23
+ @app.call(env)
24
+ else
25
+ result = nil
26
+ data = ::RubyProf::Profile.profile do
27
+ result = @app.call(env)
28
+ end
29
+
30
+ path = request.path.gsub('/', '-')
31
+ path.slice!(0)
32
+
33
+ print(data, path)
34
+ result
35
+ end
36
+ end
37
+
38
+ def print(data, path)
39
+ @printer_klasses.each do |printer_klass, base_name|
40
+ printer = printer_klass.new(data)
41
+ file_name = ::File.join(@tmpdir, "#{path}-#{base_name}")
42
+ ::File.open(file_name, 'wb') do |file|
43
+ printer.print(file, @options)
44
+ end
45
+ end
46
+ end
47
+ end
48
48
  end
File without changes
@@ -1,22 +1,22 @@
1
- module RubyProf
2
- class Thread
3
- def top_methods
4
- self.methods.select do |method_info|
5
- method_info.call_infos.detect do |call_info|
6
- call_info.parent.nil?
7
- end
8
- end
9
- end
10
-
11
- def total_time
12
- self.top_methods.inject(0) do |sum, method_info|
13
- method_info.call_infos.each do |call_info|
14
- if call_info.parent.nil?
15
- sum += call_info.total_time
16
- end
17
- end
18
- sum
19
- end
20
- end
21
- end
22
- end
1
+ module RubyProf
2
+ class Thread
3
+ def top_methods
4
+ self.methods.select do |method_info|
5
+ method_info.call_infos.detect do |call_info|
6
+ call_info.parent.nil?
7
+ end
8
+ end
9
+ end
10
+
11
+ def total_time
12
+ self.top_methods.inject(0) do |sum, method_info|
13
+ method_info.call_infos.each do |call_info|
14
+ if call_info.parent.nil?
15
+ sum += call_info.total_time
16
+ end
17
+ end
18
+ sum
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,3 @@
1
+ module RubyProf
2
+ VERSION = "0.14.0"
3
+ end
data/ruby-prof.gemspec CHANGED
@@ -1,12 +1,7 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
 
3
- # Read version from header file
4
- version_header = File.read(File.expand_path('../ext/ruby_prof/version.h', __FILE__))
5
- #match = version_header.match(/RUBY_PROF_VERSION\s*"(\.+)"/)
6
- match = version_header.match(/RUBY_PROF_VERSION\s*"([^"]+)"/)
7
- raise(RuntimeError, "Could not determine RUBY_PROF_VERSION") if not match
8
-
9
- RUBY_PROF_VERSION = "#{match[1]}"
3
+ $:.push File.expand_path("../lib", __FILE__)
4
+ require "ruby-prof/version"
10
5
 
11
6
  Gem::Specification.new do |spec|
12
7
  spec.name = "ruby-prof"
@@ -22,14 +17,14 @@ methods it called. RubyProf generate both text and html and can output
22
17
  it to standard out or to a file.
23
18
  EOF
24
19
 
25
- spec.version = RUBY_PROF_VERSION
20
+ spec.version = RubyProf::VERSION
26
21
 
27
22
  spec.author = "Shugo Maeda, Charlie Savage, Roger Pack, Stefan Kaes"
28
23
  spec.email = "shugo@ruby-lang.org, cfis@savagexi.com, rogerdpack@gmail.com, skaes@railsexpress.de"
29
24
  spec.platform = Gem::Platform::RUBY
30
25
  spec.require_path = "lib"
31
26
  spec.bindir = "bin"
32
- spec.executables = ["ruby-prof"]
27
+ spec.executables = ["ruby-prof", "ruby-prof-check-trace"]
33
28
  spec.extensions = ["ext/ruby_prof/extconf.rb"]
34
29
  spec.files = Dir['CHANGES',
35
30
  'LICENSE',
@@ -37,6 +32,7 @@ EOF
37
32
  'README.rdoc',
38
33
  'ruby-prof.gemspec',
39
34
  'bin/ruby-prof',
35
+ 'bin/ruby-prof-check-trace',
40
36
  'doc/**/*',
41
37
  'examples/*',
42
38
  'ext/ruby_prof/extconf.rb',
@@ -52,9 +48,9 @@ EOF
52
48
  'test/*.rb']
53
49
 
54
50
  spec.test_files = Dir["test/test_*.rb"]
55
- spec.required_ruby_version = '>= 1.8.7'
51
+ spec.required_ruby_version = '>= 1.9.3'
56
52
  spec.date = Time.now.strftime('%Y-%m-%d')
57
- spec.homepage = 'https://github.com/rdp/ruby-prof'
53
+ spec.homepage = 'https://github.com/ruby-prof/ruby-prof'
58
54
  spec.add_development_dependency('minitest', '~> 4.0')
59
55
  spec.add_development_dependency('rake-compiler')
60
56
  spec.add_development_dependency('rdoc')
@@ -1,78 +1,78 @@
1
- #!/usr/bin/env ruby
2
- # encoding: UTF-8
3
-
4
- require File.expand_path('../test_helper', __FILE__)
5
-
6
- class CallInfoTest < Test::Unit::TestCase
7
- def setup
8
- # Need to use wall time for this test due to the sleep calls
9
- RubyProf::measure_mode = RubyProf::WALL_TIME
10
- end
11
-
12
- # def test_clone
13
- # result = RubyProf.profile do
14
- # RubyProf::C1.hello
15
- # end
16
- #
17
- # method = result.threads.first.top_methods.first
18
- # call_info = method.call_infos.first
19
- # call_info_clone = call_info.clone
20
- #
21
- ## assert_equal(call_info.target, call_info_clone.target)
22
- # assert_equal(call_info.total_time, call_info_clone.total_time)
23
- # end
24
-
25
- def test_merge
26
- result1 = RubyProf.profile do
27
- RubyProf::C1.hello
28
- end
29
-
30
- methods = result1.threads.first.methods.sort.reverse
31
- assert_equal(3, methods.length)
32
-
33
- assert_equal('CallInfoTest#test_merge', methods[0].full_name)
34
- assert_in_delta(0.1, methods[0].total_time, 0.01)
35
- assert_in_delta(0, methods[0].wait_time, 0.01)
36
- assert_in_delta(0, methods[0].self_time, 0.01)
37
- assert_equal(1, methods[0].called)
38
-
39
- assert_equal('<Class::RubyProf::C1>#hello', methods[1].full_name)
40
- assert_in_delta(0.1, methods[1].total_time, 0.01)
41
- assert_in_delta(0, methods[1].wait_time, 0.01)
42
- assert_in_delta(0, methods[1].self_time, 0.01)
43
- assert_equal(1, methods[1].called)
44
-
45
- assert_equal('Kernel#sleep', methods[2].full_name)
46
- assert_in_delta(0.1, methods[2].total_time, 0.01)
47
- assert_in_delta(0, methods[2].wait_time, 0.01)
48
- assert_in_delta(0.1, methods[2].self_time, 0.01)
49
- assert_equal(1, methods[2].called)
50
-
51
- result2 = RubyProf.profile do
52
- RubyProf::C1.hello
53
- end
54
-
55
- # Merge the trees
56
- methods = result1.threads.first.methods.sort.reverse
57
- assert_equal(3, methods.length)
58
-
59
- assert_equal('CallInfoTest#test_merge', methods[0].full_name)
60
- assert_in_delta(0.1, methods[0].total_time, 0.01)
61
- assert_in_delta(0, methods[0].wait_time, 0.01)
62
- assert_in_delta(0, methods[0].self_time, 0.01)
63
- assert_equal(1, methods[0].called)
64
-
65
- assert_equal('<Class::RubyProf::C1>#hello', methods[1].full_name)
66
- assert_in_delta(0.1, methods[1].total_time, 0.01)
67
- assert_in_delta(0, methods[1].wait_time, 0.01)
68
- assert_in_delta(0, methods[1].self_time, 0.01)
69
- assert_equal(1, methods[1].called)
70
-
71
- assert_equal('Kernel#sleep', methods[2].full_name)
72
- assert_in_delta(0.1, methods[2].total_time, 0.01)
73
- assert_in_delta(0, methods[2].wait_time, 0.01)
74
- assert_in_delta(0.1, methods[2].self_time, 0.01)
75
- assert_equal(1, methods[2].called)
76
- end
77
- end
78
-
1
+ #!/usr/bin/env ruby
2
+ # encoding: UTF-8
3
+
4
+ require File.expand_path('../test_helper', __FILE__)
5
+
6
+ class CallInfoTest < Test::Unit::TestCase
7
+ def setup
8
+ # Need to use wall time for this test due to the sleep calls
9
+ RubyProf::measure_mode = RubyProf::WALL_TIME
10
+ end
11
+
12
+ # def test_clone
13
+ # result = RubyProf.profile do
14
+ # RubyProf::C1.hello
15
+ # end
16
+ #
17
+ # method = result.threads.first.top_methods.first
18
+ # call_info = method.call_infos.first
19
+ # call_info_clone = call_info.clone
20
+ #
21
+ ## assert_equal(call_info.target, call_info_clone.target)
22
+ # assert_equal(call_info.total_time, call_info_clone.total_time)
23
+ # end
24
+
25
+ def test_merge
26
+ result1 = RubyProf.profile do
27
+ RubyProf::C1.hello
28
+ end
29
+
30
+ methods = result1.threads.first.methods.sort.reverse
31
+ assert_equal(3, methods.length)
32
+
33
+ assert_equal('CallInfoTest#test_merge', methods[0].full_name)
34
+ assert_in_delta(0.1, methods[0].total_time, 0.01)
35
+ assert_in_delta(0, methods[0].wait_time, 0.01)
36
+ assert_in_delta(0, methods[0].self_time, 0.01)
37
+ assert_equal(1, methods[0].called)
38
+
39
+ assert_equal('<Class::RubyProf::C1>#hello', methods[1].full_name)
40
+ assert_in_delta(0.1, methods[1].total_time, 0.01)
41
+ assert_in_delta(0, methods[1].wait_time, 0.01)
42
+ assert_in_delta(0, methods[1].self_time, 0.01)
43
+ assert_equal(1, methods[1].called)
44
+
45
+ assert_equal('Kernel#sleep', methods[2].full_name)
46
+ assert_in_delta(0.1, methods[2].total_time, 0.01)
47
+ assert_in_delta(0, methods[2].wait_time, 0.01)
48
+ assert_in_delta(0.1, methods[2].self_time, 0.01)
49
+ assert_equal(1, methods[2].called)
50
+
51
+ RubyProf.profile do
52
+ RubyProf::C1.hello
53
+ end
54
+
55
+ # Merge the trees
56
+ methods = result1.threads.first.methods.sort.reverse
57
+ assert_equal(3, methods.length)
58
+
59
+ assert_equal('CallInfoTest#test_merge', methods[0].full_name)
60
+ assert_in_delta(0.1, methods[0].total_time, 0.01)
61
+ assert_in_delta(0, methods[0].wait_time, 0.01)
62
+ assert_in_delta(0, methods[0].self_time, 0.01)
63
+ assert_equal(1, methods[0].called)
64
+
65
+ assert_equal('<Class::RubyProf::C1>#hello', methods[1].full_name)
66
+ assert_in_delta(0.1, methods[1].total_time, 0.01)
67
+ assert_in_delta(0, methods[1].wait_time, 0.01)
68
+ assert_in_delta(0, methods[1].self_time, 0.01)
69
+ assert_equal(1, methods[1].called)
70
+
71
+ assert_equal('Kernel#sleep', methods[2].full_name)
72
+ assert_in_delta(0.1, methods[2].total_time, 0.01)
73
+ assert_in_delta(0, methods[2].wait_time, 0.01)
74
+ assert_in_delta(0.1, methods[2].self_time, 0.01)
75
+ assert_equal(1, methods[2].called)
76
+ end
77
+ end
78
+