Skip to content

Instantly share code, notes, and snippets.

@jfirebaugh
Created May 2, 2011 21:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jfirebaugh/952373 to your computer and use it in GitHub Desktop.
Save jfirebaugh/952373 to your computer and use it in GitHub Desktop.
require 'benchmark'
require 'cgi'
require 'uri'
Benchmark.bmbm do |bm|
bm.report("CGI.escape") { 100000.times { CGI.escape 'asdf!@#$' } }
bm.report("URI.encode_www_form_component") { 100000.times { URI.encode_www_form_component 'asdf!@#$' } }
end
Rehearsal -----------------------------------------------------------------
CGI.escape 0.850000 0.000000 0.850000 ( 0.857414)
URI.encode_www_form_component 0.660000 0.000000 0.660000 ( 0.655699)
-------------------------------------------------------- total: 1.510000sec
user system total real
CGI.escape 0.830000 0.010000 0.840000 ( 0.828300)
URI.encode_www_form_component 0.660000 0.000000 0.660000 ( 0.657125)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment