Re: [PATCH v1] rt-tests: hwlatdetect: Add timestamp delta
John Kacur <[email protected]>
| Newsgroups | org.kernel.vger.linux-rt-users |
|---|---|
| Message-ID | <[email protected]> |
On Mon, 2 Mar 2026, Costa Shulyupin wrote: > 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 <[email protected]> > --- > 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' prev = float('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) ts_float = float(ts) > + self.delta = float(ts) - float(self.__class__.prev) self.delta = ts_float - self.__class__.prev > + self.__class__.prev = ts 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 > > >