1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

[lib/benchmark] Use $stdout instead of STDOUT [Bug #17600]

This commit is contained in:
Marc-Andre Lafortune 2021-03-01 19:22:23 -05:00
parent 80e2c45f55
commit 61f417ac7d

View file

@ -163,8 +163,8 @@ module Benchmark
#
def benchmark(caption = "", label_width = nil, format = nil, *labels) # :yield: report
sync = STDOUT.sync
STDOUT.sync = true
sync = $stdout.sync
$stdout.sync = true
label_width ||= 0
label_width += 1
format ||= FORMAT
@ -176,7 +176,7 @@ module Benchmark
}
report.list
ensure
STDOUT.sync = sync unless sync.nil?
$stdout.sync = sync unless sync.nil?
end
@ -247,8 +247,8 @@ module Benchmark
job = Job.new(width)
yield(job)
width = job.width + 1
sync = STDOUT.sync
STDOUT.sync = true
sync = $stdout.sync
$stdout.sync = true
# rehearsal
puts 'Rehearsal '.ljust(width+CAPTION.length,'-')
@ -268,7 +268,7 @@ module Benchmark
Benchmark.measure(label, &item).tap { |res| print res }
}
ensure
STDOUT.sync = sync unless sync.nil?
$stdout.sync = sync unless sync.nil?
end
#