[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 1/1] scripts/performance: Add dissect.py script
From: |
Eric Blake |
Subject: |
Re: [PATCH 1/1] scripts/performance: Add dissect.py script |
Date: |
Wed, 1 Jul 2020 08:40:52 -0500 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.9.0 |
On 7/1/20 8:04 AM, Ahmed Karaman wrote:
Python script that dissects QEMU execution into three main phases:
code generation, JIT execution and helpers execution.
Syntax:
dissect.py [-h] -- <qemu executable> [<qemu executable options>] \
<target executable> [<target executable options>]
[-h] - Print the script arguments help message.
Example of usage:
dissect.py -- qemu-arm coulomb_double-arm
Given the example usage...
Example output:
Total Instructions: 4,702,865,362
Code Generation: 115,819,309 2.463%
JIT Execution: 1,081,980,528 23.007%
Helpers: 3,505,065,525 74.530%
Signed-off-by: Ahmed Karaman <ahmedkhaledkaraman@gmail.com>
---
scripts/performance/dissect.py | 165 +++++++++++++++++++++++++++++++++
1 file changed, 165 insertions(+)
create mode 100644 scripts/performance/dissect.py
diff --git a/scripts/performance/dissect.py b/scripts/performance/dissect.py
new file mode 100644
...this should have the executable bit set.
+def get_JIT_line(callgrind_data):
+ """
+ Search for the first instance of the JIT call in
+ the callgrind_annoutate output when ran using --tree=caller
annotate
+ This is equivalent to the self number of instructions of JIT.
+
+ Parameters:
+ callgrind_data (list): callgrind_annotate output
+
+ Returns:
+ (int): Line number
+ """
+ line = -1
+ for i in range(len(callgrind_data)):
+ if callgrind_data[i].strip('\n') and \
+ callgrind_data[i].split()[-1] == "[???]":
+ line = i
+ break
+ if line == -1:
+ sys.exit("Couldn't locate the JIT call ... Exiting!")
We tend to avoid ! at the end of error messages (it can come across as
shouting at the user).
+ return line
+
+
+def main():
+ # Parse the command line arguments
+ parser = argparse.ArgumentParser(
+ usage='dissect.py [-h] -- '
+ '<qemu executable> [<qemu executable options>] '
+ '<target executable> [<target executable options>]')
+
+ parser.add_argument('command', type=str, nargs='+', help=argparse.SUPPRESS)
+
+ args = parser.parse_args()
+
+ # Extract the needed variables from the args
+ command = args.command
+
+ # Insure that valgrind is installed
+ check_valgrind = subprocess.run(
+ ["which", "valgrind"], stdout=subprocess.DEVNULL)
+ if check_valgrind.returncode:
+ sys.exit("Please install valgrind before running the script!")
and again
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3226
Virtualization: qemu.org | libvirt.org