Skip to content

Commit

Permalink
Minor whitespace and formatting changes.
Browse files Browse the repository at this point in the history
  • Loading branch information
Pistos committed Jan 27, 2015
1 parent b3b9e50 commit 9784431
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
8 changes: 4 additions & 4 deletions lib/better-benchmark.rb
Expand Up @@ -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
Expand Down
13 changes: 7 additions & 6 deletions 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
Expand All @@ -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
end

0 comments on commit 9784431

Please sign in to comment.