(The linux equivalent of TimeThis.exe)
Something like:
timethis wget foo.com Receiving foo.com ... wget foo.com took 3 seconds.
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
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.
Method 2
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. You can also use command time or time to execute the utility instead of the build-in.
Method 3
@galois :
The various shells have a handful of “built-in” commands which take precedence over anything in the path. Normally this is advantageous; the built-ins will tend to run faster (because not calling an external file) and typically give the desired result (i.e., in the case of time command you normally do not care which version you are using, unless you want to use the “–format” flag).
So “time” without any special characters (like /) to make it look like a path will end up running the built-in, regardless of what your PATH looks like.
To force the shell to use the external time command, you must provide the path
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0