ruby-prof 0.7.4 → 0.7.5

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.
@@ -48,7 +48,7 @@
48
48
  */
49
49
 
50
50
  #include "ruby_prof.h"
51
-
51
+ #include <stdio.h>
52
52
 
53
53
  /* ================ Helper Functions =================*/
54
54
  static VALUE
@@ -378,7 +378,7 @@ prof_call_info_target(VALUE self)
378
378
  /* call-seq:
379
379
  called -> int
380
380
 
381
- Returns the total amount of time this method was called. */
381
+ Returns the total amount of times this method was called. */
382
382
  static VALUE
383
383
  prof_call_info_called(VALUE self)
384
384
  {
@@ -872,6 +872,12 @@ get_event_name(rb_event_flag_t event)
872
872
  return "c-return";
873
873
  case RUBY_EVENT_RAISE:
874
874
  return "raise";
875
+
876
+ #ifdef RUBY_VM
877
+ case RUBY_EVENT_SWITCH:
878
+ return "thread-interrupt";
879
+ #endif
880
+
875
881
  default:
876
882
  return "unknown";
877
883
  }
@@ -918,7 +924,7 @@ update_result(prof_measure_t total_time,
918
924
  prof_frame_t *frame)
919
925
  {
920
926
  prof_measure_t self_time = total_time - frame->child_time - frame->wait_time;
921
-
927
+
922
928
  prof_call_info_t *call_info = frame->call_info;
923
929
 
924
930
  /* Update information about the current method */
@@ -926,7 +932,7 @@ update_result(prof_measure_t total_time,
926
932
  call_info->total_time += total_time;
927
933
  call_info->self_time += self_time;
928
934
  call_info->wait_time += frame->wait_time;
929
-
935
+
930
936
  /* Note where the current method was called from */
931
937
  if (parent_frame)
932
938
  call_info->line = parent_frame->line;
@@ -937,12 +943,12 @@ switch_thread(VALUE thread_id, prof_measure_t now)
937
943
  {
938
944
  prof_frame_t *frame = NULL;
939
945
  prof_measure_t wait_time = 0;
940
-
941
946
  /* Get new thread information. */
942
947
  thread_data_t *thread_data = threads_table_lookup(threads_tbl, thread_id);
943
948
 
944
949
  /* How long has this thread been waiting? */
945
950
  wait_time = now - thread_data->last_switch;
951
+
946
952
  thread_data->last_switch = 0;
947
953
 
948
954
  /* Get the frame at the top of the stack. This may represent
@@ -950,13 +956,17 @@ switch_thread(VALUE thread_id, prof_measure_t now)
950
956
  previous method (EVENT_CALL).*/
951
957
  frame = stack_peek(thread_data->stack);
952
958
 
953
- if (frame)
959
+ if (frame) {
954
960
  frame->wait_time += wait_time;
961
+ }
962
+
963
+
955
964
 
956
965
  /* Save on the last thread the time of the context switch
957
966
  and reset this thread's last context switch to 0.*/
958
- if (last_thread_data)
959
- last_thread_data->last_switch = now;
967
+ if (last_thread_data) {
968
+ last_thread_data->last_switch = now;
969
+ }
960
970
 
961
971
  last_thread_data = thread_data;
962
972
  return thread_data;
@@ -969,11 +979,10 @@ pop_frame(thread_data_t *thread_data, prof_measure_t now)
969
979
  prof_frame_t* parent_frame = NULL;
970
980
  prof_measure_t total_time;
971
981
 
972
- frame = stack_pop(thread_data->stack);
973
-
982
+ frame = stack_pop(thread_data->stack); // only time it's called
974
983
  /* Frame can be null. This can happen if RubProf.start is called from
975
984
  a method that exits. And it can happen if an exception is raised
976
- in code that is being profiled and the stack unwinds (RubProf is
985
+ in code that is being profiled and the stack unwinds (RubyProf is
977
986
  not notified of that by the ruby runtime. */
978
987
  if (frame == NULL) return NULL;
979
988
 
@@ -989,7 +998,7 @@ pop_frame(thread_data_t *thread_data, prof_measure_t now)
989
998
  parent_frame->child_time += total_time;
990
999
  }
991
1000
 
992
- update_result(total_time, parent_frame, frame);
1001
+ update_result(total_time, parent_frame, frame); // only time it's called
993
1002
  return frame;
994
1003
  }
995
1004
 
@@ -1029,7 +1038,6 @@ static void
1029
1038
  prof_event_hook(rb_event_flag_t event, NODE *node, VALUE self, ID mid, VALUE klass)
1030
1039
  #endif
1031
1040
  {
1032
-
1033
1041
  VALUE thread = Qnil;
1034
1042
  VALUE thread_id = Qnil;
1035
1043
  prof_measure_t now = 0;
@@ -1066,8 +1074,9 @@ prof_event_hook(rb_event_flag_t event, NODE *node, VALUE self, ID mid, VALUE kla
1066
1074
 
1067
1075
  class_name = rb_class2name(klass);
1068
1076
 
1069
- if (last_thread_id != thread_id)
1077
+ if (last_thread_id != thread_id) {
1070
1078
  printf("\n");
1079
+ }
1071
1080
 
1072
1081
  printf("%2u: %-8s :%2d %s#%s\n",
1073
1082
  thread_id, event_name, source_line, class_name, method_name);
@@ -1182,6 +1191,7 @@ prof_event_hook(rb_event_flag_t event, NODE *node, VALUE self, ID mid, VALUE kla
1182
1191
  case RUBY_EVENT_RETURN:
1183
1192
  case RUBY_EVENT_C_RETURN:
1184
1193
  {
1194
+ // this assumes that all C calls take 100% user cpu, I guess.
1185
1195
  pop_frame(thread_data, now);
1186
1196
  break;
1187
1197
  }
@@ -1238,7 +1248,7 @@ get_prof_result(VALUE obj)
1238
1248
  RDATA(obj)->dfree != (RUBY_DATA_FUNC) prof_result_free)
1239
1249
  {
1240
1250
  /* Should never happen */
1241
- rb_raise(rb_eTypeError, "wrong result object");
1251
+ rb_raise(rb_eTypeError, "wrong result object (%d %d) ", BUILTIN_TYPE(obj) != T_DATA, RDATA(obj)->dfree != (RUBY_DATA_FUNC) prof_result_free);
1242
1252
  }
1243
1253
  return (prof_result_t *) DATA_PTR(obj);
1244
1254
  }
@@ -1402,7 +1412,7 @@ prof_install_hook()
1402
1412
  rb_add_event_hook(prof_event_hook,
1403
1413
  RUBY_EVENT_CALL | RUBY_EVENT_RETURN |
1404
1414
  RUBY_EVENT_C_CALL | RUBY_EVENT_C_RETURN
1405
- | RUBY_EVENT_LINE, Qnil);
1415
+ | RUBY_EVENT_LINE | RUBY_EVENT_SWITCH, Qnil);
1406
1416
  #else
1407
1417
  rb_add_event_hook(prof_event_hook,
1408
1418
  RUBY_EVENT_CALL | RUBY_EVENT_RETURN |
@@ -1,4 +1,4 @@
1
- #define RUBY_PROF_VERSION "0.7.4"
1
+ #define RUBY_PROF_VERSION "0.7.5"
2
2
  #define RUBY_PROF_VERSION_MAJ 0
3
3
  #define RUBY_PROF_VERSION_MIN 7
4
- #define RUBY_PROF_VERSION_MIC 4
4
+ #define RUBY_PROF_VERSION_MIC 5
@@ -7,6 +7,7 @@ require "ruby-prof/flat_printer"
7
7
  require "ruby-prof/graph_printer"
8
8
  require "ruby-prof/graph_html_printer"
9
9
  require "ruby-prof/call_tree_printer"
10
+ require "ruby-prof/symbol_to_proc"
10
11
 
11
12
  require "ruby-prof/test"
12
13
 
@@ -0,0 +1,9 @@
1
+ unless (:a.respond_to?(:to_proc))
2
+
3
+ class Symbol
4
+ def to_proc
5
+ proc {|stuff| stuff.send(self)}
6
+ end
7
+ end
8
+ end
9
+
@@ -0,0 +1,6 @@
1
+ require 'ruby-prof'
2
+
3
+ RubyProf.start
4
+ loop {
5
+ Thread.new { sleep 1 }
6
+ }
@@ -0,0 +1,4 @@
1
+ def go
2
+ 3
3
+ end
4
+ go
@@ -86,10 +86,10 @@ class AggregateTest < Test::Unit::TestCase
86
86
 
87
87
  call_info = call_infos.first
88
88
  assert_equal('AggClass#a', call_info.parent.target.full_name)
89
- assert_in_delta(3, call_info.total_time, 0.01)
89
+ assert_in_delta(3, call_info.total_time, 0.05)
90
90
  assert_in_delta(0, call_info.wait_time, 0.01)
91
91
  assert_in_delta(0, call_info.self_time, 0.01)
92
- assert_in_delta(3, call_info.children_time, 0.01)
92
+ assert_in_delta(3, call_info.children_time, 0.05)
93
93
  assert_equal(3, call_info.called)
94
94
  end
95
95
 
@@ -112,9 +112,9 @@ class AggregateTest < Test::Unit::TestCase
112
112
 
113
113
  call_info = call_infos.first
114
114
  assert_equal('AggClass#z', call_info.target.full_name)
115
- assert_in_delta(3, call_info.total_time, 0.01)
115
+ assert_in_delta(3, call_info.total_time, 0.05)
116
116
  assert_in_delta(0, call_info.wait_time, 0.01)
117
- assert_in_delta(0, call_info.self_time, 0.01)
117
+ assert_in_delta(0, call_info.self_time, 0.05)
118
118
  assert_in_delta(3, call_info.children_time, 0.01)
119
119
  assert_equal(3, call_info.called)
120
120
  end
@@ -115,6 +115,12 @@ class BasicTest < Test::Unit::TestCase
115
115
  assert_in_delta(0, methods[2].wait_time, 0.01)
116
116
  assert_in_delta(0.1, methods[2].self_time, 0.01)
117
117
  end
118
+
119
+ if RUBY_VERSION < '1.9'
120
+ PARENT = Object
121
+ else
122
+ PARENT = BasicObject
123
+ end
118
124
 
119
125
  def test_instance_methods
120
126
  result = RubyProf.profile do
@@ -136,21 +142,22 @@ class BasicTest < Test::Unit::TestCase
136
142
  assert_equal('C1#hello', methods[1].full_name)
137
143
  assert_equal('Kernel#sleep', methods[2].full_name)
138
144
  assert_equal('Class#new', methods[3].full_name)
139
- assert_equal('<Class::Object>#allocate', methods[4].full_name)
140
- assert_equal('Object#initialize', methods[5].full_name)
145
+
146
+ assert_equal("<Class::#{PARENT}>#allocate", methods[4].full_name)
147
+ assert_equal("#{PARENT}#initialize", methods[5].full_name)
141
148
 
142
149
  # Check times
143
- assert_in_delta(0.2, methods[0].total_time, 0.01)
150
+ assert_in_delta(0.2, methods[0].total_time, 0.02)
144
151
  assert_in_delta(0, methods[0].wait_time, 0.01)
145
152
  assert_in_delta(0, methods[0].self_time, 0.01)
146
153
 
147
- assert_in_delta(0.2, methods[1].total_time, 0.01)
154
+ assert_in_delta(0.2, methods[1].total_time, 0.02)
148
155
  assert_in_delta(0, methods[1].wait_time, 0.01)
149
156
  assert_in_delta(0, methods[1].self_time, 0.01)
150
157
 
151
- assert_in_delta(0.2, methods[2].total_time, 0.01)
158
+ assert_in_delta(0.2, methods[2].total_time, 0.02)
152
159
  assert_in_delta(0, methods[2].wait_time, 0.01)
153
- assert_in_delta(0.2, methods[2].self_time, 0.01)
160
+ assert_in_delta(0.2, methods[2].self_time, 0.02)
154
161
 
155
162
  assert_in_delta(0, methods[3].total_time, 0.01)
156
163
  assert_in_delta(0, methods[3].wait_time, 0.01)
@@ -183,17 +190,17 @@ class BasicTest < Test::Unit::TestCase
183
190
  assert_equal('Kernel#sleep', methods[2].full_name)
184
191
 
185
192
  # Check times
186
- assert_in_delta(0.3, methods[0].total_time, 0.01)
193
+ assert_in_delta(0.3, methods[0].total_time, 0.02)
187
194
  assert_in_delta(0, methods[0].wait_time, 0.01)
188
195
  assert_in_delta(0, methods[0].self_time, 0.01)
189
196
 
190
- assert_in_delta(0.3, methods[1].total_time, 0.01)
197
+ assert_in_delta(0.3, methods[1].total_time, 0.02)
191
198
  assert_in_delta(0, methods[1].wait_time, 0.01)
192
199
  assert_in_delta(0, methods[1].self_time, 0.01)
193
200
 
194
- assert_in_delta(0.3, methods[2].total_time, 0.01)
201
+ assert_in_delta(0.3, methods[2].total_time, 0.02)
195
202
  assert_in_delta(0, methods[2].wait_time, 0.01)
196
- assert_in_delta(0.3, methods[2].self_time, 0.01)
203
+ assert_in_delta(0.3, methods[2].self_time, 0.02)
197
204
  end
198
205
 
199
206
  def test_module_instance_methods
@@ -216,21 +223,21 @@ class BasicTest < Test::Unit::TestCase
216
223
  assert_equal('M1#hello', methods[1].full_name)
217
224
  assert_equal('Kernel#sleep', methods[2].full_name)
218
225
  assert_equal('Class#new', methods[3].full_name)
219
- assert_equal('<Class::Object>#allocate', methods[4].full_name)
220
- assert_equal('Object#initialize', methods[5].full_name)
221
-
226
+ assert_equal("<Class::#{PARENT}>#allocate", methods[4].full_name)
227
+ assert_equal("#{PARENT}#initialize", methods[5].full_name)
228
+
222
229
  # Check times
223
- assert_in_delta(0.3, methods[0].total_time, 0.01)
224
- assert_in_delta(0, methods[0].wait_time, 0.01)
230
+ assert_in_delta(0.3, methods[0].total_time, 0.02)
231
+ assert_in_delta(0, methods[0].wait_time, 0.02)
225
232
  assert_in_delta(0, methods[0].self_time, 0.01)
226
233
 
227
- assert_in_delta(0.3, methods[1].total_time, 0.01)
234
+ assert_in_delta(0.3, methods[1].total_time, 0.02)
228
235
  assert_in_delta(0, methods[1].wait_time, 0.01)
229
236
  assert_in_delta(0, methods[1].self_time, 0.01)
230
237
 
231
- assert_in_delta(0.3, methods[2].total_time, 0.01)
238
+ assert_in_delta(0.3, methods[2].total_time, 0.02)
232
239
  assert_in_delta(0, methods[2].wait_time, 0.01)
233
- assert_in_delta(0.3, methods[2].self_time, 0.01)
240
+ assert_in_delta(0.3, methods[2].self_time, 0.02)
234
241
 
235
242
  assert_in_delta(0, methods[3].total_time, 0.01)
236
243
  assert_in_delta(0, methods[3].wait_time, 0.01)
@@ -0,0 +1,20 @@
1
+ 1.8 passes, 1.9 however...
2
+
3
+
4
+ 1) Failure:
5
+ test_thread_count(ThreadTest) [E:/dev/ruby/ruby-prof/test/thread_test.rb:22]:
6
+ <2> expected but was
7
+ <1>.
8
+
9
+ 2) Failure:
10
+ test_thread_identity(ThreadTest) [E:/dev/ruby/ruby-prof/test/thread_test.rb:37]:
11
+ <2> expected but was
12
+ <1>.
13
+
14
+ 3) Failure:
15
+ test_thread_timings(ThreadTest) [E:/dev/ruby/ruby-prof/test/thread_test.rb:58]:
16
+ <2> expected but was
17
+ <1>.
18
+
19
+ 43 tests, 390 assertions, 3 failures, 0 errors, 0 skips
20
+ rake aborted!
@@ -34,15 +34,20 @@ class RecursiveTest < Test::Unit::TestCase
34
34
  end
