Skip to content

Instantly share code, notes, and snippets.

View joshbuddy's full-sized avatar
🤡
meow

Joshua Hull joshbuddy

🤡
meow
View GitHub Profile
<html>
<body>
Testing
</body>
</html>
<html>
<body>hi!</body>
</html>
require 'benchmark'
require 'strscan'
s = "this " * 20
puts "with .scan.each"
puts Benchmark.measure {
100000.times do
s.scan(/\w+[ $]/)
end
old-stumpy:Documents josh$ ruby test.rb
with create_additions
4.270000 0.030000 4.300000 ( 4.348951)
4.270000 0.020000 4.290000 ( 4.353974)
4.270000 0.030000 4.300000 ( 4.337681)
4.280000 0.020000 4.300000 ( 4.316854)
4.270000 0.020000 4.290000 ( 4.325486)
without create_additions
4.210000 0.030000 4.240000 ( 4.284506)
4.210000 0.030000 4.240000 ( 4.266183)
require "active_support/core_ext"
require "action_controller/new_base/http"
require "rack/router"
module Rails
class Sinatra < ActionController::Http
include AbstractController::Renderer
include AbstractController::Callbacks
include AbstractController::Helpers
class OrOrEquals
def test
@test
end
def test=(test)
@test = test
'not test'
end
rack-router | merb routing | rails routing | usher routing |
--Route generation---------------------------------------------------------------------------------------------------------------------------------------------------
A simple string x10000 | 0.149 | 0.145 | 0.450 | 0.098 |
A simple string with query parameters x10000 | 0.308 | 0.338 | 0.645 | 0.221 |
A couple variable segments x10000 | 0.210 | 0.481 | 0.639 | 0.156 |
A lot of variable segments x10000 | 0.289 | 0.395 | 0.853 | 0.351 |
Conditions that matches x10000 | 0.219 | 0.335 |
router:
#initialize(parent_router || nil)
#map('path', options = nil)
returned object supports attr_accessor :to
returned object supports attr_accessor :name
#context
returns object with attr_reader :host, :port, :scheme, :base_uri
#recognize(request_object, path)
irb(main):007:0> puts app.call(Rack::MockRequest.env_for("/hello"))
200
Hello
=> nil
irb(main):008:0>
irb(main):009:0*
irb(main):010:0*
irb(main):011:0* quit
replacement:usher joshua$ irb
| rack-router bootup time | usher bootup time |
-----------------------------------------------------------------------
Awesome x10 | 42.350 | 2.692 |