mirror of
https://github.com/MobileGL-Dev/MobileGL
synced 2026-11-07 01:53:24 +09:00
25 lines
1.2 KiB
Python
25 lines
1.2 KiB
Python
# MobileGL - tools/device_bench/disagg/slices.py
|
|
# Copyright (c) 2025-2026 MobileGL-Dev
|
|
# Licensed under the GNU Lesser General Public License v3.0:
|
|
# https://www.gnu.org/licenses/gpl-3.0.txt
|
|
# https://www.gnu.org/licenses/lgpl-3.0.txt
|
|
# SPDX-License-Identifier: LGPL-3.0-only
|
|
# End of Source File Header
|
|
|
|
# slices.py <trace> <comm-regex> : atrace slice wall time per slice name for threads whose comm-pid matches
|
|
import re, sys
|
|
from collections import Counter, defaultdict
|
|
line_re = re.compile(r'^\s*(.+?)-(\d+)\s+\(\s*([\d-]+)\)\s+\[(\d+)\]\s+\S+\s+([\d.]+):\s+tracing_mark_write:\s*(.*)$')
|
|
rx = re.compile(sys.argv[2]); stacks = defaultdict(list); tot = Counter(); cnt = Counter(); t0 = t1 = None
|
|
for line in open(sys.argv[1], errors="replace"):
|
|
m = line_re.match(line)
|
|
if not m: continue
|
|
comm, pid, tgid, cpu, ts, rest = m.groups(); ts = float(ts)
|
|
t0 = ts if t0 is None else t0; t1 = ts
|
|
if not rx.search(comm + "-" + pid): continue
|
|
if rest.startswith("B|"):
|
|
stacks[pid].append((rest.split("|", 2)[2][:70], ts))
|
|
elif rest.startswith("E|") and stacks[pid]:
|
|
n, s = stacks[pid].pop(); tot[n] += ts - s; cnt[n] += 1
|
|
for k, v in tot.most_common(25): print(f"{1e3*v:9.1f} ms n={cnt[k]:6d} avg {1e6*v/cnt[k]:8.1f} us {k}")
|