35
35
 
36
36
  methods = result.threads.values.first.sort.reverse
37
- assert_equal(6, methods.length)
38
-
37
+
38
+ if RUBY_VERSION < '1.9'
39
+ assert_equal(6, methods.length) # includes Fixnum+, Fixnum==...
40
+ else
41
+ assert_equal(4, methods.length)
42
+ end
43
+
39
44
  method = methods[0]
40
45
  assert_equal('RecursiveTest#test_simple', method.full_name)
41
46
  assert_equal(1, method.called)
42
- assert_in_delta(2, method.total_time, 0.01)
47
+ assert_in_delta(2, method.total_time, 0.05)
43
48
  assert_in_delta(0, method.self_time, 0.01)
44
49
  assert_in_delta(0, method.wait_time, 0.01)
45
- assert_in_delta(2, method.children_time, 0.01)
50
+ assert_in_delta(2, method.children_time, 0.05)
46
51
 
47
52
  assert_equal(1, method.call_infos.length)
48
53
  call_info = method.call_infos[0]
@@ -60,8 +65,11 @@ class RecursiveTest < Test::Unit::TestCase
60
65
  assert_equal(1, method.call_infos.length)
61
66
  call_info = method.call_infos[0]
62
67
  assert_equal('RecursiveTest#test_simple->Object#simple', call_info.call_sequence)
