YJIT: small fix to stats formatting. (#12282)
Avoid division by zero and NaN%, e.g. num_throw_break: 0 ( NaN%) num_throw_retry: 0 ( NaN%) num_throw_return: 0 ( NaN%)
This commit is contained in:
parent
c45503f957
commit
8502a549ef
Notes:
git
2024-12-06 17:26:00 +00:00
Merged-By: maximecb <maximecb@ruby-lang.org>
5
yjit.rb
5
yjit.rb
@ -521,9 +521,14 @@ module RubyVM::YJIT
|
||||
# Format a number along with a percentage over a total value
|
||||
def format_number_pct(pad, number, total) # :nodoc:
|
||||
padded_count = format_number(pad, number)
|
||||
|
||||
if total != 0
|
||||
percentage = number.fdiv(total) * 100
|
||||
formatted_pct = "%4.1f%%" % percentage
|
||||
"#{padded_count} (#{formatted_pct})"
|
||||
else
|
||||
"#{padded_count}"
|
||||
end
|
||||
end
|
||||
|
||||
# :startdoc:
|
||||
|
Loading…
x
Reference in New Issue
Block a user