From nobody Sat Feb 7 06:12:59 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1592349244; cv=none; d=zohomail.com; s=zohoarc; b=lXx72hn7AN+5+J4K4/WolWZUhRN9IAAYhycMymEMoFYOGcjV4mN2uCQ6Qtbzp+dGBI+Mp+II/AtLLuyHwmfxJ6XgWecFNaYTjEd+OserkjRnuWnK8mHY+RDgUGScP/l4EuQBzv6FXUy/yRFX/pG2DmJxksTSEiUeeaUVEu7+Gok= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1592349244; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=J6ZyVPWxE4rUpNMsUOcvfAQU0YaltDpuLYEOTXm+nBw=; b=eo1VH91shsxjzuQc1uSl2SzwhfSVea6Yo1j4Me5av0iRC1GDd4yaBn8k3L8JYdp/Idlt/QuZTeeBJGqSecB21q79mDodNv8J7lzfZQ4RG5raKQ2CYjucqGY0ARF0XsKE6U/8U6tFHOmMhoCoKEmUfBP+Kian8zGQXjpaKWD0diw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1592349244905553.5134089928652; Tue, 16 Jun 2020 16:14:04 -0700 (PDT) Received: from localhost ([::1]:44918 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jlKmJ-0003q0-Aj for importer@patchew.org; Tue, 16 Jun 2020 19:14:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54242) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jlKlH-0002WS-Rv for qemu-devel@nongnu.org; Tue, 16 Jun 2020 19:12:59 -0400 Received: from mail-wm1-x344.google.com ([2a00:1450:4864:20::344]:39119) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jlKlG-0006uF-Df for qemu-devel@nongnu.org; Tue, 16 Jun 2020 19:12:59 -0400 Received: by mail-wm1-x344.google.com with SMTP id t194so88682wmt.4 for ; Tue, 16 Jun 2020 16:12:58 -0700 (PDT) Received: from AK-L.domain.name ([197.58.89.86]) by smtp.gmail.com with ESMTPSA id o9sm2384226wrs.1.2020.06.16.16.12.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Jun 2020 16:12:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=J6ZyVPWxE4rUpNMsUOcvfAQU0YaltDpuLYEOTXm+nBw=; b=NPs992HuvCRmWPp97bKClU5zyJ9dYklHXZlnoRjeRVrTX/jtFPUsdpBCDsxwHaFx6y GE/B2+KcPHHtymgxFh3WDUUE3xlXvlu+HBaah1AWuKvMZaXk0FZSMaIm8qToZYPdZjj2 Rvh8bhsHg0o92uRczKsc54Au2Um8WCoZElnnO3j4lLyyG3vlZ4kSsjds9JftfMmSqTVJ DzuoOjO/UmMhl51Fg/w3sgU3L1dYzgCWp3JSlC07OnZQz/i8m3ShhrCibS3GraxRU73d yPDipNC8LD4RtPJWPeM9yM3aYpRKF1Kg2Ouux+G5afroDYfgKqnzMHWNLLILpC1TCh9+ ZWrA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=J6ZyVPWxE4rUpNMsUOcvfAQU0YaltDpuLYEOTXm+nBw=; b=pkYZykdaNS14yE2EMSihLpZiN31bLXEEUhmMwwD1jw6dhRopOFM9SWalwOxrNayl/F 3ZgPIt/+sddBn9ncsI1JDTokfNq0J2Eyt4Pdfw62jpYHUf9qsxgQzWARLWrwa3r74WUC XQ5WXrKxgA9WVYURzw9edsgBxd5B/I3xqQUJZLnW7TYrsPpivMdqiyLZtLuH46P4l2z1 7nbYM8XniMiMVipudoRckJjbFgKwSat6SwOlAPDOlCJqGO0XrUx/t9yIaXNQYnMyhAr+ /gInBLIwe2KsDdPv2ac/8T84fifCGe6gyHwhixE3gr20EfLy94muPxcqw0tssxnWSOXO pQsA== X-Gm-Message-State: AOAM533VYt+b1OUYFRax378OEZ675EE+tOq7vAo0u8GTcVgfpvI2kax8 48vUq2sEkQ8ZPyvuFsHq/9/f2h5qwIU= X-Google-Smtp-Source: ABdhPJx2IBnHr1A13sYggnwPRN+i3kFokqrVuY1lshd9gLGGju3In+2/UfmQxbV3o09nx6xwe8I/Sg== X-Received: by 2002:a7b:cc08:: with SMTP id f8mr5772413wmh.106.1592349176891; Tue, 16 Jun 2020 16:12:56 -0700 (PDT) From: Ahmed Karaman To: qemu-devel@nongnu.org, rth@twiddle.net, aleksandar.qemu.devel@gmail.com, alex.bennee@linaro.org, eblake@redhat.com, ldoktor@redhat.com, ehabkost@redhat.com, crosa@redhat.com Subject: [PATCH 1/3] MAINTAINERS: Add 'Miscellaneous' section Date: Wed, 17 Jun 2020 01:12:02 +0200 Message-Id: <20200616231204.8850-2-ahmedkhaledkaraman@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200616231204.8850-1-ahmedkhaledkaraman@gmail.com> References: <20200616231204.8850-1-ahmedkhaledkaraman@gmail.com> Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::344; envelope-from=ahmedkhaledkaraman@gmail.com; helo=mail-wm1-x344.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ahmed Karaman Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @gmail.com) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" This new section includes the 'Performance Tools and Tests' subsection which will contain the the performance scripts and benchmarks written as a part of the 'TCG Continuous Benchmarking' project. Signed-off-by: Ahmed Karaman Reviewed-by: Alex Benn=C3=A9e --- MAINTAINERS | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index 955cc8dd5c..68f668ae2a 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -2974,3 +2974,10 @@ M: Peter Maydell S: Maintained F: docs/conf.py F: docs/*/conf.py + +Miscellaneous +------------- +Performance Tools and Tests +M: Ahmed Karaman +S: Maintained +F: scripts/performance/ \ No newline at end of file --=20 2.17.1 From nobody Sat Feb 7 06:12:59 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1592349267; cv=none; d=zohomail.com; s=zohoarc; b=RLJ3szDGmHjXfg1PgTqp3HYyRWFmCiJrLypxl4JW10AbG9AEvgeflACkXMbdHK108tocVmMl5JDO1v4hL8MD2PzXZft2y9+08KuKr9zCPOtn05QQVaf9iKl0vh1r56suZv21inqrb4UyO0AYhNA/JPT2xbGhm6ky3Pg/SEsCoaw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1592349267; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=ClO0YbMLxFK4IoNk8Xcwu72VrPPnrLf9XqnoMALXakg=; b=WMoCnBkUWrUm4rTycI0KAfKRtiDhUwQfEk4rsaN439s57EqoQef8QzH6z7gIl4NVnaCIvfRHUKPBivANzvo5ihSWsBUWtpM93EpCDvsc8GCveZHQhTgUsBGeZf6DhNcgcXvE/1B2TRdExzynRQBMsCXZ4d+OpcYBl0H2Z/yt0a0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1592349267380104.71469565650068; Tue, 16 Jun 2020 16:14:27 -0700 (PDT) Received: from localhost ([::1]:46330 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jlKmg-0004ga-2U for importer@patchew.org; Tue, 16 Jun 2020 19:14:26 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54274) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jlKlV-0002uA-Fo for qemu-devel@nongnu.org; Tue, 16 Jun 2020 19:13:13 -0400 Received: from mail-wr1-x42f.google.com ([2a00:1450:4864:20::42f]:41277) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jlKlT-0006vB-In for qemu-devel@nongnu.org; Tue, 16 Jun 2020 19:13:13 -0400 Received: by mail-wr1-x42f.google.com with SMTP id j10so341533wrw.8 for ; Tue, 16 Jun 2020 16:13:11 -0700 (PDT) Received: from AK-L.domain.name ([197.58.89.86]) by smtp.gmail.com with ESMTPSA id o9sm2384226wrs.1.2020.06.16.16.13.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Jun 2020 16:13:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=ClO0YbMLxFK4IoNk8Xcwu72VrPPnrLf9XqnoMALXakg=; b=FcTBWhbiAuTS3aQck2Rv1xN71br3x/y5lDhn4fbGPXEORqgMmS1ap1uN/S5ORNJqcM OS4qYTxbb/bbBO+wzMJgZU8B48Q17ilULwaSRsyimXzOO3um+Vs7kk7WrdzTxtkuObwo dwhk2GkXuUbH13mfbp5EpUR0pIygR5l272BHCxXbtmO5WYno1lme5V7blaP/yq7c3in3 COPKmusuWOUN1vz+KxsdfdW9aDoV5+CqlTtvV4+AkERBT6Lz+p8KLKMMeWGQ3a1SrNdi m+TpzdF5b//B93hSyqnaOr/JVuDt4/+GSw5EOoQFlA79KcKyNcmmeuWSAkzKs2UHw0D2 OnTQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=ClO0YbMLxFK4IoNk8Xcwu72VrPPnrLf9XqnoMALXakg=; b=kV233tpgXDnWvv0IW36LH2fhEaJJ7vX8gZhV9fqMzDtDoVRWaC/IXJXCfDnMsKwc18 hhzhaAhf+DgDxB4ciub9MIfVrl6DzuEvUnBs2wXxQv8LK2QlnGiqC5UZt5nIvoWX9UNl FVcTqQouDbLofyW5hqwO81OyM6MeVYv6hNStW9S73OTP9kamVOKjV5AKnblB/GNc0QWN 140+L4biyhujI5jq5MZoCeFs38c/CL7ycdyhTaKKVLk36umiMZTmT6ehDhOZ/WcJubw7 oEJkSjTFYOETcvF1U4ufufClugzNRVjKymlIvrC0ybyLuvyZqZSfXEWZK5dY9ZElR/eE l7Mw== X-Gm-Message-State: AOAM533hhxFH+q30YLkRZ0K47zoESGCcMqfOBAAu5sxa7JTx0nL4q5ve SNaEMoUfjSRgLaqE9N+G+qkNiI1YmzI= X-Google-Smtp-Source: ABdhPJx9UNcwQD+tNZkvtiw+L/LLheQd0grcNIZ+SaN65caeEM43IjtSAQQcmG75WBtGmeKdvKMuKA== X-Received: by 2002:a5d:468d:: with SMTP id u13mr5659423wrq.73.1592349189716; Tue, 16 Jun 2020 16:13:09 -0700 (PDT) From: Ahmed Karaman To: qemu-devel@nongnu.org, rth@twiddle.net, aleksandar.qemu.devel@gmail.com, alex.bennee@linaro.org, eblake@redhat.com, ldoktor@redhat.com, ehabkost@redhat.com, crosa@redhat.com Subject: [PATCH 2/3] scripts/performance: Add callgrind_top_25.py script Date: Wed, 17 Jun 2020 01:12:03 +0200 Message-Id: <20200616231204.8850-3-ahmedkhaledkaraman@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200616231204.8850-1-ahmedkhaledkaraman@gmail.com> References: <20200616231204.8850-1-ahmedkhaledkaraman@gmail.com> Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::42f; envelope-from=ahmedkhaledkaraman@gmail.com; helo=mail-wr1-x42f.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ahmed Karaman Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @gmail.com) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Python script that prints the top 25 most executed functions in QEMU using callgrind. Signed-off-by: Ahmed Karaman --- scripts/performance/callgrind_top_25.py | 95 +++++++++++++++++++++++++ 1 file changed, 95 insertions(+) create mode 100644 scripts/performance/callgrind_top_25.py diff --git a/scripts/performance/callgrind_top_25.py b/scripts/performance/= callgrind_top_25.py new file mode 100644 index 0000000000..03b089a96d --- /dev/null +++ b/scripts/performance/callgrind_top_25.py @@ -0,0 +1,95 @@ +#!/usr/bin/env python3 + +# Print the top 25 most executed functions in QEMU using callgrind. +# Example Usage: +# callgrind_top_25.py /x86_64-linux-user/qemu-x86_64 executab= le +# +# This file is a part of the project "TCG Continuous Benchmarking". +# +# Copyright (C) 2020 Ahmed Karaman +# Copyright (C) 2020 Aleksandar Markovic +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +import os +import sys + +# Ensure sufficient arguments +if len(sys.argv) < 3: + print('Insufficient Script Arguments!') + sys.exit(1) + +# Get the qemu path and the executable + its arguments +(qemu, executable) =3D (sys.argv[1], ' '.join(sys.argv[2:])) + +# Run callgrind and callgrind_annotate +os.system('valgrind --tool=3Dcallgrind --callgrind-out-file=3Dcallgrind.da= ta {} {} \ + 2 > / dev / null & & callgrind_annotate callgrind.data \ + > tmp.callgrind.data'. + format(qemu, executable)) + +# Line number with the total number of instructions +number_of_instructions_line =3D 20 + +# Line number with the top function +first_func_line =3D 25 + +# callgrind_annotate output +callgrind_data =3D [] + +# Open callgrind_annotate output and store it in callgrind_data +with open('tmp.callgrind.data', 'r') as data: + callgrind_data =3D data.readlines() + +# Get the total number of instructions +total_number_of_instructions =3D int( + callgrind_data[number_of_instructions_line].split(' ')[0].replace(',',= '')) + +# Number of functions recorded by callgrind +number_of_functions =3D len(callgrind_data) - first_func_line + +# Limit the number of top functions to 25 +number_of_top_functions =3D (25 if number_of_functions > + 25 else number_of_instructions_line) + +# Store the data of the top functions in top_functions[] +top_functions =3D callgrind_data[first_func_line: + first_func_line + number_of_top_functions] +# Print information headers +print('{:>4} {:>10} {:<25} {}\n{} {} {} {}'.format('No.', + 'Percentage', + 'Name', + 'Source File', + '-' * 4, + '-' * 10, + '-' * 25, + '-' * 30, + )) + +# Print top 25 functions +for (index, function) in enumerate(top_functions, start=3D1): + function_data =3D function.split() + # Calculate function percentage + percentage =3D (float(function_data[0].replace( + ',', '')) / total_number_of_instructions) * 100 + # Get function source path and name + path, name =3D function_data[1].split(':') + # Print extracted data + print('{:>4} {:>9.3f}% {:<25} {}'.format(index, + round(percentage, 3), + name, + path)) + +# Remove intermediate files +os.system('rm callgrind.data tmp.callgrind.data') --=20 2.17.1 From nobody Sat Feb 7 06:12:59 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1592349325; cv=none; d=zohomail.com; s=zohoarc; b=m4IMjVba0Iapmcu96wblFP0xCVZ/IpGRrO8CyuPEjImq+M+HTq6zSWmm2akOIPySRrqDk5ONyZkgDivQHSVUMIgpusDI3VjD1wODt+xvpE9WlFFb1JMhdPQBYUANBSFwGjcOwsjrc6BRNSYljJ+zdgXElpyoHohDXWrSSnRLvAM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1592349325; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=t3VP6WWaLEUXrw5hSPEQzC1W88S05EoRcbRI+Zf7OEE=; b=E7tr2iBqdqFII7WbNkAOPQbSgQ2CTDUZ7PL6xsjcNqD2UPJkcJb1PbrP+UtNwfZnaJFKW8TtXCjQaT1xNv800H+k9Vlttw4x0jkloVP3HHtkNvNYriEZCxeV/JIOU72FqlH643+OMUgujoQD4tv8XkusFsPPwVQ1R2+rL6dZNBY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1592349325562367.0928449210504; Tue, 16 Jun 2020 16:15:25 -0700 (PDT) Received: from localhost ([::1]:49756 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jlKnc-00064x-Cz for importer@patchew.org; Tue, 16 Jun 2020 19:15:24 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54310) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jlKla-000341-Qd for qemu-devel@nongnu.org; Tue, 16 Jun 2020 19:13:18 -0400 Received: from mail-wr1-x434.google.com ([2a00:1450:4864:20::434]:44100) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jlKlZ-0006wn-1C for qemu-devel@nongnu.org; Tue, 16 Jun 2020 19:13:18 -0400 Received: by mail-wr1-x434.google.com with SMTP id b6so329103wrs.11 for ; Tue, 16 Jun 2020 16:13:16 -0700 (PDT) Received: from AK-L.domain.name ([197.58.89.86]) by smtp.gmail.com with ESMTPSA id o9sm2384226wrs.1.2020.06.16.16.13.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Jun 2020 16:13:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=t3VP6WWaLEUXrw5hSPEQzC1W88S05EoRcbRI+Zf7OEE=; b=G7/89ryh/FU+6PVotPSJOhs8ymD5/zqFU4jby/um/RijMhiuoZcw0/4j0CZItTCvP3 c8KILQH6c9jnHEqv32p1qWxWqrT8OnFJGXzHSE4wqwLmGK5j6lELr5rgA/z+RbLEKddB m8A6xQ7IzAjHeGjF+TjMPIIL3bwC91w1d/FHSVYOzSmP0UetmwcuSZdCsSwVYr4bC54a i5htcySduGVxeWZ1TStXWE25GNT0MUreAh0mTOQ6rTalFjFqHL42KRRopqvQQX33TX72 IYfa0Ka6mipyyxa4+DCA01tuHOgfqZLpkTRugG42daD5sKZ32ssnUNvgJRlT75UOb9ro 84uw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=t3VP6WWaLEUXrw5hSPEQzC1W88S05EoRcbRI+Zf7OEE=; b=dODol49pr31OeUeKt2ej88DFSANoHF+mfBHTXwG90Ec7WVtTaYzXRGSpZU2hRRvaLe 2cWNl+IAFrJYmsmsHCYQ4UpkJqM0SCAkg5A9NXGKeTz5qqXgoaFN2uk2xeEMyj5AqHQu XykfZhDQcreefpHQ0xHTNvSACTcsmg3Nkk/ianpzMnM2fh9MZiLX22inacWCxZPVUGHP fw/Boh13sKQLrBs+AjiJwR627Fz2aSMhHojy25QfbYWUNQhsIO0ca8igOf9zfALOZ0u5 cA+12q5wbw382o22gVuX9HjeRJYTWjZ9FZeVswGSaFRJ4tcFQXuDpeLh8ML5dSadgZDC C8Bg== X-Gm-Message-State: AOAM531XSLt3zIMagT/sUsWKle4c1FvEimu3F1dGBa+Ff/pyTt6ItbWw vtNNlPpTjJrXOHpITJHkV5S1GPYhNcQ= X-Google-Smtp-Source: ABdhPJxC3RU2gkoYY68FJZnGIBh8uw/Zo+OEXUUD3FlTTmOCpVklYCF4YC1gdTBHQ/WKUsIqtfnSBw== X-Received: by 2002:a05:6000:1185:: with SMTP id g5mr5715494wrx.39.1592349195486; Tue, 16 Jun 2020 16:13:15 -0700 (PDT) From: Ahmed Karaman To: qemu-devel@nongnu.org, rth@twiddle.net, aleksandar.qemu.devel@gmail.com, alex.bennee@linaro.org, eblake@redhat.com, ldoktor@redhat.com, ehabkost@redhat.com, crosa@redhat.com Subject: [PATCH 3/3] scripts/performance: Add perf_top_25.py script Date: Wed, 17 Jun 2020 01:12:04 +0200 Message-Id: <20200616231204.8850-4-ahmedkhaledkaraman@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200616231204.8850-1-ahmedkhaledkaraman@gmail.com> References: <20200616231204.8850-1-ahmedkhaledkaraman@gmail.com> Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::434; envelope-from=ahmedkhaledkaraman@gmail.com; helo=mail-wr1-x434.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ahmed Karaman Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @gmail.com) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Python script that prints the top 25 most executed functions in QEMU using perf. Signed-off-by: Ahmed Karaman --- scripts/performance/perf_top_25.py | 82 ++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 scripts/performance/perf_top_25.py diff --git a/scripts/performance/perf_top_25.py b/scripts/performance/perf_= top_25.py new file mode 100644 index 0000000000..eaa8cce3c3 --- /dev/null +++ b/scripts/performance/perf_top_25.py @@ -0,0 +1,82 @@ +#!/usr/bin/env python3 + +# Print the top 25 most executed functions in QEMU using perf. +# Example Usage: +# perf_top_25.py /x86_64-linux-user/qemu-x86_64 executable +# +# This file is a part of the project "TCG Continuous Benchmarking". +# +# Copyright (C) 2020 Ahmed Karaman +# Copyright (C) 2020 Aleksandar Markovic +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +import os +import sys + +# Ensure sufficient arguments +if len(sys.argv) < 3: + print('Insufficient Script Arguments!') + sys.exit(1) + +# Get the qemu path and the executable + its arguments +(qemu_path, executable) =3D (sys.argv[1], ' '.join(sys.argv[2:])) + +# Run perf repcord and report +os.system('sudo perf record {} {} 2> /dev/null \ + && sudo perf report --stdio > tmp.perf.data' + .format(qemu_path, executable)) + +# Line number with the top function +first_func_line =3D 11 + +# Perf report output +perf_data =3D [] + +# Open perf report output and store it in perf_data +with open('tmp.perf.data', 'r') as data: + perf_data =3D data.readlines() + +# Number of functions recorded by perf +number_of_functions =3D len(perf_data) - first_func_line + +# Limit the number of top functions to 25 +number_of_top_functions =3D (25 if number_of_functions > + 25 else number_of_functions) + +# Store the data of the top functions in top_functions[] +top_functions =3D perf_data[first_func_line:first_func_line + + number_of_top_functions] + +# Print information headers +print('{:>4} {:>10} {:<25} {}\n{} {} {} {}'.format('No.', + 'Percentage', + 'Name', + 'Caller', + '-' * 4, + '-' * 10, + '-' * 25, + '-' * 25, + )) + +# Print top 25 functions +for (index, function) in enumerate(top_functions, start=3D1): + function_data =3D function.split() + print('{:>4} {:>10} {:<25} {}'.format(index, + function_data[0], + function_data[-1], + ' '.join(function_data[2:-2])= )) + +# Remove intermediate files +os.system('sudo rm perf.data tmp.perf.data') --=20 2.17.1