From c318c7373c4ba03fc795d45ad74928dc931054e1 Mon Sep 17 00:00:00 2001 From: Axel Gembe Date: Fri, 10 Nov 2023 09:20:18 +0700 Subject: [PATCH] spl-time: Add assertion to gethrtime and cache NANOSEC / freq division One less division for each call. Signed-off-by: Axel Gembe --- module/os/windows/spl/spl-time.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/module/os/windows/spl/spl-time.c b/module/os/windows/spl/spl-time.c index e41151ff7d40..e3ad3668a91a 100644 --- a/module/os/windows/spl/spl-time.c +++ b/module/os/windows/spl/spl-time.c @@ -55,9 +55,12 @@ gethrtime(void) LARGE_INTEGER now; if (start.QuadPart == 0) { start = KeQueryPerformanceCounter(&freq); + ASSERT(freq.QuadPart < NANOSEC); + ASSERT(freq.QuadPart > 0); + freq.QuadPart = NANOSEC / freq.QuadPart; } now = KeQueryPerformanceCounter(NULL); - return (now.QuadPart - start.QuadPart) * (NANOSEC / freq.QuadPart); + return ((now.QuadPart - start.QuadPart) * freq.QuadPart); } /*