63
- assert_equal(4, call_info.children.length)
64
-
68
+ if RUBY_VERSION < '1.9'
69
+ assert_equal(4, call_info.children.length)
70
+ else
71
+ assert_equal(2, call_info.children.length)
72
+ end
65
73
  method = methods[2]
66
74
  assert_equal('Kernel#sleep', method.full_name)
67
75
  assert_equal(2, method.called)
@@ -90,58 +98,66 @@ class RecursiveTest < Test::Unit::TestCase
90
98
  assert_equal(1, method.call_infos.length)
91
99
  call_info = method.call_infos[0]
92
100
  assert_equal('RecursiveTest#test_simple->Object#simple->Object#simple-1', call_info.call_sequence)
93
- assert_equal(3, call_info.children.length)
94
-
95
- method = methods[4]
96
- assert_equal('Fixnum#-', method.full_name)
97
- assert_equal(2, method.called)
98
- assert_in_delta(0, method.total_time, 0.01)
99
- assert_in_delta(0, method.self_time, 0.01)
100
- assert_in_delta(0, method.wait_time, 0.01)
101
- assert_in_delta(0, method.children_time, 0.01)
102
-
103
- assert_equal(2, method.call_infos.length)
104
- call_info = method.call_infos[0]
105
- assert_equal('RecursiveTest#test_simple->Object#simple->Fixnum#-', call_info.call_sequence)
106
- assert_equal(0, call_info.children.length)
107
-
108
- call_info = method.call_infos[1]
109
- assert_equal('RecursiveTest#test_simple->Object#simple->Object#simple-1->Fixnum#-', call_info.call_sequence)
110
- assert_equal(0, call_info.children.length)
111
-
112
- method = methods[5]
113
- assert_equal('Fixnum#==', method.full_name)
114
- assert_equal(2, method.called)
115
- assert_in_delta(0, method.total_time, 0.01)
116
- assert_in_delta(0, method.self_time, 0.01)
117
- assert_in_delta(0, method.wait_time, 0.01)
118
- assert_in_delta(0, method.children_time, 0.01)
119
-
120
- assert_equal(2, method.call_infos.length)
121
- call_info = method.call_infos[0]
122
- assert_equal('RecursiveTest#test_simple->Object#simple->Fixnum#==', call_info.call_sequence)
123
- assert_equal(0, call_info.children.length)
124
-
125
- call_info = method.call_infos[1]
126
- assert_equal('RecursiveTest#test_simple->Object#simple->Object#simple-1->Fixnum#==', call_info.call_sequence)
127
- assert_equal(0, call_info.children.length)
101
+ if RUBY_VERSION < '1.9'
102
+ assert_equal(3, call_info.children.length)
103
+
104
+ method = methods[4]
105
+ assert_equal('Fixnum#-', method.full_name)
106
+ assert_equal(2, method.called)
107
+ assert_in_delta(0, method.total_time, 0.01)
108
+ assert_in_delta(0, method.self_time, 0.01)
109
+ assert_in_delta(0, method.wait_time, 0.01)
110
+ assert_in_delta(0, method.children_time, 0.01)
111
+
112
+ assert_equal(2, method.call_infos.length)
113
+ call_info = method.call_infos[0]
114
+ assert_equal('RecursiveTest#test_simple->Object#simple->Fixnum#-', call_info.call_sequence)
115
+ assert_equal(0, call_info.children.length)
116
+
117
+ call_info = method.call_infos[1]
118
+ assert_equal('RecursiveTest#test_simple->Object#simple->Object#simple-1->Fixnum#-', call_info.call_sequence)
119
+ assert_equal(0, call_info.children.length)
120
+
121
+ method = methods[5]
122
+ assert_equal('Fixnum#==', method.full_name)
123
+ assert_equal(2, method.called)
124
+ assert_in_delta(0, method.total_time, 0.01)
125
+ assert_in_delta(0, method.self_time, 0.01)
126
+ assert_in_delta(0, method.wait_time, 0.01)
127
+ assert_in_delta(0, method.children_time, 0.01)
128
+
129
+ assert_equal(2, method.call_infos.length)
130
+ call_info = method.call_infos[0]
131
+ assert_equal('RecursiveTest#test_simple->Object#simple->Fixnum#==', call_info.call_sequence)
132
+ assert_equal(0, call_info.children.length)
133
+
134
+ call_info = method.call_infos[1]
135
+ assert_equal('RecursiveTest#test_simple->Object#simple->Object#simple-1->Fixnum#==', call_info.call_sequence)
136
+ assert_equal(0, call_info.children.length)
137
+
138
+ else
139
+ assert_equal(1, call_info.children.length)
140
+ end
128
141
  end
