From 97844311f049ed5537988d34f8ac8d43a841e1f8 Mon Sep 17 00:00:00 2001 From: Pistos Date: Tue, 27 Jan 2015 12:39:02 -0500 Subject: [PATCH] Minor whitespace and formatting changes. --- lib/better-benchmark.rb | 8 ++++---- lib/better-benchmark/comparison-partial.rb | 13 +++++++------ 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/lib/better-benchmark.rb b/lib/better-benchmark.rb index 73e539d..656c47f 100644 --- a/lib/better-benchmark.rb +++ b/lib/better-benchmark.rb @@ -74,11 +74,11 @@ def self.compare_times( times1, times2, required_significance = DEFAULT_REQUIRED # by the blocks. For code blocks that execute extremely rapidly, you may # need hundreds of thousands of :inner_iterations. def self.compare_realtime( options = {}, &block1 ) - options[ :iterations ] ||= 20 - options[ :inner_iterations ] ||= 1 + options[:iterations] ||= 20 + options[:inner_iterations] ||= 1 - if options[ :iterations ] > 30 - warn "The number of iterations is set to #{options[ :iterations ]}. " + + if options[:iterations] > 30 + warn "The number of iterations is set to #{options[:iterations]}. " + "Using too many iterations may make the test results less reliable. " + "It is recommended to increase the number of :inner_iterations instead." end diff --git a/lib/better-benchmark/comparison-partial.rb b/lib/better-benchmark/comparison-partial.rb index e757913..3e8a5db 100644 --- a/lib/better-benchmark/comparison-partial.rb +++ b/lib/better-benchmark/comparison-partial.rb @@ -1,5 +1,6 @@ module Benchmark class ComparisonPartial + # @param options [Hash] @see Benchmark.compare_realtime def initialize( block, options ) @block1 = block @options = options @@ -9,25 +10,25 @@ def with( &block2 ) times1 = [] times2 = [] - (1..@options[ :iterations ]).each do |iteration| - if @options[ :verbose ] + (1..@options[:iterations]).each do |iteration| + if @options[:verbose] $stdout.print "."; $stdout.flush end times1 << Benchmark.realtime do - @options[ :inner_iterations ].times do |i| + @options[:inner_iterations].times do |i| @block1.call( iteration ) end end times2 << Benchmark.realtime do - @options[ :inner_iterations ].times do |i| + @options[:inner_iterations].times do |i| block2.call( iteration ) end end end - ::Benchmark.compare_times( times1, times2, @options[ :required_significance ] ) + ::Benchmark.compare_times( times1, times2, @options[:required_significance] ) end alias to with end -end \ No newline at end of file +end