ruby-prof 0.7.6 → 0.7.7

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.
@@ -37,7 +37,7 @@ module RubyProf
37
37
 
38
38
  def print_methods(thread_id, methods)
39
39
  # Get total time
40
- toplevel = methods.sort.last
40
+ toplevel = methods.max
41
41
  total_time = toplevel.total_time
42
42
  if total_time == 0
43
43
  total_time = 0.01
@@ -62,7 +62,7 @@ module RubyProf
62
62
  # Cache thread times since this is an expensive
63
63
  # operation with the required sorting
64
64
  @result.threads.each do |thread_id, methods|
65
- top = methods.sort.last
65
+ top = methods.max
66
66
 
67
67
  thread_time = 0.01
68
68
  thread_time = top.total_time if top.total_time > 0
@@ -36,7 +36,7 @@ module RubyProf
36
36
  # Cache thread times since this is an expensive
37
37
  # operation with the required sorting
38
38
  @result.threads.each do |thread_id, methods|
39
- top = methods.sort.last
39
+ top = methods.max
40
40
 
41
41
  thread_time = 0.01
42
42
  thread_time = top.total_time if top.total_time > 0
@@ -57,7 +57,7 @@ module RubyProf
57
57
  end
58
58
 
59
59
  def min_depth
60
- call_infos.map do |call_info|
60
+ @min_depth ||= call_infos.map do |call_info|
61
61
  call_info.depth
62
62
  end.min
63
63
  end
@@ -82,7 +82,7 @@ module RubyProf
82
82
 
83
83
  data = RubyProf.stop
84
84
  bench = data.threads.values.inject(0) do |total, method_infos|
85
- top = method_infos.sort.last
85
+ top = method_infos.max
86
86
  total += top.total_time
87
87
  total
88
88
  end
@@ -88,7 +88,7 @@ class AggregateTest < Test::Unit::TestCase
88
88
  assert_equal('AggClass#a', call_info.parent.target.full_name)
89
89
  assert_in_delta(3, call_info.total_time, 0.05)
90
90
  assert_in_delta(0, call_info.wait_time, 0.01)
91
- assert_in_delta(0, call_info.self_time, 0.01)
91
+ assert_in_delta(0, call_info.self_time, 0.05)
92
92
  assert_in_delta(3, call_info.children_time, 0.05)
93
93
  assert_equal(3, call_info.called)
94
94
  end
data/test/basic_test.rb CHANGED
@@ -137,14 +137,14 @@ class BasicTest < Test::Unit::TestCase
137
137
 
138
138
  methods = result.threads.values.first.sort.reverse
139
139
  assert_equal(6, methods.length)
140
-
141
- assert_equal('BasicTest#test_instance_methods', methods[0].full_name)
142
- assert_equal('C1#hello', methods[1].full_name)
143
- assert_equal('Kernel#sleep', methods[2].full_name)
144
- assert_equal('Class#new', methods[3].full_name)
145
-
146
- assert_equal("<Class::#{PARENT}>#allocate", methods[4].full_name)
147
- assert_equal("#{PARENT}#initialize", methods[5].full_name)
140
+ names = methods.map &:full_name
141
+ assert_equal('BasicTest#test_instance_methods', names[0])
142
+ assert_equal('C1#hello', names[1])
143
+ assert_equal('Kernel#sleep', names[2])
144
+ assert_equal('Class#new', names[3])
145
+ # order can differ
146
+ assert(names.include?("<Class::#{PARENT}>#allocate"))
147
+ assert(names.include?("#{PARENT}#initialize"))
148
148
 
149
149
  # Check times
150
150
  assert_in_delta(0.2, methods[0].total_time, 0.02)
@@ -190,17 +190,17 @@ class BasicTest < Test::Unit::TestCase
190
190
  assert_equal('Kernel#sleep', methods[2].full_name)
191
191
 
192
192
  # Check times
193
- assert_in_delta(0.3, methods[0].total_time, 0.02)
194
- assert_in_delta(0, methods[0].wait_time, 0.01)
195
- assert_in_delta(0, methods[0].self_time, 0.01)
193
+ assert_in_delta(0.3, methods[0].total_time, 0.1)
194
+ assert_in_delta(0, methods[0].wait_time, 0.02)
195
+ assert_in_delta(0, methods[0].self_time, 0.02)
196
196
 
197
- assert_in_delta(0.3, methods[1].total_time, 0.02)
198
- assert_in_delta(0, methods[1].wait_time, 0.01)
199
- assert_in_delta(0, methods[1].self_time, 0.01)
197
+ assert_in_delta(0.3, methods[1].total_time, 0.1)
198
+ assert_in_delta(0, methods[1].wait_time, 0.02)
199
+ assert_in_delta(0, methods[1].self_time, 0.02)
200
200
 
201
- assert_in_delta(0.3, methods[2].total_time, 0.02)
202
- assert_in_delta(0, methods[2].wait_time, 0.01)
203
- assert_in_delta(0.3, methods[2].self_time, 0.02)
201
+ assert_in_delta(0.3, methods[2].total_time, 0.1)
202
+ assert_in_delta(0, methods[2].wait_time, 0.02)
203
+ assert_in_delta(0.3, methods[2].self_time, 0.1)
204
204
  end
