ruby-prof 0.8.1-x86-mingw32 → 0.11.0.rc1-x86-mingw32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (119) hide show
  1. data/CHANGES +89 -13
  2. data/LICENSE +4 -3
  3. data/{README → README.rdoc} +155 -162
  4. data/Rakefile +50 -123
  5. data/bin/ruby-prof +86 -47
  6. data/examples/empty.png +0 -0
  7. data/examples/graph.dot +106 -0
  8. data/examples/graph.png +0 -0
  9. data/examples/minus.png +0 -0
  10. data/examples/multi.flat.txt +23 -0
  11. data/examples/multi.graph.html +906 -0
  12. data/examples/multi.grind.dat +194 -0
  13. data/examples/multi.stack.html +573 -0
  14. data/examples/plus.png +0 -0
  15. data/examples/stack.html +573 -0
  16. data/ext/ruby_prof/extconf.rb +53 -0
  17. data/ext/ruby_prof/rp_call_info.c +369 -0
  18. data/ext/ruby_prof/rp_call_info.h +46 -0
  19. data/ext/ruby_prof/rp_measure.c +48 -0
  20. data/ext/ruby_prof/rp_measure.h +45 -0
  21. data/ext/ruby_prof/rp_measure_allocations.c +86 -0
  22. data/ext/ruby_prof/rp_measure_cpu_time.c +112 -0
  23. data/ext/ruby_prof/rp_measure_gc_runs.c +87 -0
  24. data/ext/ruby_prof/rp_measure_gc_time.c +73 -0
  25. data/ext/ruby_prof/rp_measure_memory.c +81 -0
  26. data/ext/ruby_prof/rp_measure_process_time.c +71 -0
  27. data/ext/ruby_prof/rp_measure_wall_time.c +42 -0
  28. data/ext/ruby_prof/rp_method.c +363 -0
  29. data/ext/ruby_prof/rp_method.h +55 -0
  30. data/ext/ruby_prof/rp_stack.c +61 -0
  31. data/ext/ruby_prof/rp_stack.h +40 -0
  32. data/ext/ruby_prof/rp_thread.c +113 -0
  33. data/ext/ruby_prof/rp_thread.h +20 -0
  34. data/ext/ruby_prof/ruby_prof.c +332 -1377
  35. data/ext/ruby_prof/ruby_prof.h +54 -188
  36. data/ext/ruby_prof/version.h +6 -3
  37. data/lib/1.8/ruby_prof.so +0 -0
  38. data/lib/1.9/ruby_prof.exp +0 -0
  39. data/lib/1.9/ruby_prof.ilk +0 -0
  40. data/lib/1.9/ruby_prof.lib +0 -0
  41. data/lib/1.9/ruby_prof.pdb +0 -0
  42. data/lib/1.9/ruby_prof.so +0 -0
  43. data/lib/ruby-prof.rb +32 -18
  44. data/lib/ruby-prof/abstract_printer.rb +15 -5
  45. data/lib/ruby-prof/aggregate_call_info.rb +11 -3
  46. data/lib/ruby-prof/call_info.rb +68 -1
  47. data/lib/ruby-prof/call_stack_printer.rb +775 -0
  48. data/lib/ruby-prof/call_tree_printer.rb +17 -9
  49. data/lib/ruby-prof/compatibility.rb +134 -0
  50. data/lib/ruby-prof/dot_printer.rb +152 -0
  51. data/lib/ruby-prof/empty.png +0 -0
  52. data/lib/ruby-prof/flat_printer.rb +23 -24
  53. data/lib/ruby-prof/flat_printer_with_line_numbers.rb +17 -21
  54. data/lib/ruby-prof/graph_html_printer.rb +69 -39
  55. data/lib/ruby-prof/graph_printer.rb +35 -35
  56. data/lib/ruby-prof/method_info.rb +26 -4
  57. data/lib/ruby-prof/minus.png +0 -0
  58. data/lib/ruby-prof/multi_printer.rb +56 -0
  59. data/lib/ruby-prof/plus.png +0 -0
  60. data/lib/ruby-prof/profile.rb +72 -0
  61. data/lib/ruby-prof/rack.rb +31 -0
  62. data/lib/ruby-prof/symbol_to_proc.rb +3 -1
  63. data/lib/ruby-prof/task.rb +20 -19
  64. data/lib/ruby-prof/test.rb +5 -3
  65. data/lib/ruby_prof.exp +0 -0
  66. data/lib/ruby_prof.ilk +0 -0
  67. data/lib/ruby_prof.lib +0 -0
  68. data/lib/ruby_prof.pdb +0 -0
  69. data/lib/ruby_prof.so +0 -0
  70. data/lib/unprof.rb +2 -0
  71. data/test/aggregate_test.rb +29 -14
  72. data/test/basic_test.rb +3 -251
  73. data/test/bug_test.rb +6 -0
  74. data/test/duplicate_names_test.rb +4 -4
  75. data/test/dynamic_method_test.rb +61 -0
  76. data/test/enumerable_test.rb +4 -4
  77. data/test/exceptions_test.rb +6 -5
  78. data/test/exclude_threads_test.rb +47 -47
  79. data/test/exec_test.rb +5 -5
  80. data/test/line_number_test.rb +16 -16
  81. data/test/measure_allocations_test.rb +25 -0
  82. data/test/measure_cpu_time_test.rb +212 -0
  83. data/test/measure_gc_runs_test.rb +29 -0
  84. data/test/measure_gc_time_test.rb +29 -0
  85. data/test/measure_memory_test.rb +36 -0
  86. data/test/measure_process_time_test.rb +205 -0
  87. data/test/measure_wall_time_test.rb +209 -0
  88. data/test/method_elimination_test.rb +74 -0
  89. data/test/module_test.rb +12 -21
  90. data/test/multi_printer_test.rb +81 -0
  91. data/test/no_method_class_test.rb +5 -3
  92. data/test/prime.rb +7 -10
  93. data/test/prime_test.rb +3 -3
  94. data/test/printers_test.rb +180 -54
  95. data/test/recursive_test.rb +34 -72
  96. data/test/singleton_test.rb +5 -4
  97. data/test/stack_printer_test.rb +73 -0
  98. data/test/stack_test.rb +7 -7
  99. data/test/start_stop_test.rb +23 -6
  100. data/test/test_helper.rb +81 -0
  101. data/test/test_suite.rb +35 -21
  102. data/test/thread_test.rb +40 -39
  103. data/test/unique_call_path_test.rb +6 -6
  104. metadata +106 -51
  105. data/ext/ruby_prof/measure_allocations.h +0 -58
  106. data/ext/ruby_prof/measure_cpu_time.h +0 -152
  107. data/ext/ruby_prof/measure_gc_runs.h +0 -76
  108. data/ext/ruby_prof/measure_gc_time.h +0 -57
  109. data/ext/ruby_prof/measure_memory.h +0 -101
  110. data/ext/ruby_prof/measure_process_time.h +0 -52
  111. data/ext/ruby_prof/measure_wall_time.h +0 -53
  112. data/ext/ruby_prof/mingw/Rakefile +0 -23
  113. data/ext/ruby_prof/mingw/build.rake +0 -38
  114. data/rails/environment/profile.rb +0 -24
  115. data/rails/example/example_test.rb +0 -9
  116. data/rails/profile_test_helper.rb +0 -21
  117. data/test/current_failures_windows +0 -8
  118. data/test/measurement_test.rb +0 -121
  119. data/test/ruby-prof-bin +0 -20
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
+ # encoding: UTF-8
2
3
 
3
- require 'test/unit'
4
- require 'ruby-prof'
4
+ require File.expand_path('../test_helper', __FILE__)
5
5
  require 'timeout'
6
6
 
7
7
  # -- Test for bug [#5657]
@@ -32,6 +32,7 @@ class SingletonTest < Test::Unit::TestCase
32
32
  assert_equal(1, a.as.size)
33
33
  end
34
34
  printer = RubyProf::FlatPrinter.new(result)
35
- printer.print(STDOUT)
35
+ output = ENV['SHOW_RUBY_PROF_PRINTER_OUTPUT'] == "1" ? STDOUT : ''
36
+ printer.print(output)
36
37
  end
37
- end
38
+ end
@@ -0,0 +1,73 @@
1
+ #!/usr/bin/env ruby
2
+ # encoding: UTF-8
3
+
4
+ require File.expand_path('../test_helper', __FILE__)
5
+ require 'tmpdir'
6
+
7
+ # Test data
8
+ # A
9
+ # / \
10
+ # B C
11
+ # \
12
+ # B
13
+
14
+ class STPT
15
+ def a
16
+ 100.times{b}
17
+ 300.times{c}
18
+ c;c;c
19
+ end
20
+
21
+ def b
22
+ sleep 0
23
+ end
24
+
25
+ def c
26
+ 5.times{b}
27
+ end
28
+ end
29
+
30
+ class StackPrinterTest < Test::Unit::TestCase
31
+ def setup
32
+ # Need to use wall time for this test due to the sleep calls
33
+ RubyProf::measure_mode = RubyProf::WALL_TIME
34
+ end
35
+
36
+ def test_stack_can_be_printed
37
+ start_time = Time.now
38
+ RubyProf.start
39
+ 5.times{STPT.new.a}
40
+ result = RubyProf.stop
41
+ end_time = Time.now
42
+ expected_time = end_time - start_time
43
+
44
+ file_contents = nil
45
+ assert_nothing_raised { file_contents = print(result) }
46
+ assert file_contents =~ /Thread: (\d+) \(100\.00% ~ ([.0-9]+)\)/
47
+ actual_time = $2.to_f
48
+ assert_in_delta(expected_time, actual_time, 0.01)
49
+ end
50
+
51
+ def test_method_elimination
52
+ RubyProf.start
53
+ 5.times{STPT.new.a}
54
+ result = RubyProf.stop
55
+ assert_nothing_raised {
56
+ # result.dump
57
+ result.eliminate_methods!([/Integer#times/])
58
+ # $stderr.puts "================================"
59
+ # result.dump
60
+ print(result)
61
+ }
62
+ end
63
+
64
+ private
65
+ def print(result)
66
+ test = caller.first =~ /in `(.*)'/ ? $1 : "test"
67
+ testfile_name = "#{Dir::tmpdir}/ruby_prof_#{test}.html"
68
+ printer = RubyProf::CallStackPrinter.new(result)
69
+ File.open(testfile_name, "w") {|f| printer.print(f, :threshold => 0, :min_percent => 0, :title => "ruby_prof #{test}")}
70
+ system("open '#{testfile_name}'") if RUBY_PLATFORM =~ /darwin/ && ENV['SHOW_RUBY_PROF_PRINTER_OUTPUT']=="1"
71
+ File.open(testfile_name, "r"){|f| f.read}
72
+ end
73
+ end
data/test/stack_test.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
+ # encoding: UTF-8
2
3
 
3
- require 'test/unit'
4
- require 'ruby-prof'
4
+ require File.expand_path('../test_helper', __FILE__)
5
5
 
6
6
  # Test data
7
7
  # A
@@ -76,7 +76,7 @@ class StackTest < Test::Unit::TestCase
76
76
  call_info = method.call_infos[0]
77
77
  assert_equal('StackTest#test_call_sequence->StackClass#a', call_info.call_sequence)
78
78
  assert_equal(3, call_info.children.length)
79
-
79
+
80
80
  # Check Kernel#sleep
81
81
  method = methods[2]
82
82
  assert_equal('Kernel#sleep', method.full_name)
@@ -107,10 +107,10 @@ class StackTest < Test::Unit::TestCase
107
107
  method = methods[3]
108
108
  assert_equal('StackClass#c', method.full_name)
109
109
  assert_equal(1, method.called)
110
- assert_in_delta(5, method.total_time, 0.01)
110
+ assert_in_delta(5, method.total_time, 0.05)
111
111
  assert_in_delta(0, method.wait_time, 0.01)
112
112
  assert_in_delta(0, method.self_time, 0.01)
113
- assert_in_delta(5, method.children_time, 0.01)
113
+ assert_in_delta(5, method.children_time, 0.05)
114
114
  assert_equal(1, method.call_infos.length)
115
115
 
116
116
  call_info = method.call_infos[0]
@@ -121,10 +121,10 @@ class StackTest < Test::Unit::TestCase
121
121
  method = methods[4]
122
122
  assert_equal('StackClass#b', method.full_name)
123
123
  assert_equal(2, method.called)
124
- assert_in_delta(4, method.total_time, 0.01)
124
+ assert_in_delta(4, method.total_time, 0.05)
125
125
  assert_in_delta(0, method.wait_time, 0.01)
126
126
  assert_in_delta(0, method.self_time, 0.01)
127
- assert_in_delta(4, method.children_time, 0.01)
127
+ assert_in_delta(4, method.children_time, 0.05)
128
128
  assert_equal(2, method.call_infos.length)
129
129
 
130
130
  call_info = method.call_infos[0]
@@ -1,8 +1,8 @@
1
1
  #!/usr/bin/env ruby
2
+ # encoding: UTF-8
3
+
4
+ require File.expand_path('../test_helper', __FILE__)
2
5
 
3
- require 'test/unit'
4
- require 'ruby-prof'
5
-
6
6
  class StartStopTest < Test::Unit::TestCase
7
7
  def setup
8
8
  # Need to use wall time for this test due to the sleep calls
@@ -22,6 +22,23 @@ class StartStopTest < Test::Unit::TestCase
22
22
  sleep(2)
23
23
  @result = RubyProf.stop
24
24
  end
25
+
26
+ def test_extra_stop_should_raise
27
+ RubyProf.start
28
+ assert_raise(RuntimeError) do
29
+ RubyProf.start
30
+ end
31
+
32
+ assert_raise(RuntimeError) do
33
+ RubyProf.profile {}
34
+ end
35
+
36
+ RubyProf.stop # ok
37
+ assert_raise(RuntimeError) do
38
+ RubyProf.stop
39
+ end
40
+ end
41
+
25
42
 
26
43
  def test_different_methods
27
44
  method1
@@ -56,10 +73,10 @@ class StartStopTest < Test::Unit::TestCase
56
73
  method = methods[1]
57
74
  assert_equal('StartStopTest#method2', method.full_name)
58
75
  assert_equal(1, method.called)
59
- assert_in_delta(2, method.total_time, 0.01)
76
+ assert_in_delta(2, method.total_time, 0.05)
60
77
  assert_in_delta(0, method.wait_time, 0.01)
61
78
  assert_in_delta(0, method.self_time, 0.01)
62
- assert_in_delta(2, method.children_time, 0.01)
79
+ assert_in_delta(2, method.children_time, 0.05)
63
80
  assert_equal(1, method.call_infos.length)
64
81
 
65
82
  call_info = method.call_infos[0]
@@ -92,4 +109,4 @@ class StartStopTest < Test::Unit::TestCase
92
109
  assert_equal('StartStopTest#method1->StartStopTest#method2->StartStopTest#method3->Kernel#sleep', call_info.call_sequence)
93
110
  assert_equal(0, call_info.children.length)
94
111
  end
95
- end
112
+ end
@@ -0,0 +1,81 @@
1
+ # encoding: UTF-8
2
+
3
+ # Make RubyMine happy
4
+ if ENV["RM_INFO"] || ENV["TEAMCITY_VERSION"]
5
+ gem 'win32console'
6
+ gem 'minitest-reporters'
7
+ require 'minitest/reporters'
8
+ MiniTest::Unit.runner = MiniTest::SuiteRunner.new
9
+ MiniTest::Unit.runner.reporters << MiniTest::Reporters::RubyMineReporter.new
10
+ end
11
+
12
+ # To make testing/debugging easier, test within this source tree versus an installed gem
13
+
14
+ dir = File.dirname(__FILE__)
15
+ root = File.expand_path(File.join(dir, '..'))
16
+ lib = File.expand_path(File.join(root, 'lib'))
17
+ ext = File.expand_path(File.join(root, 'ext', 'ruby_prof'))
18
+
19
+ $LOAD_PATH << lib
20
+ $LOAD_PATH << ext
21
+
22
+ require 'ruby-prof'
23
+ require 'test/unit'
24
+ require File.expand_path('../prime', __FILE__)
25
+
26
+ # Some classes used in measurement tests
27
+ module RubyProf
28
+ class C1
29
+ def C1.hello
30
+ sleep(0.1)
31
+ end
32
+
33
+ def hello
34
+ sleep(0.2)
35
+ end
36
+ end
37
+
38
+ module M1
39
+ def hello
40
+ sleep(0.3)
41
+ end
42
+ end
43
+
44
+ class C2
45
+ include M1
46
+ extend M1
47
+ end
48
+
49
+ class C3
50
+ def hello
51
+ sleep(0.4)
52
+ end
53
+ end
54
+
55
+ module M4
56
+ def hello
57
+ sleep(0.5)
58
+ end
59
+ end
60
+
61
+ module M5
62
+ include M4
63
+ def goodbye
64
+ hello
65
+ end
66
+ end
67
+
68
+ class C6
69
+ include M5
70
+ def test
71
+ goodbye
72
+ end
73
+ end
74
+
75
+ if RUBY_VERSION < '1.9'
76
+ PARENT = Object
77
+ else
78
+ PARENT = BasicObject
79
+ end
80
+
81
+ end
data/test/test_suite.rb CHANGED
@@ -1,23 +1,37 @@
1
- require 'test/unit'
1
+ # encoding: utf-8
2
2
 
3
- require 'aggregate_test'
4
- require 'basic_test'
5
- require 'duplicate_names_test'
6
- require 'exceptions_test'
7
- require 'line_number_test'
8
- require 'measurement_test'
9
- require 'module_test'
10
- require 'no_method_class_test'
11
- require 'prime_test'
12
- require 'printers_test'
13
- require 'recursive_test'
14
- require 'singleton_test'
15
- require 'stack_test'
16
- require 'start_stop_test'
17
- require 'thread_test'
18
- require 'unique_call_path_test'
3
+ require File.expand_path("../test_helper", __FILE__)
4
+
5
+ %w(aggregate_test
6
+ basic_test
7
+ duplicate_names_test
8
+ dynamic_method_test
9
+ enumerable_test
10
+ exceptions_test
11
+ exclude_threads_test
12
+ line_number_test
13
+
14
+ measure_allocations_test
15
+ measure_cpu_time_test
16
+ measure_gc_runs_test
17
+ measure_gc_time_test
18
+ measure_memory_test
19
+ measure_process_time_test
20
+ measure_wall_time_test
21
+
22
+ method_elimination_test
23
+ module_test
24
+ multi_printer_test
25
+ no_method_class_test
26
+ prime_test
27
+ printers_test
28
+ recursive_test
29
+ singleton_test
30
+ stack_test
31
+ stack_printer_test
32
+ start_stop_test
33
+ thread_test
34
+ unique_call_path_test).each do |test|
35
+ require File.expand_path("../#{test}", __FILE__)
36
+ end
19
37
 
20
- # Can't use this one here cause it breaks
21
- # the rest of the unit tets (Ruby Prof gets
22
- # started twice).
23
- #require 'profile_unit_test'
data/test/thread_test.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
- require 'test/unit'
3
- require 'ruby-prof'
2
+ # encoding: UTF-8
3
+
4
+ require File.expand_path('../test_helper', __FILE__)
4
5
  require 'timeout'
5
6
 
6
7
  # -- Tests ----
@@ -21,11 +22,11 @@ class ThreadTest < Test::Unit::TestCase
21
22
  result = RubyProf.stop
22
23
  assert_equal(2, result.threads.keys.length) # this should pass...
23
24
  end
24
-
25
+
25
26
  def test_thread_identity
26
27
  RubyProf.start
27
28
  thread = Thread.new do
28
- sleep(1)
29
+ sleep(1)
29
30
  end
30
31
  thread.join
31
32
  result = RubyProf.stop
@@ -36,16 +37,16 @@ class ThreadTest < Test::Unit::TestCase
36
37
 
37
38
  assert(thread_ids.include?(threads[0].object_id))
38
39
  assert(thread_ids.include?(threads[1].object_id))
39
-
40
+
40
41
  assert_instance_of(Thread, ObjectSpace._id2ref(thread_ids[0]))
41
42
  assert(threads.include?(ObjectSpace._id2ref(thread_ids[0])))
42
-
43
+
43
44
  assert_instance_of(Thread, ObjectSpace._id2ref(thread_ids[1]))
44
45
  assert(threads.include?(ObjectSpace._id2ref(thread_ids[1])))
45
46
  end
46
47
 
47
48
  def test_thread_timings
48
- RubyProf.start
49
+ RubyProf.start
49
50
  thread = Thread.new do
50
51
  sleep 0 # force it to hit thread.join, below, first
51
52
  # thus forcing sleep(1), below, to be counted as (wall) self_time
@@ -55,7 +56,7 @@ class ThreadTest < Test::Unit::TestCase
55
56
  end
56
57
  thread.join
57
58
  result = RubyProf.stop
58
-
59
+
59
60
  # Check background thread
60
61
  assert_equal(2, result.threads.length)
61
62
  methods = result.threads[thread.object_id].sort.reverse
@@ -65,9 +66,9 @@ class ThreadTest < Test::Unit::TestCase
65
66
  assert_equal('ThreadTest#test_thread_timings', method.full_name)
66
67
  assert_equal(1, method.called)
67
68
  assert_in_delta(1, method.total_time, 0.05)
68
- assert_in_delta(0, method.self_time, 0.01)
69
- assert_in_delta(0, method.wait_time, 0.01)
70
- assert_in_delta(1, method.children_time, 0.01)
69
+ assert_in_delta(0, method.self_time, 0.05)
70
+ assert_in_delta(0, method.wait_time, 0.05)
71
+ assert_in_delta(1, method.children_time, 0.05)
71
72
  assert_equal(1, method.call_infos.length)
72
73
  call_info = method.call_infos[0]
73
74
  assert_equal('ThreadTest#test_thread_timings', call_info.call_sequence)
@@ -76,10 +77,10 @@ class ThreadTest < Test::Unit::TestCase
76
77
  method = methods[1]
77
78
  assert_equal('Kernel#sleep', method.full_name)
78
79
  assert_equal(2, method.called)
79
- assert_in_delta(1, method.total_time, 0.01)
80
- assert_in_delta(1.0, method.self_time, 0.01)
81
- assert_in_delta(0, method.wait_time, 0.01)
82
- assert_in_delta(0, method.children_time, 0.01)
80
+ assert_in_delta(1, method.total_time, 0.05)
81
+ assert_in_delta(1.0, method.self_time, 0.05)
82
+ assert_in_delta(0, method.wait_time, 0.05)
83
+ assert_in_delta(0, method.children_time, 0.05)
83
84
 
84
85
  assert_equal(1, method.call_infos.length)
85
86
  call_info = method.call_infos[0]
@@ -96,11 +97,11 @@ class ThreadTest < Test::Unit::TestCase
96
97
  # the sub calls to Object#new, when popped,
97
98
  # cause the parent frame to be created for method #test_thread_timings, which means a +1 when it's popped in the end
98
99
  # xxxx a test that shows it the other way, too (never creates parent frame--if that's even possible)
99
- assert_equal(1, method.called)
100
- assert_in_delta(1, method.total_time, 0.01)
100
+ assert_equal(1, method.called)
101
+ assert_in_delta(1, method.total_time, 0.05)
101
102
  assert_in_delta(0, method.self_time, 0.05)
102
103
  assert_in_delta(0, method.wait_time, 0.05)
103
- assert_in_delta(1, method.children_time, 0.01)
104
+ assert_in_delta(1, method.children_time, 0.05)
104
105
 
105
106
  assert_equal(1, method.call_infos.length)
106
107
  call_info = method.call_infos[0]
@@ -110,10 +111,10 @@ class ThreadTest < Test::Unit::TestCase
110
111
  method = methods[1]
111
112
  assert_equal('Thread#join', method.full_name)
112
113
  assert_equal(1, method.called)
113
- assert_in_delta(1, method.total_time, 0.01)
114
- assert_in_delta(0, method.self_time, 0.01)
115
- assert_in_delta(1.0, method.wait_time, 0.01)
116
- assert_in_delta(0, method.children_time, 0.01)
114
+ assert_in_delta(1, method.total_time, 0.05)
115
+ assert_in_delta(0, method.self_time, 0.05)
116
+ assert_in_delta(1.0, method.wait_time, 0.05)
117
+ assert_in_delta(0, method.children_time, 0.05)
117
118
 
118
119
  assert_equal(1, method.call_infos.length)
119
120
  call_info = method.call_infos[0]
@@ -123,10 +124,10 @@ class ThreadTest < Test::Unit::TestCase
123
124
  method = methods[2]
124
125
  assert_equal('<Class::Thread>#new', method.full_name)
125
126
  assert_equal(1, method.called)
126
- assert_in_delta(0, method.total_time, 0.01)
127
- assert_in_delta(0, method.self_time, 0.01)
128
- assert_in_delta(0, method.wait_time, 0.01)
129
- assert_in_delta(0, method.children_time, 0.01)
127
+ assert_in_delta(0, method.total_time, 0.05)
128
+ assert_in_delta(0, method.self_time, 0.05)
129
+ assert_in_delta(0, method.wait_time, 0.05)
130
+ assert_in_delta(0, method.children_time, 0.05)
130
131
 
131
132
  assert_equal(1, method.call_infos.length)
132
133
  call_info = method.call_infos[0]
@@ -136,28 +137,28 @@ class ThreadTest < Test::Unit::TestCase
136
137
  method = methods[3]
137
138
  assert_equal('Thread#initialize', method.full_name)
138
139
  assert_equal(1, method.called)
139
- assert_in_delta(0, method.total_time, 0.01)
140
- assert_in_delta(0, method.self_time, 0.01)
141
- assert_in_delta(0, method.wait_time, 0.01)
142
- assert_in_delta(0, method.children_time, 0.01)
140
+ assert_in_delta(0, method.total_time, 0.05)
141
+ assert_in_delta(0, method.self_time, 0.05)
142
+ assert_in_delta(0, method.wait_time, 0.05)
143
+ assert_in_delta(0, method.children_time, 0.05)
143
144
 
144
145
  assert_equal(1, method.call_infos.length)
145
146
  call_info = method.call_infos[0]
146
147
  assert_equal('ThreadTest#test_thread_timings-><Class::Thread>#new->Thread#initialize', call_info.call_sequence)
147
148
  assert_equal(0, call_info.children.length)
148
149
  end
149
-
150
+
150
151
  # useless test
151
152
  def test_thread_back_and_forth
152
- result = RubyProf.profile do
153
- a = Thread.new { 100_000.times { sleep 0 }}
154
- b = Thread.new { 100_000.times { sleep 0 }}
155
- a.join
156
- b.join
157
- end
158
- assert result.threads.values.flatten.sort[-1].total_time < 10 # 10s
153
+ result = RubyProf.profile do
154
+ a = Thread.new { 100_000.times { sleep 0 }}
155
+ b = Thread.new { 100_000.times { sleep 0 }}
156
+ a.join
157
+ b.join
158
+ end
159
+ assert result.threads.values.flatten.sort[-1].total_time < 10 # 10s. Amazingly, this can fail in OS X at times. Amazing.
159
160
  end
160
-
161
+
161
162
  def test_thread
162
163
  result = RubyProf.profile do
163
164
  begin