Skip to contentSkip to conversation

rteval: cyclictest.py: reduce: Fix exception with missing samples

PATCH In review Crystal Wood 2 participants 2 messages May 1, 2024

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 rteval: cyclictest.py: reduce: Fix exception with missing samples

If cyclictest omits a line of zeroes rather than printing it, __samples[high] will not exist (rather than be zero). Handle this in preparation for cyclictest doing this.

Note that get() seems more suitable than setdefault(), but the latter is used in order to match the code in timerlat.py.

---
 rteval/modules/measurement/cyclictest.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
rteval/modules/measurement/cyclictest.py +1 -1
index cef73abd1b4b..925065367eaf 100644
@@ -115,7 +115,7 @@ class RunData:
                 low = i
                 break
         high = keys[-1]
-        while high and self.__samples[high] == 0:
+        while high and self.__samples.setdefault(high, 0) == 0:
             high -= 1
         self.__range = high - low
 
Signature · 1 line
2.44.0
#1 lore raw
Quoted 18 lines · Crystal Wood

If cyclictest omits a line of zeroes rather than printing it, __samples[high] will not exist (rather than be zero). Handle this in preparation for cyclictest doing this.

Note that get() seems more suitable than setdefault(), but the latter is used in order to match the code in timerlat.py.

---
 rteval/modules/measurement/cyclictest.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
rteval/modules/measurement/cyclictest.py +0 -0
index cef73abd1b4b..925065367eaf 100644

rteval/modules/measurement/cyclictest.py class RunData: · line 121

Quoted 8 lines
rteval/modules/measurement/cyclictest.py +1 -1
@@ -115,7 +115,7 @@ class RunData:
                 low = i
                 break
         high = keys[-1]
-        while high and self.__samples[high] == 0:
+        while high and self.__samples.setdefault(high, 0) == 0:
             high -= 1
         self.__range = high - low