205
205
 
206
206
  def test_module_instance_methods
@@ -218,18 +218,18 @@ class BasicTest < Test::Unit::TestCase
218
218
 
219
219
  methods = result.threads.values.first.sort.reverse
220
220
  assert_equal(6, methods.length)
221
-
222
- assert_equal('BasicTest#test_module_instance_methods', methods[0].full_name)
223
- assert_equal('M1#hello', methods[1].full_name)
224
- assert_equal('Kernel#sleep', methods[2].full_name)
225
- assert_equal('Class#new', methods[3].full_name)
226
- assert_equal("<Class::#{PARENT}>#allocate", methods[4].full_name)
227
- assert_equal("#{PARENT}#initialize", methods[5].full_name)
221
+ names = methods.map &:full_name
222
+ assert_equal('BasicTest#test_module_instance_methods', names[0])
223
+ assert_equal('M1#hello', names[1])
224
+ assert_equal('Kernel#sleep', names[2])
225
+ assert_equal('Class#new', names[3])
226
+ assert(names.include?("<Class::#{PARENT}>#allocate"))
227
+ assert(names.include?("#{PARENT}#initialize"))
228
228
 
229
229
  # Check times
230
- assert_in_delta(0.3, methods[0].total_time, 0.02)
231
- assert_in_delta(0, methods[0].wait_time, 0.02)
232
- assert_in_delta(0, methods[0].self_time, 0.01)
230
+ assert_in_delta(0.3, methods[0].total_time, 0.1)
231
+ assert_in_delta(0, methods[0].wait_time, 0.1)
232
+ assert_in_delta(0, methods[0].self_time, 0.1)
233
233
 
234
234
  assert_in_delta(0.3, methods[1].total_time, 0.02)
235
235
  assert_in_delta(0, methods[1].wait_time, 0.01)
@@ -287,4 +287,4 @@ class BasicTest < Test::Unit::TestCase
287
287
 
288
288
  RubyProf.stop
289
289
  end
290
- end
290
+ end
@@ -1,20 +1,8 @@
1
1
  1.8 passes, 1.9 however...
2
2
 
3
-
4
3
  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>.
4
+ test_thread_timings(ThreadTest) [E:/dev/ruby/ruby-prof/test/thread_test.rb:76]:
5
+ Expected 0 - 1.0 (1.0) to be < 0.01.
18
6
 
19
- 43 tests, 390 assertions, 3 failures, 0 errors, 0 skips
20
- rake aborted!
7
+ 43 tests, 410 assertions, 1 failures, 0 errors, 0 skips
8
+ rake aborted!
@@ -181,8 +181,8 @@ class RecursiveTest < Test::Unit::TestCase
181
181
  assert_equal('Object#sub_cycle', method.full_name)
182
182
  assert_equal(1, method.called)
183
183
  assert_in_delta(2, method.total_time, 0.05)
184
- assert_in_delta(0, method.self_time, 0.01)
185
- assert_in_delta(0, method.wait_time, 0.01)
184
+ assert_in_delta(0, method.self_time, 0.05)
185
+ assert_in_delta(0, method.wait_time, 0.05)
186
186
  assert_in_delta(2, method.children_time, 0.05)
187
187
 
188
188
  assert_equal(1, method.call_infos.length)
@@ -198,7 +198,7 @@ class RecursiveTest < Test::Unit::TestCase
198
198
  assert_equal('Kernel#sleep', method.full_name)
199
199
  assert_equal(2, method.called)
200
200
  assert_in_delta(2, method.total_time, 0.05)
201
- assert_in_delta(2, method.self_time, 0.01)
201
+ assert_in_delta(2, method.self_time, 0.05)
202
202
  assert_in_delta(0, method.wait_time, 0.01)
203
203
  assert_in_delta(0, method.children_time, 0.01)
204
204
 
data/test/stack_test.rb CHANGED
@@ -53,10 +53,10 @@ class StackTest < Test::Unit::TestCase
53
53
  method = methods[0]
54
54
  assert_equal('StackTest#test_call_sequence', method.full_name)
55
55
  assert_equal(1, method.called)
56
- assert_in_delta(8, method.total_time, 0.05)
56
+ assert_in_delta(8, method.total_time, 0.25)
57
57
  assert_in_delta(0, method.wait_time, 0.01)
58
58
  assert_in_delta(0, method.self_time, 0.01)
59
- assert_in_delta(8, method.children_time, 0.05)
59
+ assert_in_delta(8, method.children_time, 0.25)
60
60
  assert_equal(1, method.call_infos.length)
61
61
 
62
62
  call_info = method.call_infos[0]
@@ -83,7 +83,7 @@ class StackTest < Test::Unit::TestCase
83
83
  assert_equal(4, method.called)
84
84
  assert_in_delta(8, method.total_time, 0.05)
85
85
  assert_in_delta(0, method.wait_time, 0.01)
86
- assert_in_delta(8, method.self_time, 0.01)
86
+ assert_in_delta(8, method.self_time, 0.05)
87
87
  assert_in_delta(0, method.children_time, 0.05)
