OnWorks Linux and Windows Online WorkStations

Logo

Free Hosting Online for WorkStations

< Previous | Contents | Next >

4.3.2. How long does it take?‌


image

Bash offers a built-in time command that displays how long a command takes to execute. The timing is highly accurate and can be used on any command. In the example below, it takes about a minute and a half to make this book:


tilly:~/xml/src> time make

Output written on abook.pdf (222 pages, 1619861 bytes). Transcript written on abook.log.

tilly:~/xml/src> time make

Output written on abook.pdf (222 pages, 1619861 bytes). Transcript written on abook.log.


real user

sys

1m41.056s

1m31.190s

0m1.880s

real user

sys


The GNU time command in /usr/bin (as opposed to the shell built-in version) displays more information that can be formatted in different ways. It also shows the exit status of the command, and the total elapsed time. The same command as the above using the independent time gives this output:


tilly:~/xml/src> /usr/bin/time make

Output written on abook.pdf (222 pages, 1595027 bytes). Transcript written on abook.log.


Command exited with non-zero status 2 88.87user 1.74system 1:36.21elapsed 94%CPU

(0avgtext+0avgdata 0maxresident)k 0inputs+0outputs (2192major+30002minor)pagefaults 0swaps

tilly:~/xml/src> /usr/bin/time make

Output written on abook.pdf (222 pages, 1595027 bytes). Transcript written on abook.log.


Top OS Cloud Computing at OnWorks: