This question is about GNU time utility on Ubuntu and CentOS, not bash time command.
I am looking at measuring resources used by CI job commands (most importantly max memory usage) using time --verbose <command to measure>
.
I need to understand how invasive the time
command is ... does it periodically interrupt child process execution and sample its stats or does the operating system (specifically Ubuntu and CentOS) already collect resource usage statistics and the time
command just reads that upon child process completion.
How does GNU 'time' measure process resource usage?
Kernel measures process resource usage. The struct rusage
is returned by wait4()
.
does it periodically interrupt child process execution and sample its stats or does the operating system
No.
does the operating system (specifically Ubuntu and CentOS) already collect resource usage statistics and the time command just reads that upon child process completion.
Yes.