getr

A POSIX application wrapping getrusage(2) for simple benchmarks.

SYNOPSIS: getr <#runs> <command> [<args> ...]

OUTPUT:

$ getr 1000 ./fizzbuzz >/dev/null
User time      : 0 s, 894347 us
System time    : 0 s, 673832 us
Time           : 1568.179 ms (1.568 ms/per)
Max RSS        : 952 kB
Page reclaims  : 239344
Page faults    : 1
Block inputs   : 0
Block outputs  : 0
vol ctx switches   : 0
invol ctx switches : 1298

DESCRIPTION: getr is a simple wrapper around the getrusage(2) syscall, which can be relied on for basic resource usage reports under Linux, OpenBSD, and macOS (among others). A child command is repeatedly spawned and waited for, and then a RUSAGE_CHILDREN report is generated. This program was created as the author was used to very simple bash loops to test performance, which was then found didn't work at all under ksh on OpenBSD. getr is just as easy and just as simple.

More...

Detailed Description

EXIT STATUS

getr exits with status 1 if it fails to spawn a process, or if its own arguments aren't understood. It exits with status 0 in all other cases, including if the spawned program returns a nonzero exit status.

Examples

getr 1000 ./fizzbuzz > /dev/null

fizzbuzz is invoked 1000 times, with no arguments, and with getr's own (and therefore fizzbuzz's) standard output piped to /dev/null. The resulting usage report would still be printed to standard error.

getr 100 rdmd -c ''

rdmd in PATH is asked, 100 times, to evaluate the empty string.

See Also

getrusage(2), which(1), time(1), perf(1), valgrind(1).

Meta