How do I time a specific command?

Try just time instead of timethis.

Although be aware that there's often a shell builtin version of time and a binary version, which will give results in different formats:

$ time wget -q -O /dev/null https://unix.stackexchange.com/

real    0m0.178s
user    0m0.003s
sys     0m0.005s

vs

$ \time wget -q -O /dev/null https://unix.stackexchange.com/
0.00user 0.00system 0:00.17elapsed 4%CPU (0avgtext+0avgdata 0maxresident)k
0inputs+0outputs (0major+613minor)pagefaults 0swaps

Unlike your "timethis" program, you get three values back. That's broken down in What is "system time" when using "time" in command line, but in short: real means "wall-clock time", while user and sys show CPU clock time, split between regular code and system calls.


By using the executable time instead of the shell builtin, you can specify the output format and values. E.g. get the real elapsed time together with the command name and parameters

/usr/bin/time --format='%C took %e seconds' sleep 3
sleep 3 took 3.00 seconds

Note that you must specify the path for time, else you will default to using the shell built-in.