From 8614311d24bd392d6c85227c81b484979c286073 Mon Sep 17 00:00:00 2001 From: Ray Andrew <4437323+rayandrew@users.noreply.github.com> Date: Wed, 30 Oct 2024 11:20:05 -0500 Subject: [PATCH] Change `max` to `abs` for preprocess time (#240) `normal` result can be negative. if we do `max(t, 0) then we will reduce the variance when the generated value is negative. It is better to use `abs` in this case. --- dlio_benchmark/reader/reader_handler.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/dlio_benchmark/reader/reader_handler.py b/dlio_benchmark/reader/reader_handler.py index b8f8dfc4..720e4378 100644 --- a/dlio_benchmark/reader/reader_handler.py +++ b/dlio_benchmark/reader/reader_handler.py @@ -60,9 +60,9 @@ def __init__(self, dataset_type, thread_index): @dlp.log def preprocess(self, a=None): - if self._args.preprocess_time != 0. or self._args.preprocess_time_stdev != 0.: + if self._args.preprocess_time > 0. or self._args.preprocess_time_stdev > 0.: t = np.random.normal(self._args.preprocess_time, self._args.preprocess_time_stdev) - sleep(max(t, 0.0)) + sleep(abs(t)) return a @abstractmethod def open(self, filename): @@ -151,4 +151,4 @@ def is_index_based(self): @abstractmethod def is_iterator_based(self): - return False \ No newline at end of file + return False