@@ -40,16 +40,18 @@ def run_benchmark(_num_itrs_hint, &block)
4040
4141 RubyVM ::YJIT . reset_stats! if defined? ( RubyVM ::YJIT ) && RubyVM ::YJIT . enabled?
4242
43- # If $YJIT_BENCH_STATS is given, print the diff of these stats at each iteration.
44- if ENV [ "YJIT_BENCH_STATS" ]
45- yjit_stats = ENV [ "YJIT_BENCH_STATS" ] . split ( "," ) . map { |key | [ key . to_sym , nil ] } . to_h
43+ # If $YJIT_BENCH_STATS or $ZJIT_BENCH_STATS is given, print the diff of these stats at each iteration.
44+ if yjit_stats = ENV [ "YJIT_BENCH_STATS" ]
45+ yjit_stats = yjit_stats . split ( "," ) . map ( & :to_sym ) . map { |key | [ key , RubyVM :: YJIT . runtime_stats ( key ) ] } . to_h
4646 yjit_stats . each_key { |key | header << " #{ key } " }
4747 end
48+ if zjit_stats = ENV [ "ZJIT_BENCH_STATS" ]
49+ zjit_stats = zjit_stats . split ( "," ) . map ( &:to_sym ) . map { |key | [ key , RubyVM ::ZJIT . stats ( key ) ] } . to_h
50+ zjit_stats . each_key { |key | header << " #{ key } " }
51+ end
4852
4953 puts header
5054 begin
51- yjit_stats &.each_key { |key | yjit_stats [ key ] = RubyVM ::YJIT . runtime_stats ( key ) }
52-
5355 time = realtime ( &block )
5456 num_itrs += 1
5557
@@ -59,10 +61,14 @@ def run_benchmark(_num_itrs_hint, &block)
5961
6062 yjit_stats &.each do |key , old_value |
6163 new_value = RubyVM ::YJIT . runtime_stats ( key )
62- diff = ( new_value - old_value )
63- itr_str << " %#{ key . size } s" % format_number ( diff )
64+ itr_str << " %#{ key . size } s" % format_number ( new_value - old_value )
6465 yjit_stats [ key ] = new_value
6566 end
67+ zjit_stats &.each do |key , old_value |
68+ new_value = RubyVM ::ZJIT . stats ( key )
69+ itr_str << " %#{ key . size } s" % format_number ( new_value - old_value )
70+ zjit_stats [ key ] = new_value
71+ end
6672
6773 puts itr_str
6874 # NOTE: we may want to preallocate an array and avoid append
0 commit comments