Sha256: bb0bbd1e69f302d346927386bd4004dd828a934e50944c59e964e312bd51f59e

Contents?: true

Size: 870 Bytes

Versions: 4

Compression:

Stored size: 870 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

4 entries across 4 versions & 1 rubygems

Version Path
usher-0.7.4 benchmarks/recognition_bm.rb
usher-0.7.3 benchmarks/recognition_bm.rb
usher-0.7.2 benchmarks/recognition_bm.rb
usher-0.7.1 benchmarks/recognition_bm.rb