Tag Info

Hot answers tagged

5

The structure of a pipeline doesn't allow time in the middle, only at the start of the pipeline. Also, time is a "shell keyword", as shown by type time. But nothing forbids the use of compound commands (and time each): time comm1 | ( time comm2 ) So, you could workaround using a sub-shell, like this: echo "12" | ( time python3 -c "a=input("");print(a)" ...


3

There is two types of time commands. One is shell built-in, belongs to bash. That's the one you see in your first example. Second one , is /usr/bin/time, that's the second one you saw. As for why it's different output, it's because you cannot pipe output to shell builtins. More on that here


3

Using last you can find this information. The following may be useful: last <username> | less It will return something like this: benlavery@Talantinc:bin $>last benlavery | less benlavery ttys005 Mon Aug 31 09:58 still logged in benlavery ttys005 fe80::105e:6b27:29ff:d967%en0 Mon Aug 31 09:14 - 09:36 (00:22) benlavery ...


1

If you like to time commands for performance reasons, I recommend not to use /usr/bin/time but either ptime(1) if this available on your platform - ptime gives a nanosecond resolution - or to use a recent Bourne Shell, as the Bourne Shell allows to automatically time all foreground commands (including shell builtins) with a microsecond resolution on all ...



Only top voted, non community-wiki answers of a minimum length are eligible