Re: [PATCH v1] rt-tests: hwlatdetect: Add --time-format argument

John Kacur <[email protected]> Wed, 15 Apr 2026 15:27:29 -0400
Newsgroups org.kernel.vger.linux-rt-users
Message-ID <[email protected]>
On Mon, 23 Mar 2026 at 18:03:46 +0200, Costa Shulyupin wrote:
> Add --time-format argument to customize timestamp output format using
> strftime directives. By default raw timestamps are output for
> backward compatibility.

Hi Costa,

Thanks for this patch. The --time-format feature is useful, but I have a few
concerns about the implementation:

1. The format_timestamp() method assumes the timestamp always contains a
   decimal point:

       t, ns = self.timestamp.split('.')

   This will fail with ValueError if the timestamp doesn't have a '.' for
   any reason. Please add error handling.

2. There's no try/except around strftime(). If a user provides an invalid
   format string, the code will crash. This should be handled gracefully.

3. The use of a class variable for time_format is unconventional:

       Tracer.Sample.time_format = args.time_format

   While it works, this makes all Sample instances share state in a way that
   could be surprising. Consider passing the format through instance
   initialization or as a method parameter instead.

4. Minor: The comment about "Float precision is safe for microseconds until
   year 2242" is misleading. The issue is that datetime only supports
   microsecond precision, not nanoseconds, which is why the custom %n
   handling is needed.

Could you please send a v2 with these improvements?

Thanks,
John