Time command execution over multiple executions
Clone or download
ltratt Merge pull request #24 from wjt/fix-help-output
--help: remove -q from -b summary
Latest commit 2eaf077 Nov 10, 2018
Type Name Latest commit message Commit time
Failed to load latest commit information.
INSTALL Add simple install instructions. Sep 6, 2012
Makefile.in Fix manpath in makefile May 11, 2018
README Remove some Markdown formatting. This commit should result in a READM… Apr 6, 2015
configure.in Make sure that the code is compiled in C99 mode. Jun 5, 2015
multitime.c --help: remove -q from -b summary Nov 9, 2018


multitime: a better time utility

Unix's `time` utility is a simple and often effective way of measuring how long a command takes to run. Unfortunately, running a command once can give misleading timings: the process may create a cache on its first execution, running faster subsequently; other processes may cause the command to be starved of CPU or IO time; etc. It is common to see people run `time` several times and take whichever values they feel most comfortable with. Inevitably, this causes problems.

`multitime` is, in essence, a simple extension to time which runs a command multiple times and prints the timing means (with confidence intervals), standard deviations, minimums, medians, and maximums having done so. This can give a much better understanding of the command's performance.

Why should you use multitime?

If you want to do any of the following, then `multitime` is worth considering:

* You want to run a command several times to understand how its timings naturally vary.
* You want to run a command several times so that temporary blips in system activity do not distort the timings.
* You need different executions of a command being timed to have different inputs / outputs.
* You want to compare the timing of multiple commands (e.g. for benchmarking purposes).

`multitime` can also be used as a drop-in replacement for the POSiX time command: when invoked as time (e.g. via a symlink), `multitime` behaves as `time`. For most users, therefore, `multitime` can safely replace the time binary, even if you don't make use of its advanced features.

Example usage

The example below shows a simple benchmark of an `awk` program. In this case the program has been executed 5 times (`-n 5`) and the mean is reported at a 95% confidence level (`-c 99`).

    $ multitime -n 5 -c 99 awk "function fib(n) \
    >   { return n <= 1 ? 1 : fib(n - 1) + fib(n - 2) } BEGIN { fib(30) }"
    ===> multitime results
    1: awk "function fib(n)   { return n <= 1 ? 1 : fib(n - 1) + fib(n - 2) } BEGIN { fib(30) }"
                Mean                Std.Dev.    Min         Median      Max
    real        1.860+/-0.0013      0.021       1.837       1.856       1.895
    user        1.833+/-0.0005      0.013       1.812       1.836       1.846
    sys         0.002+/-0.0000      0.003       0.000       0.000       0.008


Formal released of `multitime` can be downloaded here: http://tratt.net/laurie/src/multitime/releases.html.

Formal releases can be built and installed with:

    $ ./configure
    $ make install

The latest source can be cloned with:

    $ git clone git://github.com/ltratt/multitime.git

and built with:

    make -f Makefile.bootstrap
    $ ./configure
    $ make install

Want to know more?

More details can be found at the http://tratt.net/laurie/src/multitime/