Skip to content

Instantly share code, notes, and snippets.

@sikachu
Created September 13, 2012 00:05
Show Gist options
  • Save sikachu/3710896 to your computer and use it in GitHub Desktop.
Save sikachu/3710896 to your computer and use it in GitHub Desktop.
Benchmark.bmbm do |x|
x.report('start_with?') { 10_000.times { "fooo".start_with?('foo') }}
x.report('regexp') { 10_000.times { "fooo" =~ /^foo/ }}
end
Rehearsal -----------------------------------------------
start_with? 0.000000 0.000000 0.000000 ( 0.003011)
regexp 0.010000 0.000000 0.010000 ( 0.004245)
-------------------------------------- total: 0.010000sec
user system total real
start_with? 0.000000 0.000000 0.000000 ( 0.002067)
regexp 0.000000 0.000000 0.000000 ( 0.002858)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment