time-and-save.sh 778 B

1234567891011121314151617181920212223242526272829
  1. #!/bin/bash
  2. # Save path the current path that will be used to store the results.
  3. BASE_PATH=$(pwd)
  4. # Local variable to store if cpu or gpu directed benchmark
  5. TYPE=$3
  6. # Check if we need to create the directories to store the results
  7. if [ ! -d "results" ]; then
  8. mkdir results
  9. fi
  10. if [ ! -d "results/$TYPE" ]; then
  11. mkdir results/$TYPE
  12. fi
  13. # Enter in the directory passed as first parameter, then execute run and save the results in the file passed as second parameter
  14. cd $1
  15. BENCH_NAME=$1
  16. # Start the actual benchmark
  17. BENCH_TIME=`(/usr/bin/time -f "%e" ./run-$TYPE) 2>&1 > /dev/zero | tail -1`
  18. # Save execution time in the log
  19. echo "$BENCH_NAME $BENCH_TIME" >> $BASE_PATH/results/$TYPE/$2
  20. # Sleep in order to give time to the power measurement script to reset.
  21. sleep 5