Created
September 8, 2016 07:58
-
-
Save mperlet/7a420c7c1fb0bdaf0b6eeef1c53ddaba to your computer and use it in GitHub Desktop.
Shellscript to run a cmd n-times and write time-output to txt file
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 | |
if [ -z "${TIMES}" ]; | |
then | |
echo "TIMES is unset, use export TIMES=10"; | |
TIMES=10 | |
else | |
echo "TIMES is set to $TIMES"; | |
fi | |
if [ -z "$@" ]; | |
then | |
echo "Run this script with a cmd!"; | |
exit 1 | |
fi | |
CURRENT_TIME=$(date +%s) | |
echo "Start Benchmark" | |
for i in $(seq 1 $TIMES); do | |
{ time "$@";} 2>> benchmark_"$CURRENT_TIME".txt; | |
done | |
echo "Benchmark File: benchmark_$CURRENT_TIME.txt" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment