Skip to content

Instantly share code, notes, and snippets.

@mperlet
Created September 8, 2016 07:58
Show Gist options
  • Save mperlet/7a420c7c1fb0bdaf0b6eeef1c53ddaba to your computer and use it in GitHub Desktop.
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
#!/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