Jin Yao
284c4e18f5
perf time-utils: Refactor time range parsing code
...
Jiri points out that we don't need any time checking and time string
parsing if the --time option is not set. That makes sense.
This patch refactors the time range parsing code, move the duplicated
code from perf report and perf script to time_utils and check if --time
option is set before parsing the time string. This patch is no logic
change expected. So the usage of --time is same as before.
For example:
Select the first and second 10% time slices:
perf report --time 10%/1,10%/2
perf script --time 10%/1,10%/2
Select the slices from 0% to 10% and from 30% to 40%:
perf report --time 0%-10%,30%-40%
perf script --time 0%-10%,30%-40%
Select the time slices from timestamp 3971 to 3973
perf report --time 3971,3973
perf script --time 3971,3973
Committer testing:
Using the above examples, check before and after to see if it remains
the same:
$ perf record -F 10000 -- find . -name "*.[ch]" -exec cat {} + > /dev/null
[ perf record: Woken up 3 times to write data ]
[ perf record: Captured and wrote 1.626 MB perf.data (42392 samples) ]
$
$ perf report --time 10%/1,10%/2 > /tmp/report.before.1
$ perf script --time 10%/1,10%/2 > /tmp/script.before.1
$ perf report --time 0%-10%,30%-40% > /tmp/report.before.2
$ perf script --time 0%-10%,30%-40% > /tmp/script.before.2
$ perf report --time 180457.375844,180457.377717 > /tmp/report.before.3
$ perf script --time 180457.375844,180457.377717 > /tmp/script.before.3
For example, the 3rd test produces this slice:
$ cat /tmp/script.before.3
cat 3147 180457.375844: 2143 cycles:uppp: 7f79362590d9 cfree@GLIBC_2.2.5+0x9 (/usr/lib64/libc-2.28.so)
cat 3147 180457.375986: 2245 cycles:uppp: 558b70f3d86e [unknown] (/usr/bin/cat)
cat 3147 180457.376012: 2164 cycles:uppp: 7f7936257430 _int_malloc+0x8c0 (/usr/lib64/libc-2.28.so)
cat 3147 180457.376140: 2921 cycles:uppp: 558b70f3a554 [unknown] (/usr/bin/cat)
cat 3147 180457.376296: 2844 cycles:uppp: 7f7936258abe malloc+0x4e (/usr/lib64/libc-2.28.so)
cat 3147 180457.376431: 2717 cycles:uppp: 558b70f3b0ca [unknown] (/usr/bin/cat)
cat 3147 180457.376667: 2630 cycles:uppp: 558b70f3d86e [unknown] (/usr/bin/cat)
cat 3147 180457.376795: 2442 cycles:uppp: 7f79362bff55 read+0x15 (/usr/lib64/libc-2.28.so)
cat 3147 180457.376927: 2376 cycles:uppp: ffffffff9aa00163 [unknown] ([unknown])
cat 3147 180457.376954: 2307 cycles:uppp: 7f7936257438 _int_malloc+0x8c8 (/usr/lib64/libc-2.28.so)
cat 3147 180457.377116: 3091 cycles:uppp: 7f7936258a70 malloc+0x0 (/usr/lib64/libc-2.28.so)
cat 3147 180457.377362: 2945 cycles:uppp: 558b70f3a3b0 [unknown] (/usr/bin/cat)
cat 3147 180457.377517: 2727 cycles:uppp: 558b70f3a9aa [unknown] (/usr/bin/cat)
$
Install 'coreutils-debuginfo' to see cat's guts (symbols), but then, the
above chunk translates into this 'perf report' output:
$ cat /tmp/report.before.3
# To display the perf.data header info, please use --header/--header-only options.
#
#
# Total Lost Samples: 0
#
# Samples: 13 of event 'cycles:uppp' (time slices: 180457.375844,180457.377717)
# Event count (approx.): 33552
#
# Overhead Command Shared Object Symbol
# ........ ....... ................ ......................
#
17.69% cat libc-2.28.so [.] malloc
14.53% cat cat [.] 0x000000000000586e
13.33% cat libc-2.28.so [.] _int_malloc
8.78% cat cat [.] 0x00000000000023b0
8.71% cat cat [.] 0x0000000000002554
8.13% cat cat [.] 0x00000000000029aa
8.10% cat cat [.] 0x00000000000030ca
7.28% cat libc-2.28.so [.] read
7.08% cat [unknown] [k] 0xffffffff9aa00163
6.39% cat libc-2.28.so [.] cfree@GLIBC_2.2.5
#
# (Tip: Order by the overhead of source file name and line number: perf report -s srcline)
#
$
Now lets see after applying this patch, nothing should change:
$ perf report --time 10%/1,10%/2 > /tmp/report.after.1
$ perf script --time 10%/1,10%/2 > /tmp/script.after.1
$ perf report --time 0%-10%,30%-40% > /tmp/report.after.2
$ perf script --time 0%-10%,30%-40% > /tmp/script.after.2
$ perf report --time 180457.375844,180457.377717 > /tmp/report.after.3
$ perf script --time 180457.375844,180457.377717 > /tmp/script.after.3
$ diff -u /tmp/report.before.1 /tmp/report.after.1
$ diff -u /tmp/script.before.1 /tmp/script.after.1
$ diff -u /tmp/report.before.2 /tmp/report.after.2
--- /tmp/report.before.2 2019-03-01 11:01:53.526094883 -0300
+++ /tmp/report.after.2 2019-03-01 11:09:18.231770467 -0300
@@ -352,5 +352,5 @@
#
-# (Tip: Generate a script for your data: perf script -g <lang>)
+# (Tip: Treat branches as callchains: perf report --branch-history)
#
$ diff -u /tmp/script.before.2 /tmp/script.after.2
$ diff -u /tmp/report.before.3 /tmp/report.after.3
--- /tmp/report.before.3 2019-03-01 11:03:08.890045588 -0300
+++ /tmp/report.after.3 2019-03-01 11:09:40.660224002 -0300
@@ -22,5 +22,5 @@
#
-# (Tip: Order by the overhead of source file name and line number: perf report -s srcline)
+# (Tip: List events using substring match: perf list <keyword>)
#
$ diff -u /tmp/script.before.3 /tmp/script.after.3
$
Cool, just the 'perf report' tips changed, QED.
Signed-off-by: Jin Yao <yao.jin@linux.intel.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Jin Yao <yao.jin@intel.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Kan Liang <kan.liang@linux.intel.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/1551435186-6008-1-git-send-email-yao.jin@linux.intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2019-03-01 11:03:53 -03:00
..
2019-02-14 15:18:08 -03:00
2019-02-14 15:18:08 -03:00
2019-01-03 18:57:57 -08:00
2019-02-14 15:18:08 -03:00
2017-11-02 11:10:55 +01:00
2019-02-14 15:18:08 -03:00
2019-02-21 17:00:35 -03:00
2019-01-25 15:12:08 +01:00
2018-01-17 10:23:31 -03:00
2018-01-17 10:23:31 -03:00
2018-01-17 10:23:31 -03:00
2018-01-17 10:23:31 -03:00
2019-02-06 11:20:32 -03:00
2019-02-06 11:20:32 -03:00
2019-01-25 15:12:09 +01:00
2019-01-25 15:12:09 +01:00
2019-02-19 16:11:56 -03:00
2019-02-19 16:11:56 -03:00
2019-02-20 16:23:07 -03:00
2019-01-21 17:36:39 -03:00
2019-02-06 10:00:39 -03:00
2019-02-06 10:00:39 -03:00
2018-06-15 18:10:01 -03:00
2017-11-02 11:10:55 +01:00
2017-07-18 23:14:40 -03:00
2019-01-25 15:12:08 +01:00
2019-02-19 16:11:56 -03:00
2019-02-06 10:00:38 -03:00
2019-01-25 15:12:09 +01:00
2017-11-02 11:10:55 +01:00
2016-05-06 13:00:43 -03:00
2016-05-06 13:00:43 -03:00
2019-02-06 10:00:38 -03:00
2019-02-06 10:00:38 -03:00
2018-06-04 10:28:50 -03:00
2018-03-07 10:22:26 -03:00
2017-11-02 11:10:55 +01:00
2017-11-02 11:10:55 +01:00
2019-01-21 17:38:56 -03:00
2019-01-21 17:38:56 -03:00
2019-01-25 15:12:08 +01:00
2019-01-25 15:12:09 +01:00
2019-01-25 15:12:09 +01:00
2018-08-20 08:54:59 -03:00
2019-02-06 10:00:38 -03:00
2018-05-16 16:11:09 -03:00
2017-11-02 11:10:55 +01:00
2017-11-02 11:10:55 +01:00
2019-02-06 10:00:39 -03:00
2019-02-20 17:08:39 -03:00
2019-02-06 10:00:39 -03:00
2019-02-19 12:21:10 -03:00
2019-02-19 12:21:06 -03:00
2019-02-14 15:18:08 -03:00
2019-02-14 15:18:06 -03:00
2017-11-02 11:10:55 +01:00
2019-02-22 16:52:07 -03:00
2017-11-02 11:10:55 +01:00
2017-11-02 11:10:55 +01:00
2019-02-25 10:43:07 -03:00
2019-02-25 10:43:07 -03:00
2019-02-06 10:00:38 -03:00
2016-05-06 13:00:53 -03:00
2018-03-16 16:39:02 -03:00
2017-11-02 11:10:55 +01:00
2017-11-02 11:10:55 +01:00
2017-11-02 11:10:55 +01:00
2017-11-02 11:10:55 +01:00
2017-11-02 11:10:55 +01:00
2019-02-06 10:00:38 -03:00
2019-01-25 15:12:10 +01:00
2018-12-28 16:33:02 -03:00
2018-12-28 16:33:02 -03:00
2018-04-02 13:50:24 -03:00
2016-09-29 11:17:08 -03:00
2017-11-02 11:10:55 +01:00
2018-12-17 14:54:02 -03:00
2018-10-18 11:16:38 -03:00
2019-02-06 10:00:38 -03:00
2019-02-06 11:20:32 -03:00
2019-02-06 10:00:39 -03:00
2019-02-06 10:00:39 -03:00
2018-12-17 14:57:07 -03:00
2019-02-20 16:08:59 -03:00
2019-02-06 10:00:38 -03:00
2017-11-02 11:10:55 +01:00
2017-08-22 12:19:08 -03:00
2019-01-08 13:28:13 -03:00
2017-06-19 15:27:07 -03:00
2018-04-30 12:02:03 -03:00
2018-10-18 11:16:38 -03:00
2018-04-12 10:33:31 -03:00
2018-11-19 12:12:17 -08:00
2017-11-02 11:10:55 +01:00
2019-02-25 10:58:28 -03:00
2018-10-18 11:16:38 -03:00
2017-11-02 11:10:55 +01:00
2015-12-14 12:30:37 -03:00
2019-02-06 10:00:40 -03:00
2019-02-06 10:00:40 -03:00
2019-02-06 11:20:32 -03:00
2015-08-21 11:34:10 -03:00
2019-02-06 11:20:32 -03:00
2016-09-29 11:17:05 -03:00
2019-01-25 15:12:10 +01:00
2017-11-07 10:30:18 +01:00
2019-01-25 15:12:09 +01:00
2016-10-24 11:07:39 -03:00
2019-02-06 10:00:39 -03:00
2017-11-02 11:10:55 +01:00
2017-11-02 11:10:55 +01:00
2018-08-30 15:52:20 -03:00
2018-08-20 08:54:58 -03:00
2018-08-20 08:54:59 -03:00
2019-02-06 10:00:38 -03:00
2019-02-06 10:00:38 -03:00
2019-02-06 10:00:38 -03:00
2019-02-06 10:00:38 -03:00
2019-02-06 10:00:38 -03:00
2019-02-06 10:00:38 -03:00
2018-03-16 13:52:37 -03:00
2018-03-16 13:52:37 -03:00
2019-02-04 11:32:14 -03:00
2017-11-02 11:10:55 +01:00
2017-11-02 11:10:55 +01:00
2017-11-02 11:10:55 +01:00
2019-02-14 15:18:09 -03:00
2019-02-14 15:18:09 -03:00
2019-02-06 10:00:39 -03:00
2019-02-06 10:00:39 -03:00
2018-11-19 12:12:26 -08:00
2018-11-19 12:12:26 -08:00
2019-01-17 11:07:00 -03:00
2018-12-17 15:02:17 -03:00
2017-11-02 11:10:55 +01:00
2017-11-02 11:10:55 +01:00
2019-02-14 15:18:09 -03:00
2018-10-19 16:31:09 -03:00
2018-10-19 16:31:09 -03:00
2019-02-14 15:18:08 -03:00
2017-11-02 11:10:55 +01:00
2017-11-02 11:10:55 +01:00
2017-12-27 12:15:48 -03:00
2017-12-27 12:15:48 -03:00
2017-11-02 11:10:55 +01:00
2017-11-02 11:10:55 +01:00
2016-11-29 12:13:27 -03:00
2017-11-02 11:10:55 +01:00
2017-11-02 11:10:55 +01:00
2017-11-02 11:10:55 +01:00
2019-02-06 10:00:39 -03:00
2019-02-06 10:00:39 -03:00
2017-11-07 10:30:18 +01:00
2017-11-07 10:30:18 +01:00
2019-02-28 14:20:35 -03:00
2019-01-25 15:12:09 +01:00
2019-01-25 15:12:09 +01:00
2018-09-24 04:44:54 -04:00
2018-03-19 13:51:53 -03:00
2017-11-02 11:10:55 +01:00
2017-11-02 11:10:55 +01:00
2017-11-02 11:10:55 +01:00
2017-12-27 12:15:56 -03:00
2018-12-28 16:33:02 -03:00
2019-01-25 15:12:10 +01:00
2019-01-25 15:12:10 +01:00
2019-01-25 15:12:10 +01:00
2018-03-05 11:52:41 -03:00
2017-09-21 13:28:06 -03:00
2017-09-21 13:28:06 -03:00
2019-01-21 17:00:48 -03:00
2018-08-08 15:26:48 -03:00
2019-02-14 13:31:08 -03:00
2018-08-03 10:34:18 -03:00
2019-01-21 17:00:56 -03:00
2019-01-21 17:00:48 -03:00
2019-01-21 17:00:48 -03:00
2017-11-02 11:10:55 +01:00
2019-02-20 16:07:51 -03:00
2018-09-19 10:25:10 -03:00
2017-07-18 23:14:08 -03:00
2019-02-06 10:00:39 -03:00
2017-08-22 12:09:04 -03:00
2017-08-22 12:09:04 -03:00
2019-02-19 12:30:12 -03:00
2019-02-06 10:00:38 -03:00
2018-12-17 14:57:07 -03:00
2019-02-06 10:00:38 -03:00
2019-02-19 12:30:12 -03:00
2019-01-25 15:12:09 +01:00
2019-01-25 15:12:08 +01:00
2019-01-25 15:12:10 +01:00
2018-09-19 10:25:10 -03:00
2018-09-19 10:25:10 -03:00
2019-01-04 12:54:49 -03:00
2017-11-02 11:10:55 +01:00
2017-11-02 11:10:55 +01:00
2017-11-02 11:10:55 +01:00
2017-12-27 12:15:55 -03:00
2017-12-27 12:15:55 -03:00
2017-04-24 13:43:33 -03:00
2019-01-25 15:12:10 +01:00
2018-12-17 14:59:20 -03:00
2017-11-02 11:10:55 +01:00
2019-01-25 15:12:08 +01:00
2019-01-25 15:12:10 +01:00
2019-02-09 13:16:01 +01:00
2019-01-25 15:12:09 +01:00
2019-02-06 10:00:40 -03:00
2019-02-06 10:00:38 -03:00
2018-07-24 14:53:01 -03:00
2017-11-02 11:10:55 +01:00
2016-07-29 11:54:35 -03:00
2017-12-27 12:15:47 -03:00
2017-11-02 11:10:55 +01:00
2017-11-02 11:10:55 +01:00
2018-02-27 11:29:21 -03:00
2018-02-27 11:29:21 -03:00
2019-02-22 16:49:49 -03:00
2019-02-06 10:00:40 -03:00
2019-02-06 10:00:38 -03:00
2019-02-06 10:00:38 -03:00
2019-03-01 11:03:53 -03:00
2019-03-01 11:03:53 -03:00
2019-01-21 17:00:57 -03:00
2018-12-17 14:58:47 -03:00
2018-12-17 14:58:33 -03:00
2018-10-08 14:23:45 -03:00
2018-12-17 14:56:02 -03:00
2018-12-17 14:56:08 -03:00
2018-08-10 15:29:35 -03:00
2018-12-17 14:56:02 -03:00
2018-12-17 14:56:02 -03:00
2018-03-06 11:31:14 -03:00
2017-11-02 11:10:55 +01:00
2017-11-02 11:10:55 +01:00
2017-11-02 11:10:55 +01:00
2017-11-02 11:10:55 +01:00
2019-02-06 10:00:38 -03:00
2017-11-02 11:10:55 +01:00
2019-02-06 10:00:38 -03:00
2019-02-06 10:00:38 -03:00
2017-11-02 11:10:55 +01:00
2017-11-02 11:10:55 +01:00
2017-11-02 11:10:55 +01:00
2019-02-25 10:58:28 -03:00
2019-02-25 10:58:28 -03:00
2017-11-02 11:10:55 +01:00
2017-11-02 11:10:55 +01:00
2019-02-06 10:00:38 -03:00
2017-11-02 11:10:55 +01:00
2017-11-02 11:10:55 +01:00
2017-11-02 11:10:55 +01:00
2019-01-21 15:15:57 -03:00