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

ruby-changes:55336

From: k0kubun <ko1@a...>
Date: Sun, 14 Apr 2019 15:57:25 +0900 (JST)
Subject: [ruby-changes:55336] k0kubun:r67544 (trunk): Add RubyVM.reset_debug_counters when RB_DEBUG_COUNTER

k0kubun	2019-04-14 15:57:21 +0900 (Sun, 14 Apr 2019)

  New Revision: 67544

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=67544

  Log:
    Add RubyVM.reset_debug_counters when RB_DEBUG_COUNTER
    
    is defined. It's 0 by default and so it dissappears on actual build.

  Modified files:
    trunk/debug_counter.c
    trunk/debug_counter.h
    trunk/vm.c
Index: debug_counter.c
===================================================================
--- debug_counter.c	(revision 67543)
+++ debug_counter.c	(revision 67544)
@@ -43,6 +43,15 @@ rb_debug_counter_show_results(const char https://github.com/ruby/ruby/blob/trunk/debug_counter.c#L43
     }
 }
 
+VALUE
+rb_debug_counter_reset(void)
+{
+    for (int i = 0; i < RB_DEBUG_COUNTER_MAX; i++) {
+        rb_debug_counter[i] = 0;
+    }
+    return Qnil;
+}
+
 __attribute__((destructor))
 static void
 debug_counter_show_results_at_exit(void)
Index: debug_counter.h
===================================================================
--- debug_counter.h	(revision 67543)
+++ debug_counter.h	(revision 67544)
@@ -319,6 +319,8 @@ rb_debug_counter_add(enum rb_debug_count https://github.com/ruby/ruby/blob/trunk/debug_counter.h#L319
     return cond;
 }
 
+VALUE rb_debug_counter_reset(void);
+
 #define RB_DEBUG_COUNTER_INC(type)                rb_debug_counter_add(RB_DEBUG_COUNTER_##type, 1, 1)
 #define RB_DEBUG_COUNTER_INC_UNLESS(type, cond) (!rb_debug_counter_add(RB_DEBUG_COUNTER_##type, 1, !(cond)))
 #define RB_DEBUG_COUNTER_INC_IF(type, cond)       rb_debug_counter_add(RB_DEBUG_COUNTER_##type, 1, (cond))
Index: vm.c
===================================================================
--- vm.c	(revision 67543)
+++ vm.c	(revision 67544)
@@ -2872,6 +2872,9 @@ Init_VM(void) https://github.com/ruby/ruby/blob/trunk/vm.c#L2872
     rb_undef_alloc_func(rb_cRubyVM);
     rb_undef_method(CLASS_OF(rb_cRubyVM), "new");
     rb_define_singleton_method(rb_cRubyVM, "stat", vm_stat, -1);
+#if USE_DEBUG_COUNTER
+    rb_define_singleton_method(rb_cRubyVM, "reset_debug_counters", rb_debug_counter_reset, 0);
+#endif
 
     /* FrozenCore (hidden) */
     fcore = rb_class_new(rb_cBasicObject);

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

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