Created
August 2, 2018 18:09
-
-
Save enebo/28ca1b088e40a056db877896479cd40e 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
### USING matchSearch() | |
system ~/work/jruby master 1255% jruby ../snippets/regexp_bench.rb | |
Ignoring bcrypt-ruby-3.0.0-java because its extensions are not built. Try: gem pristine bcrypt-ruby --version 3.0.0 | |
Warming up -------------------------------------- | |
match? 114.704k i/100ms | |
little 132.135k i/100ms | |
middle 135.335k i/100ms | |
larger 119.215k i/100ms | |
Calculating ------------------------------------- | |
match? 2.992M (± 4.9%) i/s - 14.912M in 4.997298s | |
little 3.536M (± 4.4%) i/s - 17.706M in 5.018470s | |
middle 3.507M (± 4.5%) i/s - 17.594M in 5.027414s | |
larger 2.643M (± 3.5%) i/s - 13.233M in 5.013502s | |
### USING matchMatch() | |
system ~/work/jruby master * 1256% jruby ../snippets/regexp_bench.rb | |
Ignoring bcrypt-ruby-3.0.0-java because its extensions are not built. Try: gem pristine bcrypt-ruby --version 3.0.0 | |
Warming up -------------------------------------- | |
match? 122.451k i/100ms | |
little 182.914k i/100ms | |
middle 187.966k i/100ms | |
larger 188.653k i/100ms | |
Calculating ------------------------------------- | |
match? 2.995M (± 5.6%) i/s - 14.939M in 5.007503s | |
little 6.643M (± 5.5%) i/s - 33.107M in 5.002228s | |
middle 6.831M (± 6.3%) i/s - 34.022M in 5.006739s | |
larger 6.764M (± 7.4%) i/s - 33.580M in 5.001296s |
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' | |
pattern = /^([0-1]?[0-9]|2[0-3])([:\-,\.])?([0-5][0-9])$/ | |
string = '9:30' | |
Benchmark.ips do |x| | |
x.report('match?') { string.match?(pattern) } | |
x.report('little') { "afoobfoobar".match? /foo..r/ } | |
x.report('middle') { "aaaaaaaaafoobbbbbbfoobar".match? /foo..r/ } | |
x.report('larger') { "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaafoobbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbfoobar".match? /foo..r/ } | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment