xref: /linux/tools/perf/Documentation/perf-diff.txt (revision 1f2367a39f17bd553a75e179a747f9b257bc9478)
1perf-diff(1)
2============
3
4NAME
5----
6perf-diff - Read perf.data files and display the differential profile
7
8SYNOPSIS
9--------
10[verse]
11'perf diff' [baseline file] [data file1] [[data file2] ... ]
12
13DESCRIPTION
14-----------
15This command displays the performance difference amongst two or more perf.data
16files captured via perf record.
17
18If no parameters are passed it will assume perf.data.old and perf.data.
19
20The differential profile is displayed only for events matching both
21specified perf.data files.
22
23If no parameters are passed the samples will be sorted by dso and symbol.
24As the perf.data files could come from different binaries, the symbols addresses
25could vary. So perf diff is based on the comparison of the files and
26symbols name.
27
28OPTIONS
29-------
30-D::
31--dump-raw-trace::
32        Dump raw trace in ASCII.
33
34--kallsyms=<file>::
35        kallsyms pathname
36
37-m::
38--modules::
39        Load module symbols. WARNING: use only with -k and LIVE kernel
40
41-d::
42--dsos=::
43	Only consider symbols in these dsos. CSV that understands
44	file://filename entries.  This option will affect the percentage
45	of the Baseline/Delta column.  See --percentage for more info.
46
47-C::
48--comms=::
49	Only consider symbols in these comms. CSV that understands
50	file://filename entries.  This option will affect the percentage
51	of the Baseline/Delta column.  See --percentage for more info.
52
53-S::
54--symbols=::
55	Only consider these symbols. CSV that understands
56	file://filename entries.  This option will affect the percentage
57	of the Baseline/Delta column.  See --percentage for more info.
58
59-s::
60--sort=::
61	Sort by key(s): pid, comm, dso, symbol, cpu, parent, srcline.
62	Please see description of --sort in the perf-report man page.
63
64-t::
65--field-separator=::
66
67	Use a special separator character and don't pad with spaces, replacing
68	all occurrences of this separator in symbol names (and other output)
69	with a '.' character, that thus it's the only non valid separator.
70
71-v::
72--verbose::
73	Be verbose, for instance, show the raw counts in addition to the
74	diff.
75
76-q::
77--quiet::
78	Do not show any message.  (Suppress -v)
79
80-f::
81--force::
82        Don't do ownership validation.
83
84--symfs=<directory>::
85        Look for files with symbols relative to this directory.
86
87-b::
88--baseline-only::
89        Show only items with match in baseline.
90
91-c::
92--compute::
93        Differential computation selection - delta, ratio, wdiff, delta-abs
94        (default is delta-abs).  Default can be changed using diff.compute
95        config option.  See COMPARISON METHODS section for more info.
96
97-p::
98--period::
99        Show period values for both compared hist entries.
100
101-F::
102--formula::
103        Show formula for given computation.
104
105-o::
106--order::
107       Specify compute sorting column number.  0 means sorting by baseline
108       overhead and 1 (default) means sorting by computed value of column 1
109       (data from the first file other base baseline).  Values more than 1
110       can be used only if enough data files are provided.
111       The default value can be set using the diff.order config option.
112
113--percentage::
114	Determine how to display the overhead percentage of filtered entries.
115	Filters can be applied by --comms, --dsos and/or --symbols options.
116
117	"relative" means it's relative to filtered entries only so that the
118	sum of shown entries will be always 100%.  "absolute" means it retains
119	the original value before and after the filter is applied.
120
121--time::
122	Analyze samples within given time window. It supports time
123	percent with multiple time ranges. Time string is 'a%/n,b%/m,...'
124	or 'a%-b%,c%-%d,...'.
125
126	For example:
127
128	Select the second 10% time slice to diff:
129
130	  perf diff --time 10%/2
131
132	Select from 0% to 10% time slice to diff:
133
134	  perf diff --time 0%-10%
135
136	Select the first and the second 10% time slices to diff:
137
138	  perf diff --time 10%/1,10%/2
139
140	Select from 0% to 10% and 30% to 40% slices to diff:
141
142	  perf diff --time 0%-10%,30%-40%
143
144	It also supports analyzing samples within a given time window
145	<start>,<stop>. Times have the format seconds.microseconds. If 'start'
146	is not given (i.e., time string is ',x.y') then analysis starts at
147	the beginning of the file. If stop time is not given (i.e, time
148	string is 'x.y,') then analysis goes to the end of the file. Time string is
149	'a1.b1,c1.d1:a2.b2,c2.d2'. Use ':' to separate timestamps for different
150	perf.data files.
151
152	For example, we get the timestamp information from 'perf script'.
153
154	  perf script -i perf.data.old
155	    mgen 13940 [000]  3946.361400: ...
156
157	  perf script -i perf.data
158	    mgen 13940 [000]  3971.150589 ...
159
160	  perf diff --time 3946.361400,:3971.150589,
161
162	It analyzes the perf.data.old from the timestamp 3946.361400 to
163	the end of perf.data.old and analyzes the perf.data from the
164	timestamp 3971.150589 to the end of perf.data.
165
166--cpu:: Only diff samples for the list of CPUs provided. Multiple CPUs can
167	be provided as a comma-separated list with no space: 0,1. Ranges of
168	CPUs are specified with -: 0-2. Default is to report samples on all
169	CPUs.
170
171--pid=::
172	Only diff samples for given process ID (comma separated list).
173
174--tid=::
175	Only diff samples for given thread ID (comma separated list).
176
177COMPARISON
178----------
179The comparison is governed by the baseline file. The baseline perf.data
180file is iterated for samples. All other perf.data files specified on
181the command line are searched for the baseline sample pair. If the pair
182is found, specified computation is made and result is displayed.
183
184All samples from non-baseline perf.data files, that do not match any
185baseline entry, are displayed with empty space within baseline column
186and possible computation results (delta) in their related column.
187
188Example files samples:
189- file A with samples f1, f2, f3, f4,    f6
190- file B with samples     f2,     f4, f5
191- file C with samples f1, f2,         f5
192
193Example output:
194  x - computation takes place for pair
195  b - baseline sample percentage
196
197- perf diff A B C
198
199  baseline/A compute/B compute/C  samples
200  ---------------------------------------
201  b                    x          f1
202  b          x         x          f2
203  b                               f3
204  b          x                    f4
205  b                               f6
206             x         x          f5
207
208- perf diff B A C
209
210  baseline/B compute/A compute/C  samples
211  ---------------------------------------
212  b          x         x          f2
213  b          x                    f4
214  b                    x          f5
215             x         x          f1
216             x                    f3
217             x                    f6
218
219- perf diff C B A
220
221  baseline/C compute/B compute/A  samples
222  ---------------------------------------
223  b                    x          f1
224  b          x         x          f2
225  b          x                    f5
226                       x          f3
227             x         x          f4
228                       x          f6
229
230COMPARISON METHODS
231------------------
232delta
233~~~~~
234If specified the 'Delta' column is displayed with value 'd' computed as:
235
236  d = A->period_percent - B->period_percent
237
238with:
239  - A/B being matching hist entry from data/baseline file specified
240    (or perf.data/perf.data.old) respectively.
241
242  - period_percent being the % of the hist entry period value within
243    single data file
244
245  - with filtering by -C, -d and/or -S, period_percent might be changed
246    relative to how entries are filtered.  Use --percentage=absolute to
247    prevent such fluctuation.
248
249delta-abs
250~~~~~~~~~
251Same as 'delta` method, but sort the result with the absolute values.
252
253ratio
254~~~~~
255If specified the 'Ratio' column is displayed with value 'r' computed as:
256
257  r = A->period / B->period
258
259with:
260  - A/B being matching hist entry from data/baseline file specified
261    (or perf.data/perf.data.old) respectively.
262
263  - period being the hist entry period value
264
265wdiff:WEIGHT-B,WEIGHT-A
266~~~~~~~~~~~~~~~~~~~~~~~
267If specified the 'Weighted diff' column is displayed with value 'd' computed as:
268
269   d = B->period * WEIGHT-A - A->period * WEIGHT-B
270
271  - A/B being matching hist entry from data/baseline file specified
272    (or perf.data/perf.data.old) respectively.
273
274  - period being the hist entry period value
275
276  - WEIGHT-A/WEIGHT-B being user supplied weights in the the '-c' option
277    behind ':' separator like '-c wdiff:1,2'.
278    - WEIGHT-A being the weight of the data file
279    - WEIGHT-B being the weight of the baseline data file
280
281SEE ALSO
282--------
283linkperf:perf-record[1], linkperf:perf-report[1]
284