Created
February 2, 2019 00:46
-
-
Save lox/9a3efa21080461b6a1faa0db0b0dd2f0 to your computer and use it in GitHub Desktop.
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
#!/bin/bash | |
set -euo pipefail | |
measure() { | |
f=$1 | |
n=$2 | |
shift 2 | |
echo wall,user,sys,rss > "$f" | |
for i in $(seq $n); do | |
[[ -d $i ]] && rm -rf $i | |
mkdir $i | |
echo \$ "$@" | |
( cd $i; /usr/bin/time --output "../$f" --append --format '%e,%U,%S,%M' "$@" ) | |
rm -rf "./$i" | |
done | |
} | |
echo "Running 3 iterations" | |
measure "timing" 3 "$@" | |
echo "Average time over 3 iterations" | |
awk '{ total += $1; count++ } END { print total/count }' <(tail -n+2 timing) | |
rm timing |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment