Sha256: a7977ea71d6a3b1d2d1dc65626d60a09960c56ebdf3eb5ca5b414e5a1111e08c

Contents?: true

Size: 1.16 KB

Versions: 7

Compression:

Stored size: 1.16 KB

Contents

# encoding: utf-8
$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/..')
$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/../lib')

require 'rubygems'
require 'benchmark'

require 'rack'
require 'erb'
require 'cgi'
require 'url_escape'
require 'fast_xs_extra'
require 'escape_utils'

times = 10_000
url = "https://www.yourmom.com/cgi-bin/session.cgi?sess_args=mYHcEA  dh435dqUs0moGHeeAJTSLLbdbcbd9ef----,574b95600e9ab7d27eb0bf524ac68c27----"
puts "Escaping a #{url.bytesize} byte URL #{times} times"

Benchmark.bmbm do |x|
  x.report do
    puts "ERB::Util.url_encode"
    times.times do
      ERB::Util.url_encode(url)
    end
  end

  x.report do
    puts "Rack::Utils.escape"
    times.times do
      Rack::Utils.escape(url)
    end
  end

  x.report do
    puts "CGI.escape"
    times.times do
      CGI.escape(url)
    end
  end

  x.report do
    puts "URLEscape#escape"
    times.times do
      URLEscape.escape(url)
    end
  end

  x.report do
    puts "fast_xs_extra#fast_xs_url"
    times.times do
      url.fast_xs_url
    end
  end

  x.report do
    puts "EscapeUtils.escape_url"
    times.times do
      EscapeUtils.escape_url(url)
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
escape_utils-0.2.1 benchmark/url_escape.rb
escape_utils-0.2.0 benchmark/url_escape.rb
escape_utils-0.1.9 benchmark/url_escape.rb
escape_utils-0.1.8 benchmark/url_escape.rb
escape_utils-0.1.7 benchmark/url_escape.rb
escape_utils-0.1.6 benchmark/url_escape.rb
escape_utils-0.1.5 benchmark/url_escape.rb