88
88
  assert_equal(4, method.call_infos.length)
89
89
 
@@ -135,4 +135,4 @@ class StackTest < Test::Unit::TestCase
135
135
  assert_equal('StackTest#test_call_sequence->StackClass#a->StackClass#c->StackClass#b', call_info.call_sequence)
136
136
  assert_equal(1, call_info.children.length)
137
137
  end
138
- end
138
+ end
@@ -43,10 +43,10 @@ class StartStopTest < Test::Unit::TestCase
43
43
  method = methods[0]
44
44
  assert_equal('StartStopTest#method1', method.full_name)
45
45
  assert_equal(1, method.called)
46
- assert_in_delta(2, method.total_time, 0.01)
46
+ assert_in_delta(2, method.total_time, 0.05)
47
47
  assert_in_delta(0, method.wait_time, 0.01)
48
48
  assert_in_delta(0, method.self_time, 0.01)
49
- assert_in_delta(2, method.children_time, 0.01)
49
+ assert_in_delta(2, method.children_time, 0.05)
50
50
  assert_equal(1, method.call_infos.length)
51
51
 
52
52
  call_info = method.call_infos[0]
data/test/thread_test.rb CHANGED
@@ -21,29 +21,27 @@ class ThreadTest < Test::Unit::TestCase
21
21
  result = RubyProf.stop
22
22
  assert_equal(2, result.threads.keys.length) # this should pass...
23
23
  end
24
-
24
+
25
25
  def test_thread_identity
26
26
  RubyProf.start
27
-
28
27
  thread = Thread.new do
29
- sleep(1)
28
+ sleep(1)
30
29
  end
31
-
32
30
  thread.join
33
31
  result = RubyProf.stop
34
32
 
35
33
  thread_ids = result.threads.keys.sort
36
- threads = [Thread.current, thread].sort_by {|th| th.object_id}
34
+ threads = [Thread.current, thread]
37
35
  assert_equal(2, thread_ids.length) # should pass
38
36
 
39
- assert_equal(threads[0].object_id, thread_ids[0])
40
- assert_equal(threads[1].object_id, thread_ids[1])
41
-
37
+ assert(thread_ids.include?(threads[0].object_id))
38
+ assert(thread_ids.include?(threads[1].object_id))
39
+
42
40
  assert_instance_of(Thread, ObjectSpace._id2ref(thread_ids[0]))
43
- assert_equal(threads[0], ObjectSpace._id2ref(thread_ids[0]))
41
+ assert(threads.include? (ObjectSpace._id2ref(thread_ids[0])))
44
42
 
45
43
  assert_instance_of(Thread, ObjectSpace._id2ref(thread_ids[1]))
46
- assert_equal(threads[1], ObjectSpace._id2ref(thread_ids[1]))
44
+ assert(threads.include?(ObjectSpace._id2ref(thread_ids[1])))
47
45
  end
48
46
 
49
47
  def test_thread_timings
@@ -64,7 +62,7 @@ class ThreadTest < Test::Unit::TestCase
64
62
  assert_equal(1, method.called)
65
63
  assert_in_delta(1, method.total_time, 0.05)
66
64
  assert_in_delta(0, method.self_time, 0.01)
67
- assert_in_delta(0, method.wait_time, 0.01) # this fails
65
+ assert_in_delta(0, method.wait_time, 0.01)
68
66
  assert_in_delta(1, method.children_time, 0.01)
69
67
  assert_equal(1, method.call_infos.length)
70
68
  call_info = method.call_infos[0]
@@ -159,4 +157,4 @@ class ThreadTest < Test::Unit::TestCase
159
157
  end
160
158
  end
161
159
  end
162
- end
160
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-prof
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.6
4
+ version: 0.7.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shugo Maeda and Charlie Savage
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-12-31 00:00:00 -07:00
12
+ date: 2010-01-13 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
@@ -53,6 +53,8 @@ files:
53
53
  - ext/mingw/build.rake
54
54
  - ext/vc/ruby_prof.sln
55
55
  - ext/vc/ruby_prof.vcproj
56
+ - lib/out_18
57
+ - lib/out_19
56
58
  - lib/ruby-prof/abstract_printer.rb
57
59
  - lib/ruby-prof/aggregate_call_info.rb
58
60
  - lib/ruby-prof/call_info.rb
@@ -65,8 +67,6 @@ files:
65
67
  - lib/ruby-prof/task.rb
66
68
  - lib/ruby-prof/test.rb
67
69
  - lib/ruby-prof.rb
68
- - lib/test.rb
69
- - lib/test2.rb
70
70
  - lib/unprof.rb
71
71
  - rails/environment/profile.rb
72
72
  - rails/example/example_test.rb
data/lib/test.rb DELETED
@@ -1,6 +0,0 @@
1
- require 'ruby-prof'
2
-
3
- RubyProf.start
4
- loop {
5
- Thread.new { sleep 1 }
6
- }
data/lib/test2.rb DELETED
@@ -1,4 +0,0 @@
1
- def go
2
- 3
3
- end
4
- go