Sha256: 2bb793d8c051a92b6d3786cd8f22712259729a9e90e3417698f391b961a1308d

Contents?: true

Size: 1.18 KB

Versions: 27

Compression:

Stored size: 1.18 KB

Contents

$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
require 'rack/app'
require 'securerandom'

static_router =  Rack::App::Router::Static.new
dynamic_router = Rack::App::Router::Dynamic.new

classic_router = []

endpoint_paths = []
10000.times do
  endpoint_paths << ('/' + 7.times.map { SecureRandom.uuid }.join('/'))

  static_router.add_endpoint('GET', endpoint_paths.last, -> {})
  static_router.add_endpoint('GET', endpoint_paths.last, -> {})
  classic_router << ['GET',endpoint_paths.last,->{}]

end

start_time = Time.now
endpoint_paths.each do |request_path|
  static_router.fetch_endpoint('GET',request_path)
end
finish_time_of_static = Time.now - start_time

start_time = Time.now
endpoint_paths.each do |request_path|
  dynamic_router.fetch_endpoint('GET',request_path)
end
finish_time_of_dynamic = Time.now - start_time

start_time = Time.now
endpoint_paths.each do |request_path|
  classic_router.find{|ary| ary[0] == 'GET' and ary[1] == request_path }
end
finish_time_of_classic = Time.now - start_time

puts "time taken by static: #{finish_time_of_static}",
     "time taken by dynamic: #{finish_time_of_dynamic}",
     "time taken by classic(mock): #{finish_time_of_classic}"

Version data entries

27 entries across 27 versions & 1 rubygems

Version Path
rack-app-1.0.0 spike/routing_time.rb
rack-app-0.24.0 spike/routing_time.rb
rack-app-0.23.0 spike/routing_time.rb
rack-app-0.22.0 spike/routing_time.rb
rack-app-0.21.0 spike/routing_time.rb
rack-app-0.20.0 spike/routing_time.rb
rack-app-0.19.0 spike/routing_time.rb
rack-app-0.18.0 spike/routing_time.rb
rack-app-0.17.0 spike/routing_time.rb
rack-app-0.16.0 spike/routing_time.rb
rack-app-0.15.0 spike/routing_time.rb
rack-app-0.14.0 spike/routing_time.rb
rack-app-0.13.0 spike/routing_time.rb
rack-app-0.12.1 spike/routing_time.rb
rack-app-0.12.0 spike/routing_time.rb
rack-app-0.11.0 spike/routing_time.rb
rack-app-0.10.1 spike/routing_time.rb
rack-app-0.9.2 spike/routing_time.rb
rack-app-0.9.1 spike/routing_time.rb
rack-app-0.9.0 spike/routing_time.rb