Fix timedelta precision by importing attotimedelta
total_seconds() method from Python's datetime class outputs a Float precision number which for some numbers multiplied by 10^n gives wrong values. total_seconds() method from attotime class wraps a native timedelta object and outputs a Decimal precision number which fixes this issue. Signed-off-by: Rafal Stefanowski <rafal.stefanowski@intel.com>
This commit is contained in:
parent
80d71fabea
commit
88efaa1940
@ -177,8 +177,7 @@ class Cache:
|
|||||||
if alru_params.staleness_time else None,
|
if alru_params.staleness_time else None,
|
||||||
alru_params.flush_max_buffers
|
alru_params.flush_max_buffers
|
||||||
if alru_params.flush_max_buffers else None,
|
if alru_params.flush_max_buffers else None,
|
||||||
int(alru_params.activity_threshold.total_seconds()
|
alru_params.activity_threshold.total_milliseconds()
|
||||||
* 1000)
|
|
||||||
if alru_params.activity_threshold else None)
|
if alru_params.activity_threshold else None)
|
||||||
|
|
||||||
def get_cache_config(self):
|
def get_cache_config(self):
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
from enum import IntEnum
|
from enum import IntEnum
|
||||||
from aenum import Enum
|
from aenum import Enum
|
||||||
from test_utils.size import Size, Unit
|
from test_utils.size import Size, Unit
|
||||||
from datetime import timedelta
|
from attotime import attotimedelta
|
||||||
|
|
||||||
|
|
||||||
class CacheLineSize(Enum):
|
class CacheLineSize(Enum):
|
||||||
@ -79,7 +79,7 @@ class CacheStatus(Enum):
|
|||||||
incomplete = 5
|
incomplete = 5
|
||||||
|
|
||||||
|
|
||||||
class Time(timedelta):
|
class Time(attotimedelta):
|
||||||
def total_milliseconds(self):
|
def total_milliseconds(self):
|
||||||
return int(self.total_seconds() * 1000)
|
return int(self.total_seconds() * 1000)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user