-
-
Save christianbundy/8f5530a2814065b6f665 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
#!/usr/bin/env bash | |
trap 'exit' ERR # exit on error (better than `set -e`) | |
set -x # echo commands before running | |
set -u # throw error if an unbound variable is called | |
BASEDIR=$(cd $(dirname $0) && pwd) # path to directory for itself | |
LOGDIR="$BASEDIR/times" # directory for logging | |
LOGFILE="$LOGDIR/times.txt" # file for logging (within $LOGDIR) | |
# create array from finding files in directory (except itself) | |
IFS=$'\n' | |
PROGRAMS=($(find $BASEDIR -maxdepth 1 -type f | grep -v "$(basename $0)")) | |
# create array from reading string | |
IFS=' ' | |
read -a ITERATIONS <<< "1 5 10 50 100 500 1000 5000 10000 50000 100000" | |
mkdir -p $LOGDIR # create directory, but don't fail if it already exists | |
touch $LOGFILE # create/truncate file | |
for p in "${PROGRAMS[@]}"; do | |
for i in "${ITERATIONS[@]}"; do | |
# append output of each program and iteration combination to $LOGFILE | |
$p $i >> $LOGFILE | |
done | |
done | |
echo "Finished! Times for each program can be found in $LOGFILE" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment