-
-
Save Orbyt/8b9469b3234b260c6d1b2d107cc351f6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'benchmark/ips' | |
Benchmark.ips do |x| | |
# Configure the number of seconds used during | |
# the warmup phase (default 2) and calculation phase (default 5) | |
x.config(:time => 5, :warmup => 2) | |
# Typical mode, runs the block as many times as it can | |
x.report("No matches diff length") { "password123" == "321get" } | |
x.report("No matches same length") { "password123" == "321kmnktget"} | |
x.report("First matches") { "password123" == "p533melw321" } | |
x.report("First three matches") { "password123" == "pas3melw361" } | |
x.report("First six matches") { "password123" == "passwolw369" } | |
x.report("All matches") { "password123" == "password123" } | |
# Compare the iterations per second of the various reports! | |
x.compare! | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Warming up -------------------------------------- | |
No matches diff length | |
201.834k i/100ms | |
No matches same length | |
194.795k i/100ms | |
First matches 189.996k i/100ms | |
First three matches 218.544k i/100ms | |
First six matches 221.095k i/100ms | |
All matches 219.279k i/100ms | |
Calculating ------------------------------------- | |
No matches diff length | |
6.272M (± 3.6%) i/s - 31.486M in 5.027266s | |
No matches same length | |
5.889M (± 3.5%) i/s - 29.414M in 5.001569s | |
First matches 5.671M (± 7.5%) i/s - 28.309M in 5.027681s | |
First three matches 5.865M (± 4.4%) i/s - 29.285M in 5.003480s | |
First six matches 5.818M (± 3.9%) i/s - 29.185M in 5.024480s | |
All matches 5.632M (± 7.1%) i/s - 28.068M in 5.012928s | |
Comparison: | |
No matches diff length: 6271696.3 i/s | |
No matches same length: 5888530.3 i/s - same-ish: difference falls within error | |
First three matches: 5864885.5 i/s - same-ish: difference falls within error | |
First six matches: 5817559.3 i/s - same-ish: difference falls within error | |
First matches: 5671411.2 i/s - same-ish: difference falls within error | |
All matches: 5632047.0 i/s - 1.11x slower |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment