Skip to content

Commit f7de933

Browse files
committed
Add SDP CSV to Perfetto JSON converter
Signed-off-by: A, Peixuan (Steven) <peixa@qti.qualcomm.com>
1 parent f8560f2 commit f7de933

14 files changed

Lines changed: 1377 additions & 33 deletions

.gitignore

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Python-generated files
2+
__pycache__/
3+
*.py[oc]
4+
build/
5+
dist/
6+
wheels/
7+
*.egg-info
8+
9+
# Virtual environments
10+
.venv
11+
12+
# Input/output data files
13+
input/
14+
output/

CONTRIBUTING.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
# Contributing to <REPLACE-ME>
1+
# Contributing to Snapdragon Profiler Ecosystem
22

33
Hi there!
4-
Were thrilled that youd like to contribute to this project.
4+
We're thrilled that you'd like to contribute to this project.
55
Your help is essential for keeping this project great and for making it better.
66

77
## Branching Strategy
@@ -11,10 +11,10 @@ In general, contributors should develop on branches based off of `main` and pull
1111
## Submitting a pull request
1212

1313
1. Please read our [code of conduct](CODE-OF-CONDUCT.md) and [license](LICENSE.txt).
14-
1. [Fork](https://github.com/qualcomm/<REPLACE-ME>/fork) and clone the repository.
14+
1. [Fork](https://github.com/SnapdragonGameStudios/Snapdragon_Profiler_Ecosystem/fork) and clone the repository.
1515

1616
```bash
17-
git clone https://github.com/<username>/<REPLACE-ME>.git
17+
git clone https://github.com/<username>/Snapdragon_Profiler_Ecosystem.git
1818
```
1919

2020
1. Create a new branch based on `main`:
@@ -26,7 +26,7 @@ In general, contributors should develop on branches based off of `main` and pull
2626
1. Create an upstream `remote` to make it easier to keep your branches up-to-date:
2727

2828
```bash
29-
git remote add upstream https://github.com/qualcomm/<REPLACE-ME>.git
29+
git remote add upstream https://github.com/SnapdragonGameStudios/Snapdragon_Profiler_Ecosystem.git
3030
```
3131

3232
1. Make your changes, add tests, and make sure the tests still pass.
@@ -50,7 +50,7 @@ In general, contributors should develop on branches based off of `main` and pull
5050

5151
The `-u` is shorthand for `--set-upstream`. This will set up the tracking reference so subsequent runs of `git push` or `git pull` can omit the remote and branch.
5252

53-
1. [Submit a pull request](https://github.com/qualcomm/<REPLACE-ME>/pulls) from your branch to `main`.
53+
1. [Submit a pull request](https://github.com/SnapdragonGameStudios/Snapdragon_Profiler_Ecosystem/pulls) from your branch to `main`.
5454
1. Pat yourself on the back and wait for your pull request to be reviewed.
5555

5656
## Security Analysis of Pull Requests
@@ -68,9 +68,9 @@ By submitting a PR, you agree to participate in this process and help us keep th
6868

6969
Here are a few things you can do that will increase the likelihood of your pull request to be accepted:
7070

71-
- Follow the existing style where possible. **INSERT LINK TO STYLE, e.g. PEP8 for python**
71+
- Follow the existing style where possible. See [PEP 8](https://peps.python.org/pep-0008/) for Python coding style guidelines.
7272
- Write tests.
7373
- Keep your change as focused as possible.
7474
If you want to make multiple independent changes, please consider submitting them as separate pull requests.
7575
- Write a [good commit message](https://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html).
76-
- It's a good idea to arrange a discussion with other developers to ensure there is consensus on large features, architecture changes, and other core code changes. PR reviews will go much faster when there are no surprises.
76+
- It's a good idea to arrange a discussion with other developers to ensure there is consensus on large features, architecture changes, and other core code changes. PR reviews will go much faster when there are no surprises.

LICENSE.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,6 @@ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
2323
BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
2424
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
2525
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
26-
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26+
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27+
28+
SPDX-License-Identifier: BSD-3-Clause

README.md

Lines changed: 91 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,115 @@
1-
**After repository creation:**
2-
- [ ] Update this `README.md`. Update the Project Name, description, and all sections. Remove this checklist.
3-
- [ ] If required, update `LICENSE.txt` and the License section with your project's approved license
4-
- [ ] Search this repo for "REPLACE-ME" and update all instances accordingly
5-
- [ ] Update `CONTRIBUTING.md` as needed
6-
- [ ] Review the workflows in `.github/workflows`, updating as needed. See https://docs.github.com/en/actions for information on what these files do and how they work.
7-
- [ ] Review and update the suggested Issue and PR templates as needed in `.github/ISSUE_TEMPLATE` and `.github/PULL_REQUEST_TEMPLATE`
1+
# Snapdragon Profiler Ecosystem
82

9-
# Project Name
10-
11-
*\<update with your project name and a short description\>*
12-
13-
Project that does ... implemented in ... runs on Qualcomm® *\<processor\>*
3+
A collection of tools for working with [Snapdragon Profiler (SDP)](https://developer.qualcomm.com/software/snapdragon-profiler).
144

155
## Branches
166

177
**main**: Primary development branch. Contributors should develop submissions based on this branch, and submit pull requests to this branch.
188

19-
## Requirements
9+
## Available Tools
10+
11+
### Converter
12+
13+
Convert SDP exported CSV trace files into [Perfetto](https://ui.perfetto.dev/) compatible JSON format for visualization and analysis.
14+
This converter supports CSV files exported from both SDP capture modes:
2015

21-
List requirements to run the project, how to install them, instructions to use docker container, etc...
16+
- **Realtime Capture Mode** — Streaming/live capture sessions where metrics are recorded continuously in real time
17+
- **Trace Capture Mode** — Full trace sessions with detailed scheduling, slice, and counter data captured over a defined time window
18+
19+
#### Supported Event Types
20+
21+
| CSV Row Type | Perfetto Phase | Description |
22+
|---|---|---|
23+
| System counters | `"ph": "C"` | System-level metrics (CPU frequency, GPU metrics, DSP metrics) |
24+
| Process counters | `"ph": "C"` | Per-process counter values (e.g., `aaRdy`, GPU Rendering Pipe Metrics) |
25+
| Process slices | `"ph": "X"` | Duration events with start/end timestamps |
26+
| System scheduling slices | `"ph": "X"` | Kernel scheduling events (e.g., Sched CPU) |
27+
| Metadata | `"ph": "M"` | Auto-generated `process_name` and `thread_name` labels |
2228

2329
## Installation Instructions
2430

25-
How to install the software itself.
31+
```bash
32+
# Install uv (if not already installed)
33+
# Windows
34+
powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"
35+
36+
# macOS / Linux
37+
curl -LsSf https://astral.sh/uv/install.sh | sh
38+
39+
# Sync the project (creates virtual environment and installs dependencies)
40+
uv sync
41+
```
2642

2743
## Usage
2844

29-
Describe how to use the project.
45+
All tools are accessible through the unified `main.py` entry point:
46+
47+
```bash
48+
# Show available tools
49+
uv run main.py --help
50+
51+
# Run a specific tool (e.g., converter)
52+
uv run main.py converter <tool-specific arguments ...>
53+
```
54+
55+
### Converter Examples
56+
57+
```bash
58+
# Single file (output: trace1.json)
59+
uv run main.py converter trace1.csv
60+
61+
# Single file with custom output name
62+
uv run main.py converter trace1.csv -o custom_output.json
63+
64+
# Multiple files (each gets its own .json: trace1.json, trace2.json, trace3.json)
65+
uv run main.py converter trace1.csv trace2.csv trace3.csv
66+
67+
# All CSV files in the current directory
68+
uv run main.py converter *.csv
69+
70+
# Output to a specific directory
71+
uv run main.py converter *.csv --output-dir ./output/
72+
```
73+
74+
You can also invoke the converter directly (bypassing the dispatcher):
75+
76+
```bash
77+
uv run python -m tools.converter.convert_sdp_csv_to_perfetto_json trace1.csv
78+
```
3079

3180
## Development
3281

33-
How to develop new features/fixes for the software. Maybe different than "usage". Also provide details on how to contribute via a [CONTRIBUTING.md file](CONTRIBUTING.md).
82+
To contribute new features or fixes, please see [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines on branching, submitting pull requests, and coding standards.
3483

35-
## Getting in Contact
84+
```bash
85+
# Clone the repository
86+
git clone https://github.com/SnapdragonGameStudios/Snapdragon_Profiler_Ecosystem.git
87+
cd Snapdragon_Profiler_Ecosystem
88+
89+
# Sync the project (creates virtual environment and installs dev dependencies)
90+
uv sync
91+
```
92+
93+
## Testing
3694

37-
How to contact maintainers. E.g. GitHub Issues, GitHub Discussions could be indicated for many cases. However a mail list or list of Maintainer e-mails could be shared for other types of discussions. E.g.
95+
The project includes a comprehensive test suite using pytest.
96+
97+
```bash
98+
# Run all tests
99+
uv run pytest
100+
101+
# Run tests with verbose output
102+
uv run pytest -v
103+
104+
# Run a specific test class
105+
uv run pytest tests/test_convert_sdp_csv_to_perfetto_json.py::TestExampleCSV -v
106+
```
107+
108+
## Getting in Contact
38109

39110
* [Report an Issue on GitHub](../../issues)
40111
* [Open a Discussion on GitHub](../../discussions)
41-
* [E-mail us](mailto:REPLACE-ME@qti.qualcomm.com) for general questions
42112

43113
## License
44114

45-
*\<update with your project name and license\>*
46-
47-
*\<REPLACE-ME\>* is licensed under the [BSD-3-clause License](https://spdx.org/licenses/BSD-3-Clause.html). See [LICENSE.txt](LICENSE.txt) for the full license text.
115+
*Snapdragon Profiler Ecosystem* is licensed under the [BSD-3-clause License](https://spdx.org/licenses/BSD-3-Clause.html). See [LICENSE.txt](LICENSE.txt) for the full license text.

SECURITY.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ How to Report a Potential Vulnerability?
33

44
If you would like to report a public issue (for example, one with a released
55
CVE number), please report it as a
6-
[GitHub issue](https://github.com/qualcomm/REPLACE-ME/issues/new).
6+
[GitHub issue](https://github.com/SnapdragonGameStudios/Snapdragon_Profiler_Ecosystem/issues/new).
77
If you have a patch ready, submit it following the same procedure as any
88
other patch as described in [CONTRIBUTING.md](CONTRIBUTING.md).
99

main.py

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# ============================================================================================================
2+
#
3+
# Copyright (c) 2023, Qualcomm Innovation Center, Inc. All rights reserved.
4+
# SPDX-License-Identifier: BSD-3-Clause
5+
#
6+
# ============================================================================================================
7+
8+
9+
"""Snapdragon Profiler Ecosystem – unified CLI entry point.
10+
11+
Usage:
12+
python main.py <tool> [tool-specific arguments ...]
13+
14+
Available tools are registered in TOOLS_REGISTRY below. To add a new tool,
15+
simply create a module under ``tools/`` with a ``main()`` function that uses
16+
``argparse``, then add one line to the registry mapping.
17+
18+
Examples:
19+
python main.py converter input.csv -o output.json
20+
python main.py converter input1.csv input2.csv --output-dir output/
21+
"""
22+
23+
import importlib
24+
import sys
25+
26+
# ---------------------------------------------------------------------------
27+
# Tool registry – maps CLI name → dotted module path.
28+
# Each module MUST expose a ``main()`` function (using argparse internally).
29+
# ---------------------------------------------------------------------------
30+
TOOLS_REGISTRY: dict[str, str] = {
31+
"converter": "tools.converter.convert_sdp_csv_to_perfetto_json",
32+
}
33+
34+
35+
def main():
36+
if len(sys.argv) < 2 or sys.argv[1] in ("-h", "--help"):
37+
_print_help()
38+
sys.exit(0)
39+
40+
tool_name = sys.argv[1]
41+
42+
if tool_name not in TOOLS_REGISTRY:
43+
print(f"Error: Unknown tool '{tool_name}'.")
44+
print(f"Available tools: {', '.join(sorted(TOOLS_REGISTRY))}")
45+
sys.exit(1)
46+
47+
module_path = TOOLS_REGISTRY[tool_name]
48+
module = importlib.import_module(module_path)
49+
50+
# Remove the dispatcher's own argv[0] and the tool name so the tool's
51+
# argparse sees only its own arguments.
52+
sys.argv = [f"main.py {tool_name}"] + sys.argv[2:]
53+
module.main()
54+
55+
56+
def _print_help():
57+
print("Snapdragon Profiler Ecosystem – unified CLI entry point\n")
58+
print("Usage: python main.py <tool> [tool-specific arguments ...]\n")
59+
print("Available tools:")
60+
for name, mod in sorted(TOOLS_REGISTRY.items()):
61+
print(f" {name:20s}{mod}")
62+
print("\nPass -h/--help after a tool name for tool-specific help.")
63+
print("Example: python main.py converter --help")
64+
65+
66+
if __name__ == "__main__":
67+
main()

pyproject.toml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
[project]
2+
name = "snapdragon_profiler_ecosystem"
3+
version = "2026.04"
4+
description = "Snapdragon Profiler Ecosystem – a collection of tools for working with Snapdragon Profiler (SDP) data"
5+
readme = "README.md"
6+
requires-python = ">=3.13"
7+
dependencies = []
8+
9+
[project.scripts]
10+
snapdragon-profiler-ecosystem = "main:main"
11+
sdp-csv-to-perfetto-json = "tools.converter.convert_sdp_csv_to_perfetto_json:main"
12+
13+
[dependency-groups]
14+
dev = ["pytest>=8.0"]

test_main.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# ============================================================================================================
2+
#
3+
# Copyright (c) 2023, Qualcomm Innovation Center, Inc. All rights reserved.
4+
# SPDX-License-Identifier: BSD-3-Clause
5+
#
6+
# ============================================================================================================
7+
8+
"""Backward-compatible test entry point.
9+
10+
The test suite has moved to tests/test_convert_sdp_csv_to_perfetto_json.py.
11+
This wrapper re-exports everything so that ``pytest test_main.py`` still works.
12+
"""
13+
14+
from tests.test_convert_sdp_csv_to_perfetto_json import * # noqa: F401,F403

tests/__init__.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# ============================================================================================================
2+
#
3+
# Copyright (c) 2023, Qualcomm Innovation Center, Inc. All rights reserved.
4+
# SPDX-License-Identifier: BSD-3-Clause
5+
#
6+
# ============================================================================================================
7+
8+
# tests package

0 commit comments

Comments
 (0)