diff mbox series

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

Message ID 20240501200922.226347-1-crwood@redhat.com
State New
Headers show
Series rteval: cyclictest.py: reduce: Fix exception with missing samples | expand

Commit Message

Crystal Wood May 1, 2024, 8:09 p.m. UTC
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.

Signed-off-by: Crystal Wood <crwood@redhat.com>
---
 rteval/modules/measurement/cyclictest.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

John Kacur May 1, 2024, 8:51 p.m. UTC | #1
On Wed, 1 May 2024, Crystal Wood wrote:

> 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.
> 
> Signed-off-by: Crystal Wood <crwood@redhat.com>
> ---
>  rteval/modules/measurement/cyclictest.py | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/rteval/modules/measurement/cyclictest.py b/rteval/modules/measurement/cyclictest.py
> index cef73abd1b4b..925065367eaf 100644
> --- a/rteval/modules/measurement/cyclictest.py
> +++ b/rteval/modules/measurement/cyclictest.py
> @@ -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
>  
> -- 

Signed-off-by: John Kacur <jkacur@redhat.com>
diff mbox series

Patch

diff --git a/rteval/modules/measurement/cyclictest.py b/rteval/modules/measurement/cyclictest.py
index cef73abd1b4b..925065367eaf 100644
--- a/rteval/modules/measurement/cyclictest.py
+++ b/rteval/modules/measurement/cyclictest.py
@@ -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