This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def generate(params, defaults = {}) | |
| unless (v_controller = (params[:controller] || defaults[:controller]).to_s) =~ /^(?-mix:[^\/.,;?]+)$/ | |
| raise ArgumentError, "Condition cannot be generated with #{params.inspect}" | |
| end | |
| "/#{params.delete(:controller) ; v_controller}#{if (params[:action] || params[:id]) && (v_action = (params[:action] || defaults[:action]).to_s) =~ /^(?-mix:[^\/.,;?]+)$/ ; "/#{params.delete(:action) ; v_action}#{if (params[:id]) && (v_id = (params[:id] || defaults[:id]).to_s) =~ /^(?-mix:[^\/.,;?]+)$/ ; "/#{params.delete(:id) ; v_id}" ; end}" ; end}" | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| | rack-router | merb routing | rails routing | | |
| --Route generation----------------------------------------------------------------------------------------------------------------------------------- | |
| A simple string x10000 | 0.056 | 0.133 | 0.403 | | |
| A simple string with query parameters x10000 | 0.228 | 0.344 | 0.551 | | |
| A couple variable segments x10000 | 0.140 | 0.435 | 0.570 | | |
| A lot of variable segments x10000 | 0.213 | 0.409 | 0.787 | | |
| Conditions that matches x10000 | 0.161 | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [carllerche@carl-lerches-macbook-pro rack-router (master)]$ jruby --fast benchmarks/large_method_nesting.rb | |
| java.lang.NullPointerException | |
| at org.objectweb.asm.MethodWriter.visitMaxs(Unknown Source) | |
| at org.jruby.compiler.impl.SkinnyMethodAdapter.visitMaxs(SkinnyMethodAdapter.java:878) | |
| at org.jruby.internal.runtime.methods.InvocationMethodFactory.endMethod(InvocationMethodFactory.java:1129) | |
| at org.jruby.internal.runtime.methods.InvocationMethodFactory.endCall(InvocationMethodFactory.java:1124) | |
| at org.jruby.internal.runtime.methods.InvocationMethodFactory.getCompiledMethod(InvocationMethodFactory.java:443) | |
| at org.jruby.internal.runtime.methods.CompiledMethod$LazyCompiledMethod.initializeMethod(CompiledMethod.java:64) | |
| at org.jruby.internal.runtime.methods.CompiledMethod$LazyCompiledMethod.getVisibility(CompiledMethod.java:160) | |
| at org.jruby.RubyModule.exportMethod(RubyModule.java:1296) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| --A 1521 route set with routes nested evenly 2 levels deep----------------------------------------------------------------------------- | |
| Matching the first route x1000 | 0.152 | 0.010 | 0.074 | 0.07x | | |
| Matching the middle route x1000 | 0.052 | 0.139 | 1.433 | 2.67x | | |
| Matching the last route x1000 | 0.155 | 0.347 | 4.018 | 2.24x | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| JRUBY | |
| ===== | |
| rack-router | merb routing | | |
| ---------------------------------------------------------------- | |
| Matching /hello 0.511 | 0.165 | | |
| Matching /hello.js 0.527 | 0.155 | | |
| Matching /hello/world 0.529 | 0.158 | | |
| Matching /hello/world.js 0.552 | 0.165 | | |
| Matching /hello/world/10 0.547 | 0.164 | | |
| Matching /hello/world/10.js 0.580 | 0.176 | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class SimpleRack | |
| include Rack::Router::Routable | |
| def initialize | |
| prepare do |r| | |
| r.map "/one", :to => lambda { |env| do_one(env) } | |
| r.map "/two", :to => lambda { |env| do_two(env) } | |
| end | |
| end | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| describe "a router with an informal protocol" do | |
| before(:each) do | |
| pending | |
| end | |
| it "just works" do | |
| authz = Rack::Router.new(:protocol => [:login]) do |r| | |
| r.map "/login", :to => LoginApp, :name => :login | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require File.join(File.expand_path(File.dirname(__FILE__)), "test_helper") | |
| class RouterBase < ActionController::Base | |
| def method_missing(action_name, *args) | |
| return super unless args.empty? | |
| retval = params.reject { |k, v| k == "controller" || k == "action" } | |
| retval = retval.sort { |k, v| k.to_s <=> v.to_s } | |
| retval = retval.map { |k, v| ":#{k} => #{v.inspect}" }.join(', ') | |
| retval = "{#{retval}}" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class RouterBase < ActionController::Base | |
| def method_missing(action_name, *args) | |
| return super unless args.empty? | |
| retval = params.reject { |k, v| k == "controller" || k == "action" } | |
| retval = retval.sort { |k, v| k.to_s <=> v.to_s } | |
| retval = retval.map { |k, v| ":#{k} => #{v.inspect}" }.join(', ') | |
| retval = "{#{retval}}" | |
| render :text => "#{self.class}##{action_name} - #{retval}" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class ::OAuthFilter | |
| include Rack::Router::Routable | |
| def initialize | |
| prepare do |r| | |
| r.map "/meta", :get, :to => OAuthApp, :name => :meta | |
| r.map "/request_tokens", :post, :to => OAuthApp, :name => :request_tokens | |
| r.map "/authorization", :get, :to => OAuthApp, :name => :authorization | |
| end | |
| end |