Sha256: cb7a9bbf8a68732f725395a0af5c629e0e9bd6c1e55708ca4fb5fe9591dea40c

Contents?: true

Size: 924 Bytes

Versions: 8

Compression:

Stored size: 924 Bytes

Contents

# Calculating -------------------------------------
#    Jellyfish::URLMap     5.726k i/100ms
#         Rack::URLMap   167.000  i/100ms
# -------------------------------------------------
#    Jellyfish::URLMap     62.397k (± 1.2%) i/s -    314.930k
#         Rack::URLMap      1.702k (± 1.5%) i/s -      8.517k

# Comparison:
#    Jellyfish::URLMap:    62397.3 i/s
#         Rack::URLMap:     1702.0 i/s - 36.66x slower

require 'jellyfish'
require 'rack'

require 'benchmark/ips'

num = 1000
app = lambda do |_|
  ok = [200, {}, []]
  rn = lambda{ |_| ok }

  (0...num).each do |i|
    map "/#{i}" do
      run rn
    end
  end
end

jelly = Jellyfish::Builder.app(&app)
rack  = Rack::Builder.app(&app)
path_info = 'PATH_INFO'

Benchmark.ips do |x|
  x.report(jelly.class) do
    jelly.call(path_info => rand(num).to_s)
  end

  x.report(rack.class) do
    rack.call(path_info => rand(num).to_s)
  end

  x.compare!
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
jellyfish-1.4.0 bench/bench_builder.rb
jellyfish-1.3.1 bench/bench_builder.rb
jellyfish-1.3.0 bench/bench_builder.rb
jellyfish-1.2.2 bench/bench_builder.rb
jellyfish-1.2.1 bench/bench_builder.rb
jellyfish-1.2.0 bench/bench_builder.rb
jellyfish-1.1.1 bench/bench_builder.rb
jellyfish-1.1.0 bench/bench_builder.rb