aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test
diff options
context:
space:
mode:
authorSemyon Perepelitsa <sema@sema.in>2012-01-21 18:15:08 +0800
committerSemyon Perepelitsa <sema@sema.in>2012-01-21 18:32:17 +0800
commitbb1813cab859a404ffbb0bc8077407632b92a2f1 (patch)
treea2e75982e4129af1363d6cbed22fa2d1079a882f /actionpack/test
parent2e13850e4c8245214568b7e133908af7db9dbb9f (diff)
downloadrails-bb1813cab859a404ffbb0bc8077407632b92a2f1.tar.gz
rails-bb1813cab859a404ffbb0bc8077407632b92a2f1.tar.bz2
rails-bb1813cab859a404ffbb0bc8077407632b92a2f1.zip
Replace regexp matching with a simple string manipulation.
Using regexp looks like overkill here and is also 2x slower. user system total real string 0.020000 0.000000 0.020000 ( 0.016256) regexp 0.030000 0.000000 0.030000 ( 0.035360) require "benchmark" names = ("a".."z").map { |c| c + "a" * rand(5..10) + "=" * rand(0..1) }.map(&:to_sym) puts names n = 1000 Benchmark.bmbm do |x| x.report "string" do n.times do names.each do |name| string_name = name.to_s string_name.chomp!('=') string_name end end end x.report "regexp" do n.times do names.each do |name| name.to_s =~ /(.*)=$/ $1 end end end end
Diffstat (limited to 'actionpack/test')
0 files changed, 0 insertions, 0 deletions