Skip to content

Commit 6c1908c

Browse files
committed
tools: fix: mtrace timestamp convertion
Support for the default Zephyr timestamp format in mtrace file. This fix makes sof_per_analyzer.py handle CONFIG_LOG_OUTPUT_FORMAT_TIME_TIMESTAMP format correctly. Signed-off-by: Emilia Kurdybelska <emiliax.kurdybelska@intel.com>
1 parent 653c36b commit 6c1908c

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

tools/sof_perf_analyzer.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import re
2222
import pathlib
2323
import argparse
24+
from datetime import timedelta
2425
from typing import TextIO
2526
from typing import Generator
2627
from dataclasses import dataclass
@@ -135,7 +136,18 @@ def make_trace_item(fileio: TextIO) -> TraceItemGenerator:
135136
# both some specific offset from the sentinel.
136137
span_end_pos = match_obj.span()[1]
137138
trace_lvl = line[span_end_pos - 4: span_end_pos - 1]
138-
timestamp = float(line[span_end_pos - 19: span_end_pos - 7].strip())
139+
try:
140+
timestamp = float(line[span_end_pos - 19: span_end_pos - 7].strip())
141+
# Support for CONFIG_LOG_OUTPUT_FORMAT_TIME_TIMESTAMP - For when default Zephyr timestamp format is used
142+
except ValueError:
143+
h, m, rest = line[span_end_pos - 23: span_end_pos - 7].strip().split(':')
144+
s1, s2 = rest.split(',')
145+
s = s1+s2
146+
timestamp = timedelta(
147+
hours=int(h),
148+
minutes=int(m),
149+
seconds=float(s)
150+
).total_seconds()
139151

140152
# The rest after removing timestamp and log level
141153
rest = line[span_end_pos + 1:].split(': ')

0 commit comments

Comments
 (0)