Sha256: 83002b35c5e59a59386d62cc4edf5cf6e8e70ad26f7f8914be06868b95991964

Contents?: true

Size: 869 Bytes

Versions: 5

Compression:

Stored size: 869 Bytes

Contents

require 'rubygems'
require 'rbench'
require 'lib/usher'

u = Usher.new(:generator => Usher::Util::Generators::URL.new)
u.add_route('/simple')
u.add_route('/simple/again')
u.add_route('/simple/again/and/again')
u.add_route('/dynamic/:variable')
u.add_route('/rails/:controller/:action/:id')
u.add_route('/greedy/{!greed,.*}')

TIMES = 50_000

RBench.run(TIMES) do

  report "2 levels, static" do
    u.recognize_path('/simple')
  end

  report "4 levels, static" do
    u.recognize_path('/simple/again')
  end

  report "8 levels, static" do
    u.recognize_path('/simple/again/and/again')
  end

  report "4 levels, 1 dynamic" do
    u.recognize_path('/dynamic/anything')
  end

  report "8 levels, 3 dynamic" do
    u.recognize_path('/rails/controller/action/id')
  end

  report "4 levels, 1 greedy" do
    u.recognize_path('/greedy/controller/action/id')
  end

end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
usher-0.8.3 benchmarks/recognition_bm.rb
usher-0.8.2 benchmarks/recognition_bm.rb
usher-0.8.1 benchmarks/recognition_bm.rb
usher-0.8.0 benchmarks/recognition_bm.rb
usher-0.7.5 benchmarks/recognition_bm.rb