xref: /linux-6.15/tools/perf/scripts/python/gecko.py (revision 1699d3ef)
1*1699d3efSAnup Sharma# firefox-gecko-converter.py - Convert perf record output to Firefox's gecko profile format
2*1699d3efSAnup Sharma# SPDX-License-Identifier: GPL-2.0
3*1699d3efSAnup Sharma#
4*1699d3efSAnup Sharma# The script converts perf.data to Gecko Profile Format,
5*1699d3efSAnup Sharma# which can be read by https://profiler.firefox.com/.
6*1699d3efSAnup Sharma#
7*1699d3efSAnup Sharma# Usage:
8*1699d3efSAnup Sharma#
9*1699d3efSAnup Sharma#     perf record -a -g -F 99 sleep 60
10*1699d3efSAnup Sharma#     perf script report gecko > output.json
11*1699d3efSAnup Sharma
12*1699d3efSAnup Sharmaimport os
13*1699d3efSAnup Sharmaimport sys
14*1699d3efSAnup Sharmafrom typing import Dict
15*1699d3efSAnup Sharma
16*1699d3efSAnup Sharma# Add the Perf-Trace-Util library to the Python path
17*1699d3efSAnup Sharmasys.path.append(os.environ['PERF_EXEC_PATH'] + \
18*1699d3efSAnup Sharma	'/scripts/python/Perf-Trace-Util/lib/Perf/Trace')
19*1699d3efSAnup Sharma
20*1699d3efSAnup Sharmafrom perf_trace_context import *
21*1699d3efSAnup Sharmafrom Core import *
22*1699d3efSAnup Sharma
23*1699d3efSAnup Sharma# Uses perf script python interface to parse each
24*1699d3efSAnup Sharma# event and store the data in the thread builder.
25*1699d3efSAnup Sharmadef process_event(param_dict: Dict) -> None:
26*1699d3efSAnup Sharma	pass
27*1699d3efSAnup Sharma
28*1699d3efSAnup Sharma# Trace_end runs at the end and will be used to aggregate
29*1699d3efSAnup Sharma# the data into the final json object and print it out to stdout.
30*1699d3efSAnup Sharmadef trace_end() -> None:
31*1699d3efSAnup Sharma	pass
32