lkml.org 
[lkml]   [2020]   [Jun]   [28]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 1/2] perf stat: use proper macro for time conversions
Date
    The values of interval and timeout are in msecs as documented in the
-I and --timeout options.

Use MSEC_PER_SEC instead USEC_PER_MSEC to convert to struct timespec.
Both macros have the same value 1000L (see tools/include/linux/time64.h).

No functional change intended.

Signed-off-by: Emmanouil Maroudas <emmanouil.maroudas@gmail.com>
---
tools/perf/builtin-stat.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c
index 9be020e0098a..6aa866e2d512 100644
--- a/tools/perf/builtin-stat.c
+++ b/tools/perf/builtin-stat.c
@@ -613,11 +613,11 @@ static int __run_perf_stat(int argc, const char **argv, int run_idx)
bool second_pass = false;

if (interval) {
- ts.tv_sec = interval / USEC_PER_MSEC;
- ts.tv_nsec = (interval % USEC_PER_MSEC) * NSEC_PER_MSEC;
+ ts.tv_sec = interval / MSEC_PER_SEC;
+ ts.tv_nsec = (interval % MSEC_PER_SEC) * NSEC_PER_MSEC;
} else if (timeout) {
- ts.tv_sec = timeout / USEC_PER_MSEC;
- ts.tv_nsec = (timeout % USEC_PER_MSEC) * NSEC_PER_MSEC;
+ ts.tv_sec = timeout / MSEC_PER_SEC;
+ ts.tv_nsec = (timeout % MSEC_PER_SEC) * NSEC_PER_MSEC;
} else {
ts.tv_sec = 1;
ts.tv_nsec = 0;
--
2.17.1
\
 
 \ /
  Last update: 2020-06-29 01:27    [W:0.040 / U:0.288 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site