History

perf scripts python: Extact necessary information from process event

The script takes in a sample event dictionary(param_dict) and retrieves relevant data such as time stamp, PID, TID, and comm for each event. Also start time is defined as a global variable as it need to be passed to trace_end for gecko meta information field creation.

Anup Sharma committed 3 years ago

Commit 0a02e441 parent 1699d3e1 file · +13 −1Browse files

Showing the changes to tools/perf/scripts/python (1 of 1 file). Show all

Unified · Split

tools/perf/scripts/python/gecko.py+13−1
@@ -20,10 +20,22 @@ sys.path.append(os.environ['PERF_EXEC_PATH'] + \ · 19 unmodified lines
20from perf_trace_context import *20from perf_trace_context import *
21from Core import *21from Core import *
22 22
23# start_time is intialiazed only once for the all event traces.
24start_time = None
25
23# Uses perf script python interface to parse each26# Uses perf script python interface to parse each
24# event and store the data in the thread builder.27# event and store the data in the thread builder.
25def process_event(param_dict: Dict) -> None:28def process_event(param_dict: Dict) -> None:
26 pass29 global start_time
30 global tid_to_thread
31 time_stamp = (param_dict['sample']['time'] // 1000) / 1000
32 pid = param_dict['sample']['pid']
33 tid = param_dict['sample']['tid']
34 comm = param_dict['comm']
35
36 # Start time is the time of the first sample
37 if not start_time:
38 start_time = time_stamp
27 39
28# Trace_end runs at the end and will be used to aggregate40# Trace_end runs at the end and will be used to aggregate
29# the data into the final json object and print it out to stdout.41# the data into the final json object and print it out to stdout.