Skip to content

Instantly share code, notes, and snippets.

@awilliams
Created February 5, 2014 18:46
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 awilliams/8830401 to your computer and use it in GitHub Desktop.
Save awilliams/8830401 to your computer and use it in GitHub Desktop.
Benchmark Restfulness::Sanitizer#sanitize_query_string
#
# Benchmark Restfulness::Sanitizer#sanitize_query_string
# Usage: ruby -I lib bm.rb 1000
#
require 'benchmark'
require 'restfulness'
iterations = ARGV.empty? ? 1000 : ARGV.shift.to_i
query_string = "alongparam=das3e23&something=dfasd&password=caca&another=false"
puts "Benchmarking '#{query_string}' #{iterations} times"
Benchmark.bmbm(10) { |x|
x.report("sanitize") { iterations.times { Restfulness::Sanitizer.sanitize_query_string(query_string) } }
x.report("nothing") { iterations.times { query_string } }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment