Created
September 18, 2015 22:48
-
-
Save jbn/c447a98ff5718f9d6730 to your computer and use it in GitHub Desktop.
My justification for rewriting OAuth.jl's oauth_serialize_url_parameters
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
function method_a(options) | |
parameterstring = "" | |
keyssorted = sort!(collect(keys(options))) | |
for key in keyssorted | |
parameterstring *= "$key=$(options["$key"])&" | |
end | |
chop(parameterstring) | |
end | |
function method_b(options) | |
join( | |
["$key=$(options[key])" for key in sort!(collect(keys(options)))], | |
"&" | |
) | |
end | |
params = Dict([randstring(10) => randstring(40) for _ in 1:10]) | |
# Warm up... | |
method_a(params) | |
method_b(params) | |
@assert method_a(params) == method_b(params) | |
sleep(1) # To semi-ensure JIT is done. | |
@time method_a(params) | |
@time method_b(params); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment