vladvitan.com

Time command quick reference


← back to notes
> time ./app
./app 5.84s user 0.10s system 100% cpu 5.903 total

Command output meaning

Field (example output)MeaningInterpretation / GotchasBenchmarking Notes
user (5.84s)CPU time spent executing in user mode (your program’s code, not the kernel)Pure computation time — math, loops, data processing. Doesn’t include I/O or system callsHigh value means CPU-bound workload. Optimize algorithm or parallelize if possible
system (0.10s)CPU time spent in kernel mode handling system callsUsually low. High values indicate frequent I/O, syscalls, or context switchesIf this rises significantly, profile with strace or perf to find syscall hotspots
cpu (100%)Percentage of a single CPU utilized during the wall-clock run100% means fully using one core; >100% means multi-core usage(user + sys)/real × 100 gives CPU utilization. Over 100% → parallel processing
total / real (5.903s)Wall-clock (elapsed) time from start to finishIncludes waiting, scheduling, I/O, and all other delaysBest measure of how long it actually took. High real vs low user+sys → program was blocked or waiting

Useful notes for interpretation

Scenario / MetricMeaningInterpretation / GotchasBenchmarking Notes
user + system (≈5.94s)Total CPU time consumed across all coresCan exceed real time on multi-core systems(user+sys)/real ratio = CPU efficiency or parallelism. Here ≈ 1.006 → perfect single-core utilization
High real vs low user+sysProgram waited (I/O bound, sleep, blocked)E.g., 1.00s real, 0.01s user, 0.01s sys → waiting 98% of the timeInvestigate disk, network, or synchronization issues
High user vs low systemHeavy compute workload, minimal I/OE.g., 5.84s user, 0.10s sys → typical of compute-heavy jobsOptimize CPU code paths, use SIMD, JIT, or multi-threading
High system vs userKernel overhead dominatingE.g., 0.5s user, 3s sys → syscall-heavy or I/O-thrashingOptimize file access, reduce context switches, batch I/O
CPU ≈ 100% and user ≫ sysCPU fully utilized on one core, efficient useExample matches this caseGood benchmark baseline; shows program is CPU-bound and well-utilized
Multicore gotchauser+sys > real by large marginParallel workload summing per-core CPU timeUse htop or /usr/bin/time -v to confirm multi-core behavior
Benchmarking tipDon’t trust single runsCPU scaling, caching, and OS noise cause varianceRun several times, average results, and isolate the environment