129
-
142
+
130
143
  def test_cycle
131
144
  result = RubyProf.profile do
132
145
  cycle(2)
133
146
  end
134
147
 
135
148
  methods = result.threads.values.first.sort.reverse
136
- assert_equal(8, methods.length)
137
-
149
+ if RUBY_VERSION < '1.9'
150
+ assert_equal(8, methods.length) # includes Fixnum+ and Fixnum==, which aren't included in 1.9
151
+ else
152
+ assert_equal(6, methods.length)
153
+ end
138
154
  method = methods[0]
139
155
  assert_equal('RecursiveTest#test_cycle', method.full_name)
140
156
  assert_equal(1, method.called)
141
- assert_in_delta(2, method.total_time, 0.01)
157
+ assert_in_delta(2, method.total_time, 0.05)
142
158
  assert_in_delta(0, method.self_time, 0.01)
143
159
  assert_in_delta(0, method.wait_time, 0.01)
144
- assert_in_delta(2, method.children_time, 0.01)
160
+ assert_in_delta(2, method.children_time, 0.05)
145
161
 
146
162
  assert_equal(1, method.call_infos.length)
147
163
  call_info = method.call_infos[0]
@@ -151,10 +167,10 @@ class RecursiveTest < Test::Unit::TestCase
151
167
  method = methods[1]
152
168
  assert_equal('Object#cycle', method.full_name)
153
169
  assert_equal(1, method.called)
154
- assert_in_delta(2, method.total_time, 0.01)
170
+ assert_in_delta(2, method.total_time, 0.05)
155
171
  assert_in_delta(0, method.self_time, 0.01)
156
172
  assert_in_delta(0, method.wait_time, 0.01)
157
- assert_in_delta(2, method.children_time, 0.01)
173
+ assert_in_delta(2, method.children_time, 0.05)
158
174
 
159
175
  assert_equal(1, method.call_infos.length)
160
176
  call_info = method.call_infos[0]
@@ -164,20 +180,24 @@ class RecursiveTest < Test::Unit::TestCase
164
180
  method = methods[2]
165
181
  assert_equal('Object#sub_cycle', method.full_name)
166
182
  assert_equal(1, method.called)
167
- assert_in_delta(2, method.total_time, 0.01)
183
+ assert_in_delta(2, method.total_time, 0.05)
168
184
  assert_in_delta(0, method.self_time, 0.01)
169
185
  assert_in_delta(0, method.wait_time, 0.01)
170
- assert_in_delta(2, method.children_time, 0.01)
186
+ assert_in_delta(2, method.children_time, 0.05)
171
187
 
172
188
  assert_equal(1, method.call_infos.length)
