public inbox for linux-rt-users@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] rt-tests: hwlatdetect: Update to integer division
@ 2022-11-10 15:35 Leah Leshchinsky
  2022-11-11 19:46 ` John Kacur
  0 siblings, 1 reply; 2+ messages in thread
From: Leah Leshchinsky @ 2022-11-10 15:35 UTC (permalink / raw)
  To: jkacur; +Cc: linux-rt-users

In Python 3, "/" is a float division operator, as opposed to Python 2,
which defaults to integer division. This results in an error when
calculating width, which assumes an integer.

Update width division to integer division with the "//" operator.

Signed-off-by: Leah Leshchinsky <lleshchi@redhat.com>

diff --git a/src/hwlatdetect/hwlatdetect.py b/src/hwlatdetect/hwlatdetect.py
index 7b1ae646577a..929107f9c252 100755
--- a/src/hwlatdetect/hwlatdetect.py
+++ b/src/hwlatdetect/hwlatdetect.py
@@ -454,9 +454,10 @@ if __name__ == '__main__':
 
     if args.window:
         w = microseconds(args.window)
+        width = w//2
         if w < int(detect.get("width")):
-            debug(f"shrinking width to {w//2} for new window of {w}")
-            detect.set("width", w/2)
+            debug(f"shrinking width to {width} for new window of {w}")
+            detect.set("width", width)
         debug(f"window parameter = {w}")
         detect.set("window", w)
         debug(f"window for sampling set to {w}us")
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] rt-tests: hwlatdetect: Update to integer division
  2022-11-10 15:35 [PATCH] rt-tests: hwlatdetect: Update to integer division Leah Leshchinsky
@ 2022-11-11 19:46 ` John Kacur
  0 siblings, 0 replies; 2+ messages in thread
From: John Kacur @ 2022-11-11 19:46 UTC (permalink / raw)
  To: Leah Leshchinsky; +Cc: linux-rt-users



On Thu, 10 Nov 2022, Leah Leshchinsky wrote:

> In Python 3, "/" is a float division operator, as opposed to Python 2,
> which defaults to integer division. This results in an error when
> calculating width, which assumes an integer.

What kind of error? Is there a traceback, or merely an incorrect value?

> 
> Update width division to integer division with the "//" operator.
> 
> Signed-off-by: Leah Leshchinsky <lleshchi@redhat.com>
> 
> diff --git a/src/hwlatdetect/hwlatdetect.py b/src/hwlatdetect/hwlatdetect.py
> index 7b1ae646577a..929107f9c252 100755
> --- a/src/hwlatdetect/hwlatdetect.py
> +++ b/src/hwlatdetect/hwlatdetect.py
> @@ -454,9 +454,10 @@ if __name__ == '__main__':
>  
>      if args.window:
>          w = microseconds(args.window)
> +        width = w//2
>          if w < int(detect.get("width")):
> -            debug(f"shrinking width to {w//2} for new window of {w}")
> -            detect.set("width", w/2)
> +            debug(f"shrinking width to {width} for new window of {w}")
> +            detect.set("width", width)
>          debug(f"window parameter = {w}")
>          detect.set("window", w)
>          debug(f"window for sampling set to {w}us")
> -- 

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


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-11-11 19:47 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-11-10 15:35 [PATCH] rt-tests: hwlatdetect: Update to integer division Leah Leshchinsky
2022-11-11 19:46 ` John Kacur

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox