I'm writing this script where I have to run a program, time it and write that time into a text file, it must be in seconds with 6 decimal places. So far I have this:
#!/bin/bash
MAX_THREADS=8 #2 x number of cores
if [ $# -ne 2 ]; then #checks number of arguments
echo Invalid number of arguments
exit 1
else
NUM_THREADS=$1
fi
if [ $NUM_THREADS -gt $MAX_THREADS ]; then
echo Invalid number of threads
exit 1
fi
make clean
make
start=$(date +%s)
./CircuitRouter-SeqSolver $2
end=$(date +%s)
cat > $2.speedup.csv << EOF
$((end-start))
EOF
You can ignore anything related to NUM_THREADS that's for another part of the script. So I make clean, make and then run CircuitRouter-SeqSolver with $2 as an argument, I saw this solution with date but it only writes the number of seconds without decimal numbers so it just writes 0 into the file since the program takes less than 1 second to finish. How can I modify date to write decimal numbers?