public
Rubygem
Description: Merb Core: All you need. None you don't.
Homepage: http://www.merbivore.com
Clone URL: git://github.com/wycats/merb-core.git
Search Repo:
Michael S. Klishin (author)
Tue May 13 11:34:51 -0700 2008
commit  137889807100ed854a43e663ae2ea33fb2eea6ce
tree    06ca2a8bf6da47309d6928edf2ff5a14ab9cce65
parent  ff19a1ab25844042f02db0f769c9481810cc1357
merb-core / simple_benches / split_gsub.rb
100644 13 lines (10 sloc) 0.435 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
require 'benchmark'
 
TIMES = (ARGV[0] || 100_000).to_i
 
Benchmark.bmbm do |x|
  x.report("split") { TIMES.times { "aaa/aaa/aaa.bbb.ccc.ddd".split(".").last }}
  x.report("match") { TIMES.times { "aaa/aaa/aaa.bbb.ccc.ddd".match(/\.([^\.]*)$/)[1] }}
end
 
# TIMES == 1_000_000
# user system total real
# split 4.150000 0.010000 4.160000 ( 4.155064)
# match 3.670000 0.000000 3.670000 ( 3.683401)