173
189
  call_info = method.call_infos[0]
174
190
  assert_equal('RecursiveTest#test_cycle->Object#cycle->Object#sub_cycle', call_info.call_sequence)
175
- assert_equal(4, call_info.children.length)
191
+ if RUBY_VERSION < '1.9'
192
+ assert_equal(4, call_info.children.length)
193
+ else
194
+ assert_equal(2, call_info.children.length)
195
+ end
176
196
 
177
197
  method = methods[3]
178
198
  assert_equal('Kernel#sleep', method.full_name)
179
199
  assert_equal(2, method.called)
180
- assert_in_delta(2, method.total_time, 0.01)
200
+ assert_in_delta(2, method.total_time, 0.05)
181
201
  assert_in_delta(2, method.self_time, 0.01)
182
202
  assert_in_delta(0, method.wait_time, 0.01)
183
203
  assert_in_delta(0, method.children_time, 0.01)
@@ -194,10 +214,10 @@ class RecursiveTest < Test::Unit::TestCase
194
214
  method = methods[4]
195
215
  assert_equal('Object#cycle-1', method.full_name)
196
216
  assert_equal(1, method.called)
197
- assert_in_delta(1, method.total_time, 0.01)
217
+ assert_in_delta(1, method.total_time, 0.05)
198
218
  assert_in_delta(0, method.self_time, 0.01)
