From nobody Tue Oct 21 00:44:56 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2D857C0015E for ; Wed, 5 Jul 2023 19:49:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233952AbjGETt1 (ORCPT ); Wed, 5 Jul 2023 15:49:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52744 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233699AbjGETtX (ORCPT ); Wed, 5 Jul 2023 15:49:23 -0400 Received: from mail-pl1-x634.google.com (mail-pl1-x634.google.com [IPv6:2607:f8b0:4864:20::634]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 23890E3; Wed, 5 Jul 2023 12:49:23 -0700 (PDT) Received: by mail-pl1-x634.google.com with SMTP id d9443c01a7336-1b895a06484so18482905ad.1; Wed, 05 Jul 2023 12:49:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1688586562; x=1691178562; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=Gwp8fA2qpy452CipUIAT5AcsUa4bLXq9Z9L1naFewyg=; b=AH2xCWzJyQrh3RwBnsTSDzNuG04w+HjuNr1vKGp1Q3oiaKhXGYhefX7K75Q/TkYe6B BFN6d+A9sDXrKTkD68wNZPLnuYkkfBfpqMPWDIA4qgDTgwx/qqdOnd+lZZR4OuEaUpeq zqFWjhES/f2nWWF97kyhFafsDHxW/r4Wks0FY3UxCa1kLnVdd4VnBQTWjk3WSRKIA7kK BjKzsLAuDRCrlA+IBXi6UHTtj3hKGeB86lnwVw9QdHvJiQAlaVDMsxeWOBlLSCclgucj /oMKLRzNSm2XeqkQ568W69PhOu2thyMN1Jufo8wR2nAcmdwpoXty3bDXA2iMBWQfyluh oj3Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688586562; x=1691178562; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=Gwp8fA2qpy452CipUIAT5AcsUa4bLXq9Z9L1naFewyg=; b=NWUznAubtEtvciU4RCtj8hlw0rHNhVaOWTj6eWSrQxTvIpeps44DWomlpNALwTKgha TGMoj8NfNn8IXhbQba50ET6m/HPhWW42MSdMyWfm+xIZCKuiAOHKm/OohsfSMdjuAuzj ARTAa6/0L3rRov4rFCTMg4uyb7/oxWv9fohaj0ALBMu49Rb/gJQdSV3lF9CwOKWtfwTX 6Fa1zxKQ0zrJ7ypHFtb8KuKBuFzTnaHlfLDS1//RNimN1qHOk+Nl2CsB5Up27vkVRgHa rpLUv76tU7FkgrzZ5zyDCn7eqz4uUPq9km3Nx1+TbMCA1AbOcutgMAjP9scRtQ5eAnCk SJJw== X-Gm-Message-State: ABy/qLYHu5w10TrFwO95hV3XE3dFC+Xh0EmQfzCNgDWMcQe9Amyr/AHL pzzCbajnJZzyhalo1UCtSwc= X-Google-Smtp-Source: APBJJlFPwzvYIzNEY+bAyj+fX3xFQcHUHiPP3qHW3xU7+OplVAcUuNMEJjLTCT58P9FDJEdfbDGkmA== X-Received: by 2002:a17:903:2281:b0:1b6:6b90:7c2f with SMTP id b1-20020a170903228100b001b66b907c2fmr16773053plh.55.1688586562475; Wed, 05 Jul 2023 12:49:22 -0700 (PDT) Received: from yoga ([2400:1f00:13:c628:31be:68ae:86f5:48b9]) by smtp.gmail.com with ESMTPSA id 4-20020a170902c24400b001b86f410341sm9812547plg.189.2023.07.05.12.49.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Jul 2023 12:49:22 -0700 (PDT) Date: Thu, 6 Jul 2023 01:19:13 +0530 From: Anup Sharma To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Ian Rogers , Adrian Hunter , Anup Sharma , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 6/7] scripts: python: implement add sample function and return finish Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The addSample function appends a new entry to the 'samples' data structure. It takes the thread name, stack array, and time as input parameters and if the thread name differs from the current name, it updates the name. The function utilizes the get_or_create_stack and get_or_create_frame methods to construct the stack structure. Finally, it adds the stack, time, and responsiveness values to the 'data' list within 'samples'. The finish function generates a dictionary containing various profile information such as 'tid', 'pid', 'name', 'markers', 'samples', 'frameTable', 'stackTable', 'stringTable', 'registerTime', 'unregisterTime', and 'processType'. Signed-off-by: Anup Sharma --- .../scripts/python/firefox-gecko-converter.py | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/tools/perf/scripts/python/firefox-gecko-converter.py b/tools/p= erf/scripts/python/firefox-gecko-converter.py index d5b9fb16e520..910e598c743f 100644 --- a/tools/perf/scripts/python/firefox-gecko-converter.py +++ b/tools/perf/scripts/python/firefox-gecko-converter.py @@ -110,6 +110,35 @@ def process_event(param_dict): frameMap[frameString] =3D frame return frame =20 + def addSample(threadName, stackArray, time): + nonlocal name + if name !=3D threadName: + name =3D threadName + stack =3D reduce(lambda prefix, stackFrame: get_or_create_stack + (get_or_create_frame(stackFrame), prefix), stackArray, None) + responsiveness =3D 0 + samples['data'].append([stack, time, responsiveness]) + + def finish(): + return { + "tid": tid, + "pid": pid, + "name": name, + "markers": markers, + "samples": samples, + "frameTable": frameTable, + "stackTable": stackTable, + "stringTable": stringTable, + "registerTime": 0, + "unregisterTime": None, + "processType": 'default' + } + + return { + "addSample": addSample, + "finish": finish + } + def _addThreadSample(pid, tid, threadName, time_stamp, stack): thread =3D thread_map.get(tid) if not thread: --=20 2.34.1