1.\" $NetBSD: tprof.8,v 1.3 2011/12/09 15:26:48 yamt Exp $ 2.\" 3.\" Copyright (c)2011 YAMAMOTO Takashi, 4.\" All rights reserved. 5.\" 6.\" Redistribution and use in source and binary forms, with or without 7.\" modification, are permitted provided that the following conditions 8.\" are met: 9.\" 1. Redistributions of source code must retain the above copyright 10.\" notice, this list of conditions and the following disclaimer. 11.\" 2. Redistributions in binary form must reproduce the above copyright 12.\" notice, this list of conditions and the following disclaimer in the 13.\" documentation and/or other materials provided with the distribution. 14.\" 15.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 16.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 19.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 21.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25.\" SUCH DAMAGE. 26.\" 27.\" ------------------------------------------------------------ 28.Dd November 26, 2011 29.Dt TPROF 8 30.Os 31.\" ------------------------------------------------------------ 32.Sh NAME 33.Nm tprof 34.Nd record tprof profiling samples 35.\" ------------------------------------------------------------ 36.Sh SYNOPSIS 37.Nm 38.Op Fl c 39.Op Fl o Ar file 40.Ar command ... 41.\" ------------------------------------------------------------ 42.Sh DESCRIPTION 43The 44.Nm 45is a sampling based profiler. 46.Pp 47.Nm 48utility makes the kernel driver start profiling, 49executes the specified command, 50keeps recording samples from the kernel driver until the command finishes, 51and reports statistics to the standard error. 52.Pp 53The 54.Nm tprof 55pseudo driver and a suitable backend should be loaded beforehand. 56.Pp 57The 58.Nm 59utility accepts the following options. 60.Bl -tag -width hogehoge 61.It Fl o Ar file 62Write the collected samples to the file named 63.Ar file . 64The default is 65.Dq Pa tprof.out . 66.It Fl c 67Write the collected samples to the standard output. 68Note that the output is a binary stream. 69.El 70.\" ------------------------------------------------------------ 71.Sh EXAMPLES 72The following command profiles the system during 1 second and shows 73the top-10 kernel functions which likely consumed CPU cycles. 74.Bd -literal 75 tprof -c sleep 1 2>/dev/null | tpfmt -skCLP | head -10 76.Ed 77.\" ------------------------------------------------------------ 78.Sh DIAGNOSTICS 79The 80.Nm 81utility reports the following statistics about the activities of the 82.Nm tprof 83pseudo driver. 84.Bl -tag -width dropbuf_samples 85.It sample 86The number of samples collected and prepared for userland consumption. 87.It overflow 88The number of samples dropped because the per-CPU buffer was full. 89.It buf 90The number of buffers successfully prepared for userland consumption. 91.It emptybuf 92The number of buffers which have been dropped because they were empty. 93.It dropbuf 94The number of buffers dropped because the number of buffers kept in the kernel 95exceeds the limit. 96.It dropbuf_samples 97The number of samples dropped because the buffers containing the samples 98were dropped. 99.El 100.\" ------------------------------------------------------------ 101.\".Sh HISTORY 102.\"The 103.\".Nm 104.\"utility first appeared in 105.\".Nx XXX . 106.\" ------------------------------------------------------------ 107.Sh SEE ALSO 108.Xr tpfmt 1 , 109.Xr tprof 4 110.\" ------------------------------------------------------------ 111.Sh AUTHORS 112The 113.Nm 114utility is written by 115.An YAMAMOTO Takashi . 116.\" ------------------------------------------------------------ 117.Sh CAVEATS 118The contents and representation of recorded samples are undocumented and 119will likely be changed for future releases of 120.Nx 121in an incompatible way. 122