From b79f34df37d605954beaa381e6309d50386434b2 Mon Sep 17 00:00:00 2001 Message-Id: In-Reply-To: References: From: Kamalesh Babulal Date: Tue, 21 Apr 2020 08:02:51 -0500 Subject: [PATCH V4 07/14] lparstat: Add helper function to calculate delta To: powerpc-utils-devel@googlegroups.com Cc: Tyrel Datwyler , Nathan Lynch , Naveen N . Rao , Gautham R . Shenoy , Vasant Hegde Add a helper function for one of the most often used arithmetics of calculating delta of a sysentry. Signed-off-by: Kamalesh Babulal --- src/lparstat.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/lparstat.c b/src/lparstat.c index 7c55a8c..152e5fa 100644 --- a/src/lparstat.c +++ b/src/lparstat.c @@ -226,6 +226,21 @@ static void sig_int_handler(int signal) exit(1); } +long long get_delta_value(char *se_name) +{ + long long value, old_value; + struct sysentry *se; + + se = get_sysentry(se_name); + if (se->value[0] == '\0') + return 0LL; + + value = strtoll(se->value, NULL, 0); + old_value = strtoll(se->old_value, NULL, 0); + + return (value - old_value); +} + void get_time() { struct timeval t; -- 2.25.3