Skip to content

Commit 29dbed1

Browse files
committed
* gc.c (gc_profile_total_time): fix off-by-one error in GC::Profiler.total_time.
* test/ruby/test_gc.rb (class TestGc): test for above. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43457 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
1 parent fb3bd5a commit 29dbed1

File tree

3 files changed

+17
-1
lines changed

3 files changed

+17
-1
lines changed

ChangeLog

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
Tue Oct 29 11:10:08 2013 Aman Gupta <[email protected]>
2+
3+
* gc.c (gc_profile_total_time): fix off-by-one error in
4+
GC::Profiler.total_time.
5+
* test/ruby/test_gc.rb (class TestGc): test for above.
6+
17
Tue Oct 29 09:53:00 2013 Charlie Somerville <[email protected]>
28

39
* insns.def, vm.c, vm_insnhelper.c, vm_insnhelper.h, vm_method.c: split

gc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6140,7 +6140,7 @@ gc_profile_total_time(VALUE self)
61406140

61416141
if (objspace->profile.run && objspace->profile.next_index > 0) {
61426142
size_t i;
6143-
size_t count = objspace->profile.next_index - 1;
6143+
size_t count = objspace->profile.next_index;
61446144

61456145
for (i = 0; i < count; i++) {
61466146
time += objspace->profile.records[i].gc_time;

test/ruby/test_gc.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,16 @@ def test_profiler_clear
166166
eom
167167
end
168168

169+
def test_profiler_total_time
170+
GC::Profiler.enable
171+
GC::Profiler.clear
172+
173+
GC.start
174+
assert_operator(GC::Profiler.total_time, :>, 0)
175+
ensure
176+
GC::Profiler.disable
177+
end
178+
169179
def test_finalizing_main_thread
170180
assert_in_out_err(%w[--disable-gems], <<-EOS, ["\"finalize\""], [], "[ruby-dev:46647]")
171181
ObjectSpace.define_finalizer(Thread.main) { p 'finalize' }

0 commit comments

Comments
 (0)