summaryrefslogtreecommitdiff
path: root/zjit.rb
diff options
context:
space:
mode:
Diffstat (limited to 'zjit.rb')
-rw-r--r--zjit.rb24
1 files changed, 23 insertions, 1 deletions
diff --git a/zjit.rb b/zjit.rb
index a307abdf88..fc2c80c52f 100644
--- a/zjit.rb
+++ b/zjit.rb
@@ -22,6 +22,7 @@ class << RubyVM::ZJIT
# Return \ZJIT statistics as a Hash
def stats
stats = Primitive.rb_zjit_stats
+ return nil if stats.nil?
if stats.key?(:vm_insns_count) && stats.key?(:zjit_insns_count)
stats[:total_insns_count] = stats[:vm_insns_count] + stats[:zjit_insns_count]
@@ -37,15 +38,29 @@ class << RubyVM::ZJIT
stats = self.stats
[
+ :compile_time_ns,
+ :profile_time_ns,
+ :gc_time_ns,
+ :invalidation_time_ns,
:total_insns_count,
:vm_insns_count,
:zjit_insns_count,
:ratio_in_zjit,
].each do |key|
+ # Some stats like vm_insns_count and ratio_in_zjit are not supported on the release build
+ next unless stats.key?(key)
value = stats[key]
- if key == :ratio_in_zjit
+
+ case key
+ when :ratio_in_zjit
value = '%0.1f%%' % value
+ when /_time_ns\z/
+ key = key.to_s.sub(/_time_ns\z/, '_time')
+ value = "#{number_with_delimiter(value / 10**6)}ms"
+ else
+ value = number_with_delimiter(value)
end
+
buf << "#{'%-18s' % "#{key}:"} #{value}\n"
end
buf
@@ -59,6 +74,13 @@ class << RubyVM::ZJIT
# :stopdoc:
private
+ def number_with_delimiter(number)
+ s = number.to_s
+ i = s.index('.') || s.size
+ s.insert(i -= 3, ',') while i > 3
+ s
+ end
+
# Print ZJIT stats
def print_stats
$stderr.write stats_string