Issue #4197 has been updated by Tomoyuki Chikanaga.


Hi,
In Benchmark#bmbm, I think it's better to use ensure clause instead of Object#tap to restore STDOUT.sync. How about a patch below?

diff --git a/lib/benchmark.rb b/lib/benchmark.rb
index 052b9ad..ac17ba4 100644
--- a/lib/benchmark.rb
+++ b/lib/benchmark.rb
@@ -266,9 +266,9 @@ module Benchmark
       GC.start
       print label.ljust(width)
       Benchmark.measure(&item).tap { |res| print res.format }
-    }.tap {
-      STDOUT.sync = sync
     }
+  ensure
+    STDOUT.sync = sync unless sync.nil?
   end
 
   #

----------------------------------------
http://redmine.ruby-lang.org/issues/show/4197

----------------------------------------
http://redmine.ruby-lang.org