Skip to content

Commit

Permalink
cleanup rubocop issue Style/FormatString
Browse files Browse the repository at this point in the history
cleanuped by rubocop --auto-correct

Signed-off-by: Li Zhijian <[email protected]>
Signed-off-by: Philip Li <[email protected]>
  • Loading branch information
zhijianli88 authored and rli9 committed Oct 11, 2017
1 parent 4af159d commit 3b5f95c
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 19 deletions.
2 changes: 1 addition & 1 deletion lib/common.rb
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ def format_number(number)
else
'%.4g'
end
s = fmt % [number]
s = format(fmt, number)
# Remove trailing 0
if fmt[-1] == 'f'
s.gsub(/\.?0+$/, '')
Expand Down
8 changes: 4 additions & 4 deletions lib/plot.rb
Original file line number Diff line number Diff line change
Expand Up @@ -95,15 +95,15 @@ def setup_output(plot, file_name)
if file_name
case file_name
when /eps/
plot.terminal 'eps size %d,%d fontscale 1' % @inch_size
plot.terminal format('eps size %d,%d fontscale 1', @inch_size)
file_name += '.eps' unless file_name.end_with? '.eps'
else
plot.terminal 'png size %d,%d' % @pixel_size
plot.terminal format('png size %d,%d', @pixel_size)
file_name += '.png' unless file_name.end_with? '.png'
end
plot.output file_name
else
plot.terminal 'dumb nofeed size %d,%d' % @char_size
plot.terminal format('dumb nofeed size %d,%d', @char_size)
end
end
end
Expand Down Expand Up @@ -210,7 +210,7 @@ def plot
setup_output p, file
else
if (np % @nr_plot).zero?
p.terminal 'dumb nofeed size %d,%d' % @char_size
p.terminal format('dumb nofeed size %d,%d', @char_size)
p.multiplot "layout 1,#{@nr_plot}"
end
np += 1
Expand Down
4 changes: 2 additions & 2 deletions lib/stats.rb
Original file line number Diff line number Diff line change
Expand Up @@ -510,8 +510,8 @@ def __get_changed_stats(a, b, is_incomplete_run, options)
next unless is_reasonable_perf_change(k, delta, max)
end

interval_a = '[ %-10.5g - %-10.5g ]' % [min_a, max_a]
interval_b = '[ %-10.5g - %-10.5g ]' % [min_b, max_b]
interval_a = format('[ %-10.5g - %-10.5g ]', min_a, max_a)
interval_b = format('[ %-10.5g - %-10.5g ]', min_b, max_b)
interval = interval_a + ' -- ' + interval_b

changed_stats[k] = { 'stat' => k,
Expand Down
24 changes: 12 additions & 12 deletions sbin/compare
Original file line number Diff line number Diff line change
Expand Up @@ -505,45 +505,45 @@ def show_one_diff(stat, dim, v0, v, v0_stddev, v_stddev, is_float, is_exp, is_fa
p = 0
end
if is_fail
buf = sprintf "%#{REL_WIDTH - 2}.0f%% ", p
buf = format "%#{REL_WIDTH - 2}.0f%% ", p
elsif stat =~ ABS_CHANGE_STATS_RE
buf = sprintf "%#{REL_WIDTH - 1}.0g ", v - v0
buf = format "%#{REL_WIDTH - 1}.0g ", v - v0
elsif p.abs < 3
buf = sprintf ' ' * REL_WIDTH
elsif p.abs < 100_000
buf = sprintf "%#{REL_WIDTH - 2}.0f%% ", p
buf = format "%#{REL_WIDTH - 2}.0f%% ", p
else
buf = sprintf "%#{REL_WIDTH - 2}.0g%% ", p
buf = format "%#{REL_WIDTH - 2}.0g%% ", p
end

buf = Term::ANSIColor.intense_red(buf) if p.abs >= 50 && $colorful
end

if is_exp
if is_float == false && v.abs < 100_000_000
buf += sprintf "%#{ABS_WIDTH}d", v
buf += format "%#{ABS_WIDTH}d", v
else
buf += sprintf "%#{ABS_WIDTH}.4g", v
buf += format "%#{ABS_WIDTH}.4g", v
end
elsif is_float
buf += sprintf "%#{ABS_WIDTH}.2f", v
buf += format "%#{ABS_WIDTH}.2f", v
elsif is_fail
if v.zero?
buf += sprintf "%#{ABS_WIDTH + 1}s", ' '
buf += format "%#{ABS_WIDTH + 1}s", ' '
else
buf += sprintf "%#{ABS_WIDTH + 1}d", v
buf += format "%#{ABS_WIDTH + 1}d", v
end
else
buf += sprintf "%#{ABS_WIDTH}d", v
buf += format "%#{ABS_WIDTH}d", v
end

if v_stddev
if is_fail
buf += sprintf ":%-#{ERR_WIDTH - 2}d", v_stddev
buf += format ":%-#{ERR_WIDTH - 2}d", v_stddev
else
v_stddev = 100 * v_stddev / v if v != 0
if v_stddev > 3
buf += sprintf " ±%#{ERR_WIDTH - 3}d%%", v_stddev
buf += format " ±%#{ERR_WIDTH - 3}d%%", v_stddev
else
buf += ' ' * ERR_WIDTH
end
Expand Down

0 comments on commit 3b5f95c

Please sign in to comment.