Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix code block in compare.rb rdoc comments #137

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 14 additions & 14 deletions lib/benchmark/compare.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,22 +30,22 @@ module Benchmark
# +x.compare!+ also takes an +order: :baseline+ option.
#
# Example:
# > Benchmark.ips do |x|
# x.report('Reduce using block') { [*1..10].reduce { |sum, n| sum + n } }
# x.report('Reduce using tag') { [*1..10].reduce(:+) }
# x.report('Reduce using to_proc') { [*1..10].reduce(&:+) }
# x.compare!(order: :baseline)
# end
# > Benchmark.ips do |x|
# x.report('Reduce using block') { [*1..10].reduce { |sum, n| sum + n } }
# x.report('Reduce using tag') { [*1..10].reduce(:+) }
# x.report('Reduce using to_proc') { [*1..10].reduce(&:+) }
# x.compare!(order: :baseline)
# end
#
# Calculating -------------------------------------
# Reduce using block 886.202k (± 2.2%) i/s - 4.521M in 5.103774s
# Reduce using tag 1.821M (± 1.6%) i/s - 9.111M in 5.004183s
# Reduce using to_proc 895.948k (± 1.6%) i/s - 4.528M in 5.055368s
# Calculating -------------------------------------
# Reduce using block 886.202k (± 2.2%) i/s - 4.521M in 5.103774s
# Reduce using tag 1.821M (± 1.6%) i/s - 9.111M in 5.004183s
# Reduce using to_proc 895.948k (± 1.6%) i/s - 4.528M in 5.055368s
#
# Comparison:
# Reduce using block: 886202.5 i/s
# Reduce using tag: 1821055.0 i/s - 2.05x (± 0.00) faster
# Reduce using to_proc: 895948.1 i/s - same-ish: difference falls within error
# Comparison:
# Reduce using block: 886202.5 i/s
# Reduce using tag: 1821055.0 i/s - 2.05x (± 0.00) faster
# Reduce using to_proc: 895948.1 i/s - same-ish: difference falls within error
#
# The first report is considered the baseline against which other reports are compared.
module Compare
Expand Down