Skip to content

Instantly share code, notes, and snippets.

@neale
Last active August 29, 2015 14:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save neale/745f2756fb181ab53852 to your computer and use it in GitHub Desktop.
Save neale/745f2756fb181ab53852 to your computer and use it in GitHub Desktop.
Times programs in your directory and logs times to a file
#!/usr/bin/env bash
trap 'exit' ERR
set -u
DIR="$(pwd)"
LOG="$DIR/times/times.txt"
PROGRAMS=($(find $DIR -maxdepth 1 -type f | grep -v "$(basename $0)"))
mkdir -p $DIR/times
touch $LOG
echo "timing for each random array"
for i in "${PROGRAMS[@]}"; do
if [[ -x "$i" ]]; then
echo "generating program time for $i"
{ time $i > /dev/null 2>&1 ; } 2>> $LOG
else
echo "$i is not timed, and exec permissions to time"
fi
done
echo "finshed, times for each program can be found in $LOG"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment