Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp5217609ybl; Tue, 4 Feb 2020 09:46:32 -0800 (PST) X-Google-Smtp-Source: APXvYqz15sizu6/9M55Ay4QYkRtTtbcavZTEwa2aD0FRHeV+tr1+H6J9Ev/tQjWn95eD7iC3RCay X-Received: by 2002:a05:6830:43:: with SMTP id d3mr23862888otp.259.1580838392683; Tue, 04 Feb 2020 09:46:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1580838392; cv=none; d=google.com; s=arc-20160816; b=KjxXmRfaviVVzqwQ0+9PZaOC//uDIbsJweb+dEcZBKs/o4pHEDXFO6I5OB4uCB6Wdx VccCQ8EKXICaaMPJhBm29V7jW2ne96G+rhLh3dM2YtO9iqeBXEfW8nofMzlm5VNhkVnP PcVXEMgm/+3tKZ3oP8gDaCkgP+zcwcJ5I4dGVj4qzmnD+kst3p9ED6MSwFm/wK6B9slQ VwLk+MKURo5TMU4WPDp4C29Sef/V+KBXfVaAfwD0IRlRau5Uh7jdwXV6Im4MqetQ7boZ CFMO0rA3x9g5K7gVN2Jv0i/8TM+NlLw05bqwaQSQZNPNtop+9fUezlJb+OYBYiBnBFVV D6sQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=oLKMuMB0pD/SnJNS01mXV9qqfnLzf6MymNdMH0gH6s8=; b=aq45CPDr2DiPN/j4/TGkEXxHdothnj8WgwyK7iKabMHs+tBu0GBhjmS3G1EAN2KPiu 6ZJci0LDU7T8qAkq1TZvHX4cHqAHu1PjfxzBoTBDHfbMGhZDPoZM3jHp1xOvEHOU8tEQ URvUbdHp/4FNL+pSus+H13pdzewr8TnOI+hkNzY4NamQphS5cbysFNJnhoDudEPm3HYk F8FD34JfC2wH0/SdZm6r9pXrbI7YchloRz08vR5P8qdihTLwT+RYSfA+U3mnm+HGAyRH EBUnNzFrV83+qA7cMKJ6EwOXljf9RDZbSEoFbrNxEmgVx7ysw8M0rm5nNIgXTm5TJTkX hqiA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l14si11092673oii.37.2020.02.04.09.46.20; Tue, 04 Feb 2020 09:46:32 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727456AbgBDRpR (ORCPT + 99 others); Tue, 4 Feb 2020 12:45:17 -0500 Received: from mout-p-201.mailbox.org ([80.241.56.171]:14426 "EHLO mout-p-201.mailbox.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727321AbgBDRpR (ORCPT ); Tue, 4 Feb 2020 12:45:17 -0500 X-Greylist: delayed 428 seconds by postgrey-1.27 at vger.kernel.org; Tue, 04 Feb 2020 12:45:17 EST Received: from smtp1.mailbox.org (smtp1.mailbox.org [80.241.60.240]) (using TLSv1.2 with cipher ECDHE-RSA-CHACHA20-POLY1305 (256/256 bits)) (No client certificate requested) by mout-p-201.mailbox.org (Postfix) with ESMTPS id 48BsNc0x4QzQlBW; Tue, 4 Feb 2020 18:38:08 +0100 (CET) X-Virus-Scanned: amavisd-new at heinlein-support.de Received: from smtp1.mailbox.org ([80.241.60.240]) by hefe.heinlein-support.de (hefe.heinlein-support.de [91.198.250.172]) (amavisd-new, port 10030) with ESMTP id r-FS5AX31atR; Tue, 4 Feb 2020 18:38:04 +0100 (CET) From: Hagen Paul Pfeifer To: linux-kernel@vger.kernel.org Cc: Hagen Paul Pfeifer , Andi Kleen , Adrian Hunter , Jiri Olsa , Arnaldo Carvalho de Melo Subject: [PATCH] perf script: introduce deltatime option Date: Tue, 4 Feb 2020 18:37:09 +0100 Message-Id: <20200204173709.489161-1-hagen@jauu.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org For some kind of analysis a deltatime output is more human friendly and reduce the cognitive load for further analysis. The following output demonstrate the new option "deltatime": calculate the time difference in relation to the previous event. $ perf script --deltatime test 2525 [001] 0.000000: sdt_libev:ev_add: (5635e72a5ebd) test 2525 [001] 0.000091: sdt_libev:epoll_wait_enter: (5635e72a76a9) test 2525 [001] 1.000051: sdt_libev:epoll_wait_return: (5635e72a772e) arg1=1 test 2525 [001] 0.000685: sdt_libev:ev_add: (5635e72a5ebd) test 2525 [001] 0.000048: sdt_libev:epoll_wait_enter: (5635e72a76a9) test 2525 [001] 1.000104: sdt_libev:epoll_wait_return: (5635e72a772e) arg1=1 test 2525 [001] 0.003895: sdt_libev:epoll_wait_enter: (5635e72a76a9) test 2525 [001] 0.996034: sdt_libev:epoll_wait_return: (5635e72a772e) arg1=1 test 2525 [001] 0.000058: sdt_libev:epoll_wait_enter: (5635e72a76a9) test 2525 [001] 1.000004: sdt_libev:epoll_wait_return: (5635e72a772e) arg1=1 test 2525 [001] 0.000064: sdt_libev:epoll_wait_enter: (5635e72a76a9) test 2525 [001] 0.999934: sdt_libev:epoll_wait_return: (5635e72a772e) arg1=1 test 2525 [001] 0.000056: sdt_libev:epoll_wait_enter: (5635e72a76a9) test 2525 [001] 0.999930: sdt_libev:epoll_wait_return: (5635e72a772e) arg1=1 Cc: Andi Kleen Cc: Adrian Hunter Cc: Jiri Olsa Cc: Arnaldo Carvalho de Melo Signed-off-by: Hagen Paul Pfeifer --- tools/perf/builtin-script.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c index e2406b291c1c..d5566b121159 100644 --- a/tools/perf/builtin-script.c +++ b/tools/perf/builtin-script.c @@ -63,7 +63,9 @@ static char const *script_name; static char const *generate_script_lang; static bool reltime; +static bool deltatime; static u64 initial_time; +static u64 previous_time; static bool debug_mode; static u64 last_timestamp; static u64 nr_unordered; @@ -704,6 +706,13 @@ static int perf_sample__fprintf_start(struct perf_sample *sample, if (!initial_time) initial_time = sample->time; t = sample->time - initial_time; + } else if (deltatime) { + if (previous_time) + t = sample->time - previous_time; + else { + t = 0; + } + previous_time = sample->time; } nsecs = t; secs = nsecs / NSEC_PER_SEC; @@ -3551,6 +3560,7 @@ int cmd_script(int argc, const char **argv) "anything beyond the specified depth will be ignored. " "Default: kernel.perf_event_max_stack or " __stringify(PERF_MAX_STACK_DEPTH)), OPT_BOOLEAN(0, "reltime", &reltime, "Show time stamps relative to start"), + OPT_BOOLEAN(0, "deltatime", &deltatime, "Show time stamps relative to previous event"), OPT_BOOLEAN('I', "show-info", &show_full_info, "display extended information from perf.data file"), OPT_BOOLEAN('\0', "show-kernel-path", &symbol_conf.show_kernel_path, @@ -3647,6 +3657,13 @@ int cmd_script(int argc, const char **argv) } } + if (reltime && deltatime) { + fprintf(stderr, + "reltime and deltatime - the two don't get along well. " + "Please limit to --reltime or --deltatime.\n"); + return -1; + } + if (itrace_synth_opts.callchain && itrace_synth_opts.callchain_sz > scripting_max_stack) scripting_max_stack = itrace_synth_opts.callchain_sz; -- 2.24.1