Is there a command that's useful for doing a benchmark test on a separate command or function; to see how cpu intensive it is?
Preferably something similar to how you can report the duration of a command with time
.
For instance: I tried the following code; before adding sleep 0.1
; and it stressed the CPU, fans kicked into high gear, etc. Adding sleep 0.1
after each printf
seemed to mitigate the problem. And basically, I'm just curious to check out the difference:
spin ()
{
i=0
sp='/-\|'
n=${#sp}
printf ' '
sleep 0.1
while true; do
printf '\b%s' "${sp:i++%n:1}"
sleep 0.1
done
}
perf
and friends) – quixotic Mar 31 '17 at 06:31/usr/bin/time -v ./yourscript.sh
to get many informations about resource usage. – ctx Mar 31 '17 at 11:31