Skip to content

Commit 6aa732f

Browse files
committed
fix: mtrace timestamp convertion
New OS has different timestamp format in mtrace file. This fix makes sof_per_analyzer.py handle both formats correctly. Signed-off-by: Emilia Kurdybelska <emiliax.kurdybelska@intel.com>
1 parent 49c1ecb commit 6aa732f

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

tools/sof_perf_analyzer.py

Lines changed: 12 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,17 @@ 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+
except ValueError: # For different timestamp format in mtrace file
142+
h, m, rest = line[span_end_pos - 23: span_end_pos - 7].strip().split(':')
143+
s1, s2 = rest.split(',')
144+
s = s1+s2
145+
timestamp = timedelta(
146+
hours=int(h),
147+
minutes=int(m),
148+
seconds=float(s)
149+
).total_seconds()
139150

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

0 commit comments

Comments
 (0)