Received: by 2002:ac0:b08d:0:0:0:0:0 with SMTP id l13csp3558946imc; Sun, 24 Feb 2019 07:38:26 -0800 (PST) X-Google-Smtp-Source: AHgI3IYx6YNUoJaBhxlGo6DgDP7qftKKge0710wN9/pS6ZqjzdstNucBnWCMnHSqfyQVnvWEoQA7 X-Received: by 2002:a63:584e:: with SMTP id i14mr14041192pgm.68.1551022706502; Sun, 24 Feb 2019 07:38:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551022706; cv=none; d=google.com; s=arc-20160816; b=ZnbcQdY9g+j9ddtto4wsAjJ7VH461iwXCUgvoEZASD6QojnuoMNNa/cNFXeVWBo+Os p88tL7DNMP+fFE5VrEEOk8/30FnZ2NhBLI4DLPQv1ccWdV+4fpybYryUZ1GlFF4lGbT2 gbEAroLh8jDifTJRVhK4UhVR0kzctKkMoKtS+DmCgOuZUAPCVRd4hdLg8w6heMew6yIe cCXey1dQXhytLkPCwVJpuueI+nphNs8qQqQ5xHNZr/BNlTt1hhn4rD3l3vvPczmfdE8S SJuhSpTMBEYN01uyYRQ0PG6ZFLO+u8E1Htm6up6b8jaf+jkOQeePZNviADo8b5OVBMw6 p2hg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=VghTwPDLZpbGhTGCGdpo0nvY5i//3/6RTN2VYnpF4R8=; b=aoUyHPSUGMNaMiz368ekydhzGNO2IKdn+9HsS6km8/nUGMdiAgo5vxf/Hg7Y9Rxdue X1ONrlnKM4ma+jlnYxq53Bm6UKSQ5ufp3YabK1xiLPhNmXe+QNJtugkKkxvoldNqCRuA 4wCbEs284Adsymf85NUhXy//jUSUBUv42a+m3umW5iT6cyhiFjjAQptTR4cIpcacUBVZ Tpdwsg9RTEQRKg1BbVjqnWZH1AdLnAuAfBRw9pvc0St3PgspgDDuOJiCURWQd8Ipikvk JDOho7ZgPw5Gc7Yg6+qOIqnGNMfX1YajVDRjc8wOgHBGxyC6YWl0Fw4tWPAsg1lrgxIk iMZA== 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 x12si6251935pgp.286.2019.02.24.07.38.11; Sun, 24 Feb 2019 07:38:26 -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 S1728516AbfBXPhf (ORCPT + 99 others); Sun, 24 Feb 2019 10:37:35 -0500 Received: from mga01.intel.com ([192.55.52.88]:4462 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728489AbfBXPhe (ORCPT ); Sun, 24 Feb 2019 10:37:34 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga101.fm.intel.com with ESMTP; 24 Feb 2019 07:37:31 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.58,407,1544515200"; d="scan'208";a="120396838" Received: from tassilo.jf.intel.com (HELO tassilo.localdomain) ([10.7.201.137]) by orsmga008.jf.intel.com with ESMTP; 24 Feb 2019 07:37:30 -0800 Received: by tassilo.localdomain (Postfix, from userid 1000) id C58503010AD; Sun, 24 Feb 2019 07:37:30 -0800 (PST) From: Andi Kleen To: acme@kernel.org, linux-perf-users@vger.kernel.org Cc: linux-kernel@vger.kernel.org, jolsa@kernel.org, namhyung@kernel.org, eranian@google.com, Andi Kleen Subject: [PATCH 10/11] perf tools: Add utility function to print ns time stamps Date: Sun, 24 Feb 2019 07:37:21 -0800 Message-Id: <20190224153722.27020-11-andi@firstfloor.org> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20190224153722.27020-1-andi@firstfloor.org> References: <20190224153722.27020-1-andi@firstfloor.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Andi Kleen Add a utility function to print nanosecond timestamps. Signed-off-by: Andi Kleen --- tools/perf/util/time-utils.c | 8 ++++++++ tools/perf/util/time-utils.h | 1 + 2 files changed, 9 insertions(+) diff --git a/tools/perf/util/time-utils.c b/tools/perf/util/time-utils.c index 6193b46050a5..a63bdf4cfd1b 100644 --- a/tools/perf/util/time-utils.c +++ b/tools/perf/util/time-utils.c @@ -404,6 +404,14 @@ int timestamp__scnprintf_usec(u64 timestamp, char *buf, size_t sz) return scnprintf(buf, sz, "%"PRIu64".%06"PRIu64, sec, usec); } +int timestamp__scnprintf_nsec(u64 timestamp, char *buf, size_t sz) +{ + u64 sec = timestamp / NSEC_PER_SEC; + u64 nsec = timestamp % NSEC_PER_SEC; + + return scnprintf(buf, sz, "%"PRIu64".%09"PRIu64, sec, nsec); +} + int fetch_current_timestamp(char *buf, size_t sz) { struct timeval tv; diff --git a/tools/perf/util/time-utils.h b/tools/perf/util/time-utils.h index 70b177d2b98c..9266cf4a8e58 100644 --- a/tools/perf/util/time-utils.h +++ b/tools/perf/util/time-utils.h @@ -24,6 +24,7 @@ bool perf_time__ranges_skip_sample(struct perf_time_interval *ptime_buf, int num, u64 timestamp); int timestamp__scnprintf_usec(u64 timestamp, char *buf, size_t sz); +int timestamp__scnprintf_nsec(u64 timestamp, char *buf, size_t sz); int fetch_current_timestamp(char *buf, size_t sz); -- 2.17.2