-
Notifications
You must be signed in to change notification settings - Fork 0
/
getr.mdoc
86 lines (85 loc) · 2.44 KB
/
getr.mdoc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
.Dd September 27, 2019
.Dt GETR 1
.Os POSIX
.Sh NAME
.Nm getr
.Nd getrusage() wrapper for simple benchmarks
.Sh SYNOPSIS
.Pp
\fBgetr\fR
.Ar --help
.Pp
\fBgetr\fR
.Ar --version
.Pp
\fBgetr\fR
.Op Ar -b Ar ref
.Op Ar -i Ar input_file
.Ar count
.Ar program
.Op Ar args Ar ...
.Sh OUTPUT
.Bd -literal
$ getr 1000 ./fizzbuzz >/dev/null
User time : 0 s, 717132 us
System time : 0 s, 760456 us
Time : 1568 ms (1.568 ms/per)
Max RSS : 6.0 MB
Page reclaims : 481577
Page faults : 0
Block inputs : 0
Block outputs : 0
vol ctx switches : 1000
invol ctx switches : 40
$ ./getr -i /etc/redhat-release -b 1.568 3 perl -lne 'print scalar(reverse($_))'
)ytrihT( 03 esaeler arodeF
)ytrihT( 03 esaeler arodeF
)ytrihT( 03 esaeler arodeF
| 1.488x | 2.333 ms | 5.9 MB |
.Ed
.Sh DESCRIPTION
.Pp
\fBgetr\fR is a simple wrapper around the \fBgetrusage\fR(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
\fBRUSAGE_CHILDREN\fR report is generated. This program was
created as the author was used to very simple bash loops to test
performance, which he then found didn't work at all under ksh on
OpenBSD. \fBgetr\fR is just as easy and nearly as simple.
.Sh EXIT STATUS
.Pp
\fBgetr\fR exits with status 1 if it fails to parse its arguments.
In all other cases, including failure of spawned commands, it exits
with status 0.
.Sh EXAMPLES
.Pp
\fBgetr 1000 ./fizzbuzz > /dev/null\fR
.Pp
\fBfizzbuzz\fR is invoked 1000 times, with no arguments, and with
\fBgetr\fR's own (and therefore \fBfizzbuzz\fR's) standard output
piped to \fB/dev/null\fR. The resulting usage report would still
be printed to standard error.
.Pp
\fBgetr 100 python3 -c ''\fR
.Pp
The \fBpython3\fR in PATH is asked, 100 times, to evaluate
the empty string as a Python script.
.Pp
\fBgetr -i /dev/null -b 5.86 100 python3 -c ''\fR
.Pp
As above, but with input from /dev/null (getr will try to rewind it
before each spawn). Instead of the normal listing, the output is a
single row suitable for adding to an org-mode table, with columns
Speed, Runtime, and MaxRSS. Speed is calculated as Ref * Speed =
Runtime, where Ref is 5.86 in the above example. In the
\fBOUTPUT\fR section you can see that Perl, asked to reverse lines
of input, takes 1.5 times as long as fizzbuzz takes to produce its
output.
.Sh SEE ALSO
.Pp
.Xr getrusage 2 ,
.Xr which 1 ,
.Xr time 1 ,
.Xr perf 1 ,
.Xr valgrind 1 .