- NetBSD Manual Pages
TPROF(8) NetBSD System Manager's Manual TPROF(8)
Powered by man-cgi (2021-06-01).
Maintained for NetBSD
by Kimmo Suominen.
Based on man-cgi by Panagiotis Christias.
tprof -- record tprof profiling samples
tprof op [arguments]
The tprof tool can be used to monitor hardware events (PMCs) during the
execution of certain commands.
The tprof utility makes the kernel driver start profiling, executes the
specified command, keeps recording samples from the kernel driver until
the command finishes, and reports statistics to the standard error.
The tprof pseudo driver and a suitable backend should be loaded before-
hand. See tprof(4) for the details.
The tprof utility accepts the following options. The first argument, op,
specifies the action to take. Valid actions are:
list Display a list of performance counter events available on
monitor -e name[:option][,scale] [-e ...] [-o outfile] command
Monitor the execution of command command. name specifies
the name of the event to count; it must be taken from the
list of available events. option specifies the source of
the event; it must be a combination of u (userland) and k
(kernel). If omitted, it is assumed that both are speci-
fied. The collected samples are written into the file
scale specifies the ratio of the speed to the cycle
counter, or the counter until overflow. The counter reset
value on overflow used for profiling is calculated from
the speed of the cycle counter by default, but for some
events this value may be too large (counter increasing too
slowly) to be sufficient for profiling. For example, to
specify an event that increases about 1000 times slower
than the cycle counter, specify ``-e event,1000''. Also,
if ``-e event,=200'' is specified, profiling is performed
every time the counter is increased by 200. outfile if
specified. The default is ``tprof.out''.
count -e name[:option] [-e ...] [-i interval] command
Same as monitor, but does not do any profiling, only out-
puts counters every interval second.
analyze [-CkLPs] [-p pid] file
Analyze the samples produced by a previous run of tprof,
stored in file, and generate a plain text representation
-C Don't distinguish CPUs. All samples are
treated as its CPU number is 0.
-k Kernel only. Ignore samples for userland
-L Don't distinguish LWPs. All samples are
treated as its LWP ID is 0.
-P Don't distinguish processes. All samples
are treated as its PID is 0.
-p pid Process only samples for the process with
PID pid and ignore the rest.
-s Per symbol.
top [-e name[,scale] [-e ...]] [-i interval] [-acu]
Displays profiling results in real-time. name specifies
the name of the event to count.
-i interval set the update interval in seconds. The
default value is 1.
-a Starts in accumulation mode. The dis-
play is updated every interval second,
but the values are accumulative.
-c show the delta of the event counters.
-u Userland processes are also included in
While tprof top is running, it accepts commands from the
terminal. These commands are currently recognized:
a toggle accumurative mode.
c shows/hides the event counters.
q quit tprof.
z clear accumulated data.
The following command profiles the system during 20 seconds and writes
the samples into the file myfile.out.
# tprof monitor -e llc-misses:k -o myfile.out sleep 20
The following command displays the results of the sampling.
# tprof analyze myfile.out
The following CPU models are supported:
- x86 AMD Family 10h
- x86 AMD Family 15h
- x86 AMD Family 17h
- x86 AMD Family 19h
- x86 Intel Generic (all Intel CPUs)
- x86 Intel Skylake/Kabylake
- x86 Intel Silvermont/Airmont
- x86 Intel Goldmont
- x86 Intel Goldmont Plus
The tprof utility reports the following statistics about the activities
of the tprof pseudo driver.
sample The number of samples collected and prepared for user-
overflow The number of samples dropped because the per-CPU buffer
buf The number of buffers successfully prepared for userland
emptybuf The number of buffers which have been dropped because
they were empty.
dropbuf The number of buffers dropped because the number of
buffers kept in the kernel exceeds the limit.
dropbuf_samples The number of samples dropped because the buffers con-
taining the samples were dropped.
The tprof utility was written by YAMAMOTO Takashi. It was revamped by
Maxime Villard in 2018, and by Ryo Shimizu in 2022.
The contents and representation of recorded samples are undocumented and
will likely be changed for future releases of NetBSD in an incompatible
NetBSD 10.99 December 16, 2022 NetBSD 10.99