Rate This Document
Findability
Accuracy
Completeness
Readability

Python/C Profiler Functions

The Python/C Profiler is used on the Kunpeng platform. It can be used to analyze Python programs and Python & C/C++ hybrid programs when performance bottlenecks occur. The tool helps identify hotspot functions, enabling you to quickly locate code issues and improve program performance.

Prerequisites

  • The Python/C Profiler has been installed. See Installing the Tool.
  • If you have installed the tool using a compressed package, decompress the package and switch to the tool directory. Then run the command in ./ mode, for example, ./devkit py-perf -h. If you have installed the tool using an RPM package, run devkit py-perf -h. This section uses an RPM package as an example.

Command Function

Uses ptrace to sample Python programs and Python & C/C++ hybrid programs, analyzes call stacks, obtains top 20 hotspot functions, and draws flame graphs.

Syntax

1
devkit py-perf [-h | --help] TASK [ARGS]

Example

View the information about Python/C performance analysis functions:

1
devkit py-perf -h

Command output:

1
2
3
4
5
6
7
 Usage: devkit py-perf [-h | --help] TASK [ARGS]

 The most commonly used devkit py-perf sub tasks are:
   help      Get help information
   hotspot   Run the hotspot collection and analysis task

 See 'devkit py-perf TASK --help' for more information on a specific task.
Table 1 Function description

Subcommand

Function

Description

help

Displays help information.

-

hotspot

Python/C performance hotspot analysis.

The tool uses ptrace to sample Python programs and Python & C/C++ hybrid programs, analyzes call stacks, obtains top 20 hotspot functions, and draws flame graphs.