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...

Members

Functions

getrusage
int getrusage(int who, RUsage* usage)
Undocumented in source but is binding to C. You might be able to learn more by searching the web for its name.
main
void main(string[] args)
Undocumented in source. Be warned that the author may not have intended to support it.
readable_rss
string readable_rss(real kb)
Undocumented in source. Be warned that the author may not have intended to support it.
report
void report(int times)
Undocumented in source. Be warned that the author may not have intended to support it.

Manifest constants

RUSAGE_CHILDREN
enum RUSAGE_CHILDREN;
Undocumented in source.

Structs

RUsage
struct RUsage
Undocumented in source.
Timeval
struct Timeval
Undocumented in source.

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