All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] rt-tests: hwlatdetect: Add timestamp delta
@ 2026-03-09 23:09 Costa Shulyupin
  2026-03-10 18:05 ` John Kacur
  0 siblings, 1 reply; 2+ messages in thread
From: Costa Shulyupin @ 2026-03-09 23:09 UTC (permalink / raw)
  To: linux-rt-users; +Cc: John Kacur, Costa Shulyupin, Luis Claudio R. Goncalves

Add delta field that calculates the time interval between consecutive
samples. For the first sample, the previous timestamp is initialized to
'nan' (Not a Number), so the first delta is also 'nan'.

This helps identify periodic issues during hardware latency testing.

v2:
Address John Kacur's review comments:
- Use float('nan') instead of string 'nan' for prev initialization
- Compute float(ts) once and reuse for delta calculation and prev update

Signed-off-by: Costa Shulyupin <costa.shul@redhat.com>
---
 src/hwlatdetect/hwlatdetect.py | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/src/hwlatdetect/hwlatdetect.py b/src/hwlatdetect/hwlatdetect.py
index 42b9f301718a..18ca930487f0 100755
--- a/src/hwlatdetect/hwlatdetect.py
+++ b/src/hwlatdetect/hwlatdetect.py
@@ -253,7 +253,8 @@     def detect(self):
 
     class Sample:
         'private class for tracer sample data'
-        __slots__ = 'cpu', 'timestamp', 'inner', 'outer', 'count'
+        __slots__ = 'cpu', 'timestamp', 'delta', 'inner', 'outer', 'count'
+        prev = float('nan')
 
         def __init__(self, line):
             fields = line.split()
@@ -276,14 +277,16 @@         def __init__(self, line):
             i, o = fields[6].split('/')
             ts = fields[7][3:]
             self.timestamp = str(ts)
+            ts_float = float(ts)
+            self.delta = ts_float - self.__class__.prev
+            self.__class__.prev = ts_float
             self.inner = int(i)
             self.outer = int(o)
             self.count = int(kv["count"]) if "count" in kv else None
 
         def __str__(self):
-            if self.count is not None:
-                return f"ts: {self.timestamp}, inner:{self.inner}, outer:{self.outer}, cpu:{self.cpu}, count:{self.count}"
-            return f"ts: {self.timestamp}, inner:{self.inner}, outer:{self.outer}, cpu:{self.cpu}"
+            s = f"ts: {self.timestamp}, delta:{self.delta:.6f}, inner:{self.inner}, outer:{self.outer}, cpu:{self.cpu}"
+            return s if self.count is None else s + f", count:{self.count}"
 
         def display(self):
             """ convert object to string and print """
-- 
2.53.0


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

* Re: [PATCH v2] rt-tests: hwlatdetect: Add timestamp delta
  2026-03-09 23:09 [PATCH v2] rt-tests: hwlatdetect: Add timestamp delta Costa Shulyupin
@ 2026-03-10 18:05 ` John Kacur
  0 siblings, 0 replies; 2+ messages in thread
From: John Kacur @ 2026-03-10 18:05 UTC (permalink / raw)
  To: Costa Shulyupin; +Cc: linux-rt-users, John Kacur, Luis Claudio R. Goncalves


8<------

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

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

end of thread, other threads:[~2026-03-10 18:06 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-09 23:09 [PATCH v2] rt-tests: hwlatdetect: Add timestamp delta Costa Shulyupin
2026-03-10 18:05 ` John Kacur

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.