[PATCH 3/9] scripts: python: Introduce thread sample processing in convertPerfScriptProfile

From: Anup Sharma
Date: Wed Jun 21 2023 - 15:41:02 EST


The _addThreadSample function is responsible for adding a sample to a specific
thread. It takes the process ID (pid), thread ID (tid), thread name, timestamp
(time_stamp), and stack as parameters. It first checks if the thread exists in
the threadMap dictionary. If not, it creates a new thread using the _createtread
function and assigns it to the threadMap. Finally, it calls the 'addSample' method
of the thread, passing the thread name, stack, and timestamp.

Signed-off-by: Anup Sharma <anupnewsmail@xxxxxxxxx>
---
tools/perf/scripts/python/firefox-gecko-converter.py | 8 ++++++++
1 file changed, 8 insertions(+)

diff --git a/tools/perf/scripts/python/firefox-gecko-converter.py b/tools/perf/scripts/python/firefox-gecko-converter.py
index 2817d4a96269..0ff70c0349c8 100644
--- a/tools/perf/scripts/python/firefox-gecko-converter.py
+++ b/tools/perf/scripts/python/firefox-gecko-converter.py
@@ -46,3 +46,11 @@ def convertPerfScriptProfile(profile):
"addSample": addSample,
"finish": finish
}
+
+ threadMap = dict()
+ def _addThreadSample(pid, tid, threadName, time_stamp, stack):
+ thread = threadMap.get(tid)
+ if not thread:
+ thread = _createtread(threadName, pid, tid)
+ threadMap[tid] = thread
+ thread['addSample'](threadName, stack, time_stamp)
--
2.34.1