Created
November 23, 2016 23:01
-
-
Save thegedge/a468091c002d5f65ea018c2ab28b0da9 to your computer and use it in GitHub Desktop.
Run a series of curl requests and profile the mean / std. dev. of those requests
This file contains hidden or 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
#!/bin/bash | |
profile-curl() { | |
local num_iters=500 | |
local num_warmups=10 | |
local -a times | |
for x in $(seq 1 "${num_warmups}"); do | |
curl -s -o /dev/null "$@" 2>&1 | |
done | |
for x in $(seq 1 "${num_iters}"); do | |
times+=($(curl -s -w '%{time_total}\n' -o /dev/null "$@")) | |
done | |
ruby -- - "${times[@]}" <<-EOS | |
values = ARGV.map(&:to_f) | |
μ = values.reduce(:+) / values.length | |
σ = (values.map{ |x| (x - μ)**2 }.reduce(:+) / values.length) ** 0.5 | |
puts "μ = %.4f, σ = %.4f" % [μ, σ] | |
EOS | |
} | |
profile-curl "$@" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment