diff --git a/misc/zjit_diff.rb b/misc/zjit_diff.rb index eacbfc06..2971f0c1 100755 --- a/misc/zjit_diff.rb +++ b/misc/zjit_diff.rb @@ -84,6 +84,7 @@ def initialize(path, threshold_pct: DEFAULT_THRESHOLD_PCT, minimum_diff: DEFAULT @minimum_diff = minimum_diff @limit = limit @benchmark_filter = benchmarks + normalize_zjit_stats! end def run @@ -396,6 +397,28 @@ def format_bytes(bytes) "#{bytes}B" end end + + # Strip hex addresses from stat keys so that entries like + # "##foo" and "##foo" + # collapse into one. Numeric values are summed when keys merge. + def normalize_zjit_stats! + @raw_data.each_value do |benchmarks| + benchmarks.each_value do |bench_data| + next unless bench_data.is_a?(Hash) && bench_data['zjit_stats'].is_a?(Hash) + stats = bench_data['zjit_stats'] + normalized = {} + stats.each do |key, value| + nkey = key.gsub(/0x\h+/, '0x…') + if normalized.key?(nkey) && value.is_a?(Numeric) && normalized[nkey].is_a?(Numeric) + normalized[nkey] += value + else + normalized[nkey] = value + end + end + bench_data['zjit_stats'] = normalized + end + end + end end if __FILE__ == $0