199
219
  assert_in_delta(0, method.wait_time, 0.01)
200
- assert_in_delta(1, method.children_time, 0.01)
220
+ assert_in_delta(1, method.children_time, 0.05)
201
221
 
202
222
  assert_equal(1, method.call_infos.length)
203
223
  call_info = method.call_infos[0]
@@ -215,40 +235,44 @@ class RecursiveTest < Test::Unit::TestCase
215
235
  assert_equal(1, method.call_infos.length)
216
236
  call_info = method.call_infos[0]
217
237
  assert_equal('RecursiveTest#test_cycle->Object#cycle->Object#sub_cycle->Object#cycle-1->Object#sub_cycle-1', call_info.call_sequence)
218
- assert_equal(3, call_info.children.length)
219
-
220
- method = methods[6]
221
- assert_equal('Fixnum#-', method.full_name)
222
- assert_equal(2, method.called)
223
- assert_in_delta(0, method.total_time, 0.01)
224
- assert_in_delta(0, method.self_time, 0.01)
225
- assert_in_delta(0, method.wait_time, 0.01)
226
- assert_in_delta(0, method.children_time, 0.01)
227
-
228
- assert_equal(2, method.call_infos.length)
229
- call_info = method.call_infos[0]
230
- assert_equal('RecursiveTest#test_cycle->Object#cycle->Object#sub_cycle->Fixnum#-', call_info.call_sequence)
231
- assert_equal(0, call_info.children.length)
232
-
233
- call_info = method.call_infos[1]
234
- assert_equal('RecursiveTest#test_cycle->Object#cycle->Object#sub_cycle->Object#cycle-1->Object#sub_cycle-1->Fixnum#-', call_info.call_sequence)
235
- assert_equal(0, call_info.children.length)
236
-
237
- method = methods[7]
238
- assert_equal('Fixnum#==', method.full_name)
239
- assert_equal(2, method.called)
240
- assert_in_delta(0, method.total_time, 0.01)
241
- assert_in_delta(0, method.self_time, 0.01)
242
- assert_in_delta(0, method.wait_time, 0.01)
243
- assert_in_delta(0, method.children_time, 0.01)
244
-
245
- assert_equal(2, method.call_infos.length)
246
- call_info = method.call_infos[0]
247
- assert_equal('RecursiveTest#test_cycle->Object#cycle->Object#sub_cycle->Fixnum#==', call_info.call_sequence)
248
- assert_equal(0, call_info.children.length)
238
+ if RUBY_VERSION < '1.9'
239
+ assert_equal(3, call_info.children.length)
240
+ method = methods[6]
241
+ assert_equal('Fixnum#-', method.full_name)
242
+ assert_equal(2, method.called)
243
+ assert_in_delta(0, method.total_time, 0.01)
244
+ assert_in_delta(0, method.self_time, 0.01)
245
+ assert_in_delta(0, method.wait_time, 0.01)
246
+ assert_in_delta(0, method.children_time, 0.01)
247
+
248
+ assert_equal(2, method.call_infos.length)
249
+ call_info = method.call_infos[0]
250
+ assert_equal('RecursiveTest#test_cycle->Object#cycle->Object#sub_cycle->Fixnum#-', call_info.call_sequence)
251
+ assert_equal(0, call_info.children.length)
252
+
253
+ call_info = method.call_infos[1]
254
+ assert_equal('RecursiveTest#test_cycle->Object#cycle->Object#sub_cycle->Object#cycle-1->Object#sub_cycle-1->Fixnum#-', call_info.call_sequence)
255
+ assert_equal(0, call_info.children.length)
256
+
257
+ method = methods[7]
258
+ assert_equal('Fixnum#==', method.full_name)
259
+ assert_equal(2, method.called)
260
+ assert_in_delta(0, method.total_time, 0.01)
261
+ assert_in_delta(0, method.self_time, 0.01)
262
+ assert_in_delta(0, method.wait_time, 0.01)
263
+ assert_in_delta(0, method.children_time, 0.01)
264
+
265
+ assert_equal(2, method.call_infos.length)
266
+ call_info = method.call_infos[0]
267
+ assert_equal('RecursiveTest#test_cycle->Object#cycle->Object#sub_cycle->Fixnum#==', call_info.call_sequence)
268
+ assert_equal(0, call_info.children.length)
269
+
270
+ call_info = method.call_infos[1]
271
+ assert_equal('RecursiveTest#test_cycle->Object#cycle->Object#sub_cycle->Object#cycle-1->Object#sub_cycle-1->Fixnum#==', call_info.call_sequence)
272
+ assert_equal(0, call_info.children.length)
273
+ else
274
+ assert_equal(1, call_info.children.length)
275
+ end
249
276
 
250
- call_info = method.call_infos[1]
251
- assert_equal('RecursiveTest#test_cycle->Object#cycle->Object#sub_cycle->Object#cycle-1->Object#sub_cycle-1->Fixnum#==', call_info.call_sequence)
252
- assert_equal(0, call_info.children.length)
253
277
  end
254
- end
278
+ end