Describe the bug
The nds and nds-h power scripts can report an inaccurate number for the "Power Test Time" especially when the test finishes too quickly. Sometimes a negative number is reported as the test time. This is because we use int(time.time()) to measure the timing. The use of int(time.time()) has a couple of issues. See https://docs.python.org/3/library/time.html#time.time for more details.
time.time() returns the unix time in seconds as a float, which can cause precision loss.
- The
int casting will drop the fractional seconds.
We should use time.time_ns() instead to improve the accuracy.
Steps/Code to reproduce bug
Run some query that finishes very quickly, such as SELECT 1.
Expected behavior
The test time should be as accurate as possible. The test time should never be negative numbers.
Describe the bug
The nds and nds-h power scripts can report an inaccurate number for the "Power Test Time" especially when the test finishes too quickly. Sometimes a negative number is reported as the test time. This is because we use
int(time.time())to measure the timing. The use ofint(time.time())has a couple of issues. See https://docs.python.org/3/library/time.html#time.time for more details.time.time()returns the unix time in seconds as a float, which can cause precision loss.intcasting will drop the fractional seconds.We should use
time.time_ns()instead to improve the accuracy.Steps/Code to reproduce bug
Run some query that finishes very quickly, such as
SELECT 1.Expected behavior
The test time should be as accurate as possible. The test time should never be negative numbers.