Created
February 5, 2014 18:46
-
-
Save awilliams/8830401 to your computer and use it in GitHub Desktop.
Benchmark Restfulness::Sanitizer#sanitize_query_string
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# 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