From nobody Wed Feb 11 05:41:55 2026 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 B7382EB64D8 for ; Wed, 21 Jun 2023 19:40:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229656AbjFUTkM (ORCPT ); Wed, 21 Jun 2023 15:40:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36988 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229542AbjFUTkI (ORCPT ); Wed, 21 Jun 2023 15:40:08 -0400 Received: from mail-pf1-x436.google.com (mail-pf1-x436.google.com [IPv6:2607:f8b0:4864:20::436]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DD761171C; Wed, 21 Jun 2023 12:40:07 -0700 (PDT) Received: by mail-pf1-x436.google.com with SMTP id d2e1a72fcca58-666ecf9a0ceso3383602b3a.2; Wed, 21 Jun 2023 12:40:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1687376407; x=1689968407; 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=pZjCGZDhKpXUGSqDazPCwNKoB5sel2LSB5kjV5qg9hw=; b=hSz94Aifn14AVAIYgF5iOoW8O9wlFY3sDdn24bNFUxZ3IY3QI9JvwGSZYXI14w6sc3 YF7rY1EzXKlv5p5oEqA0h6BdxSAbJPLLx4MHOiG/sdHW7YJ83NX/jXW2C4hhGet80cNz kidZdoUCnLA9ezjdiyep3GzL0pecbQDP/nXa3+azfB1cBB65qWOGEMH1znuJO8apC/TB 9j/MVQjydoci7Tqo6h0pbMi91ckJPnuxu5zamPfKeetEsCTCPoz5MtgT7v1hCdnKxFHQ sg10NEhE04yytTis968A7OWOX0MalBCsg507wAshXChkShni3b7JZ+QUdcB1crJnWdOs lq4Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687376407; x=1689968407; 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=pZjCGZDhKpXUGSqDazPCwNKoB5sel2LSB5kjV5qg9hw=; b=Y+4AuBgj3rGFazQ8jx3biPQMFv7jPLz/A+aIzkTRebiTSeE5UL4vB41L5iGG+Y1ZZb hHbrn9jGF2/ZwdB4p29CUH5bENhzwFbOHZvE95xAp2AUPFdmq2a0fm/Wnh69CxCKt8Qa EqWl6L4ij+ysbIa6IuNx5Qz85esejCYz225wtRg3bkPFD2B2Sr+YWsB69u3FMiiuWeIY pDE4wC3siK69pPdZGNk+RARp1xnQS1yRg3REt4PMYoTVLHM1Pu57PP7I6/19xJCHboNb hip0gT/gArGMqqXd0BAoEoEyxAbnxxRnnBoYMgwIWvq/iGVp3wadQVoAmuO9yduGLq43 WyQA== X-Gm-Message-State: AC+VfDw+Yzgz6tJ9wu6oyalBXJtCDFizQwIL7xcRPHmNg2dHy1fKBS7i jxkxV4QezYnsRmgBwZ1Y9Ek= X-Google-Smtp-Source: ACHHUZ7iTsUHJjPKx60L97N/5zwVvocem2AFCJg82V3aKOYyAr6+WE8FgMwSi8V+EGANZnX1Vng+pA== X-Received: by 2002:a05:6a00:a94:b0:666:8403:9f4 with SMTP id b20-20020a056a000a9400b00666840309f4mr17338320pfl.16.1687376407143; Wed, 21 Jun 2023 12:40:07 -0700 (PDT) Received: from yoga ([2400:1f00:13:6258:556c:aad7:2240:7612]) by smtp.gmail.com with ESMTPSA id a20-20020aa780d4000000b0064d47cd117esm3265030pfn.39.2023.06.21.12.40.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Jun 2023 12:40:06 -0700 (PDT) Date: Thu, 22 Jun 2023 01:09:59 +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 2/9] scripts: python: implement add sample function and return finish function Message-ID: <4ded5c271261644c472562f31994830b6a0aefe1.1687375189.git.anupnewsmail@gmail.com> 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 main convertPerfScriptProfile function returns a dictionary with references to the addSample and finish functions, allowing external code to utilize them for profile conversion. This function has few more functions which will be added. The addSample function appends a new entry to the 'samples' data structure. It takes the thread name, stack array, and time as input parameters. 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 infor= mation such as 'tid', 'pid', 'name', 'markers', 'samples', 'frameTable', 'stackTab= le', 'stringTable', 'registerTime', 'unregisterTime', and 'processType'. Signed-off-by: Anup Sharma --- .../scripts/python/firefox-gecko-converter.py | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/tools/perf/scripts/python/firefox-gecko-converter.py b/tools/p= erf/scripts/python/firefox-gecko-converter.py index 73a431d0c7d1..2817d4a96269 100644 --- a/tools/perf/scripts/python/firefox-gecko-converter.py +++ b/tools/perf/scripts/python/firefox-gecko-converter.py @@ -13,3 +13,36 @@ def isPerfScriptFormat(profile): =20 firstLine =3D profile[:profile.index('\n')] return bool(re.match(r'^\S.*?\s+(?:\d+/)?\d+\s+(?:\d+\d+\s+)?[\d.]+:',= firstLine)) + +def convertPerfScriptProfile(profile):=20 + + def addSample(threadName, stackArray, time): + nonlocal name + if name !=3D threadName: + name =3D threadName + # TODO:=20 + # get_or_create_stack will create a new stack if it doesn't ex= ist, or return the existing stack if it does. + # get_or_create_frame will create a new frame if it doesn't ex= ist, or return the existing frame if it does. + stack =3D reduce(lambda prefix, stackFrame: get_or_create_stac= k(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 + } --=20 2.34.1