This is probably the stupidest question, but I can’t find anything about it online, and I’m partially on the verge of falling asleep.
Anyway, I’m assuming it’s got to do something with taking the total elapsed/wall time, and subtracting both the user and system time. IE, wall time is 10 seconds, system time is 2 and user is 1, meaning wait time is 7 seconds.
I’d love to get a sure-fire answer instead of using/guessing with this one that’s based on my gut.
The formula appears to be exactly as you surmised, with the caveat raised above.
Since
/usr/bin/timemeasures its user and system process time in CPU-seconds (according to the documentation), you’ll need to take the number of CPUs able to execute the code into account. For most simple, single-threaded applications, using one CPU as an estimate is reasonable.* In these cases, you can tolerably use CPU time as a substitute for wall clock time.For others, it depends on the maximum CPU saturation that program is expected to achieve, and that’s outside the scope of what
timecan tell you.* Certain processor-level idiosyncrasies with enhanced parallelism and speculative branch execution make this technically inaccurate, but it’s otherwise a reasonable estimate.