42 ms·
That is merely an optimization though. You can simply time sh -c 'foo | bar'
by jstimpfle 10y ago
That is merely an optimization though. You can simply
time sh -c 'foo | bar'
- therein 10y agoBut now you are timing the startup of `sh` as well.
- aexaey 10y ago...which (surprisingly) is a measurable amount. About 1 ms for `dash` and a whooping 9.5 ms for `bash` on a relatively slow CPU: pi@pi:~ $ time (for x in {1..1000}; do time echo | sleep 0.01; done 2>/dev/null) real 0m24.173s pi@pi:~ $ time (for x in {1..1000}; do time sh -c 'echo | sleep 0.01'; done 2>/dev/null) real 0m25.170s pi@pi:~ $ time (for x in {1..1000}; do time bash -c 'echo | sleep 0.01'; done 2>/dev/null) real 0m33.643s
- jstimpfle 10y ago1ms is on the order of process creation time, so not very relevant: The measured program itself requires process creation. Most programs run considerably longer than that (otherwise timing would not make much sense). It's really not more than that: an optimization.