File tree Expand file tree Collapse file tree 2 files changed +15
-12
lines changed Expand file tree Collapse file tree 2 files changed +15
-12
lines changed Original file line number Diff line number Diff line change 1313# Seed the global random number generator for repeatability between runs
1414Random . srand ( 1337 )
1515
16+ def format_number ( num )
17+ num . to_s . split ( "." ) . tap do |a |
18+ # Insert comma separators but only in the whole number portion (a[0]).
19+ # Look for "-?" at the end to preserve any leading minus sign that may be on the beginning.
20+ a [ 0 ] = a [ 0 ] . reverse . scan ( /\d {1,3}-?/ ) . join ( "," ) . reverse
21+
22+ # Add a space when positive so that if there is ever a negative
23+ # the first digit will line up.
24+ a [ 0 ] . prepend ( " " ) unless a [ 0 ] . start_with? ( "-" )
25+ end . join ( "." )
26+ end
27+
1628def run_cmd ( *args )
1729 puts "Command: #{ args . join ( " " ) } "
1830 system ( *args )
@@ -114,7 +126,7 @@ def return_results(warmup_iterations, bench_iterations)
114126 if yjit_stats
115127 yjit_bench_results [ "yjit_stats" ] = yjit_stats
116128
117- formatted_stats = proc { |key | "%10s" % yjit_stats [ key ] . to_s . split ( "." ) . tap { | a | a [ 0 ] = a [ 0 ] . reverse . scan ( / \d {1,3}/ ) . join ( "," ) . reverse } . join ( "." ) }
129+ formatted_stats = proc { |key | "%10s" % format_number ( yjit_stats [ key ] ) }
118130 yjit_stats_keys = [
119131 *ENV . fetch ( "YJIT_BENCH_STATS" , "" ) . split ( "," ) . map ( &:to_sym ) ,
120132 :inline_code_size ,
Original file line number Diff line number Diff line change @@ -59,17 +59,8 @@ def run_benchmark(_num_itrs_hint, &block)
5959
6060 yjit_stats &.each do |key , old_value |
6161 new_value = RubyVM ::YJIT . runtime_stats ( key )
62-
63- # Insert comma separators but only in the whole number portion.
64- diff = ( new_value - old_value ) . to_s . split ( "." ) . tap do |a |
65- # Preserve any leading minus sign that may be on the beginning.
66- a [ 0 ] = a [ 0 ] . reverse . scan ( /\d {1,3}-?/ ) . join ( "," ) . reverse
67- # Add a space when positive so that if there is ever a negative
68- # the first digit will line up.
69- a [ 0 ] . prepend ( " " ) unless a [ 0 ] . start_with? ( "-" )
70- end . join ( "." )
71-
72- itr_str << " %#{ key . size } s" % diff
62+ diff = ( new_value - old_value )
63+ itr_str << " %#{ key . size } s" % format_number ( diff )
7364 yjit_stats [ key ] = new_value
7465 end
7566
You can’t perform that action at this time.
0 commit comments