[前][次][番号順一覧][スレッド一覧]

ruby-changes:31378

From: tmm1 <ko1@a...>
Date: Tue, 29 Oct 2013 11:11:34 +0900 (JST)
Subject: [ruby-changes:31378] tmm1:r43457 (trunk): * gc.c (gc_profile_total_time): fix off-by-one error in GC::Profiler.total_time.

tmm1	2013-10-29 11:11:26 +0900 (Tue, 29 Oct 2013)

  New Revision: 43457

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=43457

  Log:
    * 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.

  Modified files:
    trunk/ChangeLog
    trunk/gc.c
    trunk/test/ruby/test_gc.rb
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 43456)
+++ ChangeLog	(revision 43457)
@@ -1,3 +1,9 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Tue Oct 29 11:10:08 2013  Aman Gupta <ruby@t...>
+
+	* 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.
+
 Tue Oct 29 09:53:00 2013  Charlie Somerville  <charliesome@r...>
 
 	* insns.def, vm.c, vm_insnhelper.c, vm_insnhelper.h, vm_method.c: split
Index: gc.c
===================================================================
--- gc.c	(revision 43456)
+++ gc.c	(revision 43457)
@@ -6140,7 +6140,7 @@ gc_profile_total_time(VALUE self) https://github.com/ruby/ruby/blob/trunk/gc.c#L6140
 
     if (objspace->profile.run && objspace->profile.next_index > 0) {
 	size_t i;
-	size_t count = objspace->profile.next_index - 1;
+	size_t count = objspace->profile.next_index;
 
 	for (i = 0; i < count; i++) {
 	    time += objspace->profile.records[i].gc_time;
Index: test/ruby/test_gc.rb
===================================================================
--- test/ruby/test_gc.rb	(revision 43456)
+++ test/ruby/test_gc.rb	(revision 43457)
@@ -166,6 +166,16 @@ class TestGc < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_gc.rb#L166
     eom
   end
 
+  def test_profiler_total_time
+    GC::Profiler.enable
+    GC::Profiler.clear
+
+    GC.start
+    assert_operator(GC::Profiler.total_time, :>, 0)
+  ensure
+    GC::Profiler.disable
+  end
+
   def test_finalizing_main_thread
     assert_in_out_err(%w[--disable-gems], <<-EOS, ["\"finalize\""], [], "[ruby-dev:46647]")
       ObjectSpace.define_finalizer(Thread.main) { p 'finalize' }

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]