Re:/usr/bin/time: not the command you think you know
by dredmorbius on Tuesday March 07, 2017 @02:33PM
(#13813851)
I'm sorry, that's not clear to me. What's the significance exactly?
Re:/usr/bin/time: not the command you think you know
by knome on Tuesday March 07, 2017 @11:19PM
(#13817860)
A command takes a series of arguments, stdin/out/err pipes and returns an error code on completion.
time prefixes a pipeline ( the most basic case being a single command without a pipe into another ), a command block { ... } a subshell block ( ... ), a for statement, an if statement, just whatever really.
This "time" would output how long "a" took to run:
/usr/bin/time a b c | { d e ; f g ; } | h i ;
This "time" outputs how long the pipeline "a", "d", "f", and "h" took to run: time a b c | { d e ; f g ; } | h i ;
This is a syntax error: /usr/bin/time { d e ; f g ; }
This returns how long the command group takes to run: time { d e ; f g ; }
Further examples: $ time sleep 10 | sleep 1 ;
real 0m10.073s
user 0m0.000s
sys 0m0.000s
$ time sleep 1 | sleep 10 ;
real 0m10.003s
user 0m0.000s
sys 0m0.000s
$ /usr/bin/time sleep 10 | sleep 1 ;
0.00user 0.00system 0:10.00elapsed 0%CPU (0avgtext+0avgdata 1796maxresident)k
0inputs+0outputs (0major+80minor)pagefaults 0swaps
$
$ /usr/bin/time sleep 1 | sleep 10 ;
0.00user 0.00system 0:01.00elapsed 0%CPU (0avgtext+0avgdata 1808maxresident)k
0inputs+0outputs (0major+82minor)pagefaults 0swaps
Note the two /usr/bin/time's output their timing information as soon as the first command is done, but the pipeline doesn't return until both commands have exited.> hope this rant helps in some way
Re:/usr/bin/time: not the command you think you know
by dredmorbius on Wednesday March 08, 2017 @06:04PM
(#13824819)
Thanks, that does raise some interesting points.
What of:
/usr/bin/time ( sleep 1 | sleep 10 )
Explicitly invvoking a subshell. Which I understand the builtin to be doing.
https://www.gnu.org/software/bash/manual/html_node/Pipelines...