Skip to content

Commit

Permalink
Use escape_utils if available.
Browse files Browse the repository at this point in the history
This improves Rack's performance when escaping/unescaping URLs.
For a simple sinatra app (one route returning a string), I get those numbers
without escape_utils:

request   concurrency   req/s    failures
==========================================
1000      1             952      0
1000      11            1106     0
1000      21            1156     0
1000      31            953      0
1000      41            1030     0
1000      51            1140     0
1000      61            1156     0
1000      71            1123     0
1000      81            1119     0
1000      91            1097     0

And these with escape_utils:

request   concurrency   req/s    failures
==========================================
1000      1             964      0
1000      11            1178     0
1000      21            1229     0
1000      31            1206     0
1000      41            1236     0
1000      51            1230     0
1000      61            1222     0
1000      71            1206     0
1000      81            1224     0
1000      91            1190     0

For benchmarking I used Thin's abc (which in turn uses ab).
  • Loading branch information
rkh committed Dec 3, 2010
1 parent 61632c4 commit bfce7aa
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions lib/sinatra/base.rb
Expand Up @@ -6,6 +6,16 @@
require 'sinatra/showexceptions'
require 'tilt'

begin
require 'escape_utils'
require 'escape_utils/url/rack'
require 'escape_utils/html/rack'
rescue LoadError
unless defined? RUBY_ENGINE and RUBY_ENGINE != 'ruby'
$stderr.puts 'consider installing escape_utils for better performance'
end
end

module Sinatra
VERSION = '1.1.1'

Expand Down

0 comments on commit bfce7aa

Please sign in to comment.