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

ruby-changes:68824

From: Alan <ko1@a...>
Date: Thu, 21 Oct 2021 08:14:05 +0900 (JST)
Subject: [ruby-changes:68824] 8302eb57b0 (master): Add UJIT.reset_stats!

https://git.ruby-lang.org/ruby.git/commit/?id=8302eb57b0

From 8302eb57b0492a5ebd021536f0f3a00b95694bf8 Mon Sep 17 00:00:00 2001
From: Alan Wu <XrXr@u...>
Date: Wed, 3 Mar 2021 16:56:24 -0500
Subject: Add UJIT.reset_stats!

To allow analyzing sections of the application.
---
 ujit.rb      |  6 ++++++
 ujit_iface.c | 13 +++++++++++++
 2 files changed, 19 insertions(+)

diff --git a/ujit.rb b/ujit.rb
index 6f63df4a8c..a2f61b1021 100644
--- a/ujit.rb
+++ b/ujit.rb
@@ -43,6 +43,12 @@ module UJIT https://github.com/ruby/ruby/blob/trunk/ujit.rb#L43
     Primitive.get_stat_counters
   end
 
+  # Discard statistics collected for --ujit-stats.
+  def self.reset_stats!
+    # defined in ujit_iface.c
+    Primitive.reset_stats_bang
+  end
+
   class << self
     private
 
diff --git a/ujit_iface.c b/ujit_iface.c
index 352ff392cb..2030501637 100644
--- a/ujit_iface.c
+++ b/ujit_iface.c
@@ -561,6 +561,19 @@ get_stat_counters(rb_execution_context_t *ec, VALUE self) https://github.com/ruby/ruby/blob/trunk/ujit_iface.c#L561
 #endif // if RUBY_DEBUG
 }
 
+// Primitive called in ujit.rb. Zero out all the counters.
+static VALUE
+reset_stats_bang(rb_execution_context_t *ec, VALUE self)
+{
+#if RUBY_DEBUG
+    vm_insns_count = 0;
+    rb_compiled_iseq_count = 0;
+    memset(&exit_op_count, 0, sizeof(exit_op_count));
+    memset(&ujit_runtime_counters, 0, sizeof(ujit_runtime_counters));
+#endif // if RUBY_DEBUG
+    return Qnil;
+}
+
 #include "ujit.rbinc"
 
 #if RUBY_DEBUG
-- 
cgit v1.2.1


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

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