public inbox for linux-rt-users@vger.kernel.org
 help / color / mirror / Atom feed
From: Costa Shulyupin <costa.shul@redhat.com>
To: linux-rt-users <linux-rt-users@vger.kernel.org>
Cc: John Kacur <jkacur@redhat.com>,
	Costa Shulyupin <costa.shul@redhat.com>,
	"Luis Claudio R. Goncalves" <lgoncalv@redhat.com>
Subject: [PATCH v1] rt-tests: hwlatdetect: Add timestamp delta
Date: Mon,  2 Mar 2026 21:33:10 +0200	[thread overview]
Message-ID: <20260302193310.1712952-1-costa.shul@redhat.com> (raw)

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.

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

diff --git a/src/hwlatdetect/hwlatdetect.py b/src/hwlatdetect/hwlatdetect.py
index 42b9f301718a..f95e771048f6 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 = 'nan'
 
         def __init__(self, line):
             fields = line.split()
@@ -276,14 +277,15 @@         def __init__(self, line):
             i, o = fields[6].split('/')
             ts = fields[7][3:]
             self.timestamp = str(ts)
+            self.delta = float(ts) - float(self.__class__.prev)
+            self.__class__.prev = ts
             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


             reply	other threads:[~2026-03-02 19:33 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-02 19:33 Costa Shulyupin [this message]
2026-03-09 22:21 ` [PATCH v1] rt-tests: hwlatdetect: Add timestamp delta John Kacur

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260302193310.1712952-1-costa.shul@redhat.com \
    --to=costa.shul@redhat.com \
    --cc=jkacur@redhat.com \
    --cc=lgoncalv@redhat.com \
    --cc=linux-rt-users@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox