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, cycles,
94        delta-abs (default is delta-abs).  Default can be changed using
95        diff.compute config option.  See COMPARISON METHODS section for
96        more info.
97
98-p::
99--period::
100        Show period values for both compared hist entries.
101
102-F::
103--formula::
104        Show formula for given computation.
105
106-o::
107--order::
108       Specify compute sorting column number.  0 means sorting by baseline
109       overhead and 1 (default) means sorting by computed value of column 1
110       (data from the first file other base baseline).  Values more than 1
111       can be used only if enough data files are provided.
112       The default value can be set using the diff.order config option.
113
114--percentage::
115	Determine how to display the overhead percentage of filtered entries.
116	Filters can be applied by --comms, --dsos and/or --symbols options.
117
118	"relative" means it's relative to filtered entries only so that the
119	sum of shown entries will be always 100%.  "absolute" means it retains
120	the original value before and after the filter is applied.
121
122--time::
123	Analyze samples within given time window. It supports time
124	percent with multiple time ranges. Time string is 'a%/n,b%/m,...'
125	or 'a%-b%,c%-%d,...'.
126
127	For example:
128
129	Select the second 10% time slice to diff:
130
131	  perf diff --time 10%/2
132
133	Select from 0% to 10% time slice to diff:
134
135	  perf diff --time 0%-10%
136
137	Select the first and the second 10% time slices to diff:
138
139	  perf diff --time 10%/1,10%/2
140
141	Select from 0% to 10% and 30% to 40% slices to diff:
142
143	  perf diff --time 0%-10%,30%-40%
144
145	It also supports analyzing samples within a given time window
146	<start>,<stop>. Times have the format seconds.nanoseconds. If 'start'
147	is not given (i.e. time string is ',x.y') then analysis starts at
148	the beginning of the file. If stop time is not given (i.e. time
149	string is 'x.y,') then analysis goes to the end of the file.
150	Multiple ranges can be separated by spaces, which requires the argument
151	to be quoted e.g. --time "1234.567,1234.789 1235,"
152	Time string is'a1.b1,c1.d1:a2.b2,c2.d2'. Use ':' to separate timestamps
153	for different perf.data files.
154
155	For example, we get the timestamp information from 'perf script'.
156
157	  perf script -i perf.data.old
158	    mgen 13940 [000]  3946.361400: ...
159
160	  perf script -i perf.data
161	    mgen 13940 [000]  3971.150589 ...
162
163	  perf diff --time 3946.361400,:3971.150589,
164
165	It analyzes the perf.data.old from the timestamp 3946.361400 to
166	the end of perf.data.old and analyzes the perf.data from the
167	timestamp 3971.150589 to the end of perf.data.
168
169--cpu:: Only diff samples for the list of CPUs provided. Multiple CPUs can
170	be provided as a comma-separated list with no space: 0,1. Ranges of
171	CPUs are specified with -: 0-2. Default is to report samples on all
172	CPUs.
173
174--pid=::
175	Only diff samples for given process ID (comma separated list).
176
177--tid=::
178	Only diff samples for given thread ID (comma separated list).
179
180COMPARISON
181----------
182The comparison is governed by the baseline file. The baseline perf.data
183file is iterated for samples. All other perf.data files specified on
184the command line are searched for the baseline sample pair. If the pair
185is found, specified computation is made and result is displayed.
186
187All samples from non-baseline perf.data files, that do not match any
188baseline entry, are displayed with empty space within baseline column
189and possible computation results (delta) in their related column.
190
191Example files samples:
192- file A with samples f1, f2, f3, f4,    f6
193- file B with samples     f2,     f4, f5
194- file C with samples f1, f2,         f5
195
196Example output:
197  x - computation takes place for pair
198  b - baseline sample percentage
199
200- perf diff A B C
201
202  baseline/A compute/B compute/C  samples
203  ---------------------------------------
204  b                    x          f1
205  b          x         x          f2
206  b                               f3
207  b          x                    f4
208  b                               f6
209             x         x          f5
210
211- perf diff B A C
212
213  baseline/B compute/A compute/C  samples
214  ---------------------------------------
215  b          x         x          f2
216  b          x                    f4
217  b                    x          f5
218             x         x          f1
219             x                    f3
220             x                    f6
221
222- perf diff C B A
223
224  baseline/C compute/B compute/A  samples
225  ---------------------------------------
226  b                    x          f1
227  b          x         x          f2
228  b          x                    f5
229                       x          f3
230             x         x          f4
231                       x          f6
232
233COMPARISON METHODS
234------------------
235delta
236~~~~~
237If specified the 'Delta' column is displayed with value 'd' computed as:
238
239  d = A->period_percent - B->period_percent
240
241with:
242  - A/B being matching hist entry from data/baseline file specified
243    (or perf.data/perf.data.old) respectively.
244
245  - period_percent being the % of the hist entry period value within
246    single data file
247
248  - with filtering by -C, -d and/or -S, period_percent might be changed
249    relative to how entries are filtered.  Use --percentage=absolute to
250    prevent such fluctuation.
251
252delta-abs
253~~~~~~~~~
254Same as 'delta` method, but sort the result with the absolute values.
255
256ratio
257~~~~~
258If specified the 'Ratio' column is displayed with value 'r' computed as:
259
260  r = A->period / B->period
261
262with:
263  - A/B being matching hist entry from data/baseline file specified
264    (or perf.data/perf.data.old) respectively.
265
266  - period being the hist entry period value
267
268wdiff:WEIGHT-B,WEIGHT-A
269~~~~~~~~~~~~~~~~~~~~~~~
270If specified the 'Weighted diff' column is displayed with value 'd' computed as:
271
272   d = B->period * WEIGHT-A - A->period * WEIGHT-B
273
274  - A/B being matching hist entry from data/baseline file specified
275    (or perf.data/perf.data.old) respectively.
276
277  - period being the hist entry period value
278
279  - WEIGHT-A/WEIGHT-B being user supplied weights in the the '-c' option
280    behind ':' separator like '-c wdiff:1,2'.
281    - WEIGHT-A being the weight of the data file
282    - WEIGHT-B being the weight of the baseline data file
283
284cycles
285~~~~~~
286If specified the '[Program Block Range] Cycles Diff' column is displayed.
287It displays the cycles difference of same program basic block amongst
288two perf.data. The program basic block is the code between two branches.
289
290'[Program Block Range]' indicates the range of a program basic block.
291Source line is reported if it can be found otherwise uses symbol+offset
292instead.
293
294SEE ALSO
295--------
296linkperf:perf-record[1], linkperf:perf-report[1]
297