systime

systime runs a program and tells you how much CPU time it took. It is like the classic Unix time tool, except while time tells you the CPU time that was charged to the process running the program, systime tells you all the CPU time used by the computer.

Examples


systime "mplayer -vo x11 bigfile.mpg"

Results:


wall:  1.09 s
cpu:   0.58 s  ( 53%)
  user:  0.52 s
  sys:   0.06 s

Overview

systime shell command

General

systime tells you how much CPU time all the processes in the system took while a certain program was running. This is in contrast to the more common measurement, which is how much CPU time was charged to the specific process that ran the program.

The systime version is useful when processes other than the one that actually runs the program contribute a lot of computing in service of that program. For example, there may be kernel processes that do such things as page memory, which would be difficult for them to charge to any one process. Or the program may submit a request to a daemon, which means the CPU time the daemon spends gets charged to the daemon instead of to the requesting program. A common case where this kind of accounting is needed is where a program displays stuff on an X server. The X server process uses a significant amount of CPU time, and it not not charged to the program that actually generated the images.

To measure just the time charged to the specific process that runs the program (basically, the time that process executes), use the Bash builtin command time.

systime's results are not very useful when the computer is doing multiple things at once, since systime reports CPU time by everything. It has no way to know whether some other process is serving the one you're trying to analyze.

systime works only on Linux. It gets its CPU time information from the Linux proc file stat.

systime reports the sum of all the CPU time used by all the CPUs. Ergo, with two CPUs, the total reported in a program that takes 1 second to run may be as high as 2 seconds.

Arguments

There is one argument: the shell command to run. Because this is one argument, if you run systime as a shell command itself, be sure to escape spaces properly, such as by including the whole argument in quotes.

systime invokes the shell /bin/sh (with a -c option) to run your command. The time used by that shell before and after actually running your program is included in the reported times.

The Output

Example:


wall:  1.09 s
cpu:   0.58 s  ( 53%)
  user:  0.52 s
  sys:   0.06 s

Assume the computer has one CPU.

In the example, the program took 1.09 seconds of wall clock time to run. In that time, the computer's CPU was busy a total of .58 seconds. .58 is 53% of 1.09. Of the .58 seconds, .52 seconds were executing user space program instructions and .06 seconds were executing kernel instructions.

If there are 2 CPUs fully utilized, the per centage on the "cpu" line is 200%.

Due to imprecision in the time measurements (by the kernel), the CPU time can slightly exceed the wall clock time, making the per centage higher than 100%. Also, the program uses more precision than it reports, so for example, the per centage reported might not be the same as you would get dividing the reported numbers yourself.