From e9e49c49acbd7789d2e44f82401663b58720bb66 Mon Sep 17 00:00:00 2001 From: David Bar-On Date: Sat, 10 Aug 2024 09:33:50 +0300 Subject: [PATCH] Performance enhancement for iperf_time_add() --- src/iperf_time.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/iperf_time.c b/src/iperf_time.c index a435dd30d..5c9b0fb7f 100644 --- a/src/iperf_time.c +++ b/src/iperf_time.c @@ -72,12 +72,11 @@ iperf_time_now(struct iperf_time *time1) void iperf_time_add_usecs(struct iperf_time *time1, uint64_t usecs) { - time1->secs += usecs / 1000000L; - time1->usecs += usecs % 1000000L; - if ( time1->usecs >= 1000000L ) { - time1->secs += time1->usecs / 1000000L; - time1->usecs %= 1000000L; - } + uint64_t total_usecs; + + total_usecs = time1->usecs + usecs; + time1->secs += total_usecs / 1000000L; + time1->usecs = total_usecs % 1000000L; } uint64_t