Sha256: fc1d21f4caf54a397c1179db3fcc344337a997d4e91584efdbb628998bde0950

Contents?: true

Size: 869 Bytes

Versions: 1

Compression:

Stored size: 869 Bytes

Contents

$:.unshift File.expand_path('../lib', __dir__)

require 'benchmark'
require 'mustermann/template'
require 'addressable/template'

[Mustermann::Template, Addressable::Template].each do |klass|
  puts "", " #{klass} ".center(64, '=')
  Benchmark.bmbm do |x|
    no_capture = klass.new("/simple")
    x.report("no captures, match") { 1_000.times { no_capture.match('/simple') } }
    x.report("no captures, miss") { 1_000.times { no_capture.match('/miss') } }

    simple = klass.new("/{match}")
    x.report("simple, match") { 1_000.times { simple.match('/simple').captures } }
    x.report("simple, miss") { 1_000.times { simple.match('/mi/ss') } }

    explode = klass.new("{/segments*}")
    x.report("explode, match") { 1_000.times { explode.match("/a/b/c").captures } }
    x.report("explode, miss") { 1_000.times { explode.match("/a/b/c.miss") } }
  end
  puts
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
mustermann-0.0.1 bench/template_vs_addressable.rb