Skip to content

Commit

Permalink
spl-time: Add assertion to gethrtime and cache NANOSEC / freq division
Browse files Browse the repository at this point in the history
One less division for each call.

Signed-off-by: Axel Gembe <[email protected]>
  • Loading branch information
EchterAgo committed Nov 10, 2023
1 parent 439c171 commit c318c73
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion module/os/windows/spl/spl-time.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/*
Expand Down

0 comments on commit c318c73

Please sign in to comment.