Introduce `json_loads` executions benchmark by moreal · Pull Request #6723 · RustPython/RustPython
This pull request adds a benchmark for the json_loads function under the executions category. The dummy data is the metadata of the psutil package, which is decoded during the pip install pyperf process. I hope it becomes trackable at https://rustpython.github.io/benchmarks.
If there are any changes needed for the benchmark category or the benchmark dummy data, please let me know.
NOTE: This pull request was extracted from PR #6704.
Summary by CodeRabbit
- Chores
- Added JSON loading benchmark script for performance testing.
✏️ Tip: You can customize this high-level summary in your review settings.
📝 Walkthrough
Walkthrough
A new JSON loading benchmark script is added that reads and parses a JSON file from the data directory using the standard library's json module to measure JSON deserialization performance.
Changes
| Cohort / File(s) | Summary |
|---|---|
Benchmark script benches/benchmarks/json_loads.py |
New benchmark script that reads and parses benches/_data/pypi_org__simple__psutil.json using json.loads() to measure JSON deserialization performance. |
Estimated code review effort
🎯 1 (Trivial) | ⏱️ ~2 minutes
Poem
🐰 A JSON file hops in with glee,
Loads parse swift as can be,
With benchmark so keen,
Performance we'll glean,
Speedier parsing for you and me! 📊
🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
| Check name | Status | Explanation |
|---|---|---|
| Description Check | ✅ Passed | Check skipped - CodeRabbit’s high-level summary is enabled. |
| Title check | ✅ Passed | The title clearly and specifically describes the main change: introducing a new benchmark for json_loads executions, which aligns with the PR's objective of adding a json_loads benchmark. |
| Docstring Coverage | ✅ Passed | No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. |
✏️ Tip: You can configure your own custom pre-merge checks in the settings.
✨ Finishing touches
- 📝 Generate docstrings
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Comment @coderabbitai help to get the list of available commands and usage tips.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (2)
benches/benchmarks/json_loads.py (2)
3-4: Consider specifying explicit UTF-8 encoding.JSON files are UTF-8 by specification. Without an explicit
encodingparameter, Python uses the system's default encoding, which may differ on some platforms.Suggested improvement
-with open('benches/_data/pypi_org__simple__psutil.json') as f: +with open('benches/_data/pypi_org__simple__psutil.json', encoding='utf-8') as f: data = f.read()
5-7: Remove extra blank line.PEP 8 recommends a single blank line between logical sections within a module. There are two consecutive blank lines here.
Suggested fix
with open('benches/_data/pypi_org__simple__psutil.json') as f: data = f.read() - loaded = json.loads(data)
📜 Review details
Configuration used: Path: .coderabbit.yml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
benches/_data/pypi_org__simple__psutil.jsonbenches/benchmarks/json_loads.py
🧰 Additional context used
📓 Path-based instructions (1)
**/*.py
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
**/*.py: In most cases, Python code should not be edited; bug fixes should be made through Rust code modifications only
Follow PEP 8 style for custom Python code
Use ruff for linting Python code
Files:
benches/benchmarks/json_loads.py
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (8)
- GitHub Check: Run rust tests (windows-2025)
- GitHub Check: Run rust tests (ubuntu-latest)
- GitHub Check: Run snippets and cpython tests (windows-2025)
- GitHub Check: Run snippets and cpython tests (ubuntu-latest)
- GitHub Check: Ensure compilation on various targets
- GitHub Check: Check the WASM package and demo
- GitHub Check: Check Rust code with clippy
- GitHub Check: Run snippets and cpython tests on wasm-wasi
I hope it becomes trackable at https://rustpython.github.io/benchmarks.
Unfortunately the benches action is currently broken because the microbenchmarks job fails. Therefore, it won't get uploaded to the website until the microbenchmarks job gets fixed. Fixing the microbenchmarks job, however, is likely beyond the scope of this PR.
Unfortunately the benches action is currently broken because the microbenchmarks job fails. Therefore, it won't get uploaded to the website until the microbenchmarks job gets fixed. Fixing the microbenchmarks job, however, is likely beyond the scope of this PR.
I'm fixing the benchmark job in cron-ci workflow in #6724
(Although you've already seen the PR and added revisions, I'm leaving a comment on this PR to preserve context. 😅)
terryluan12 pushed a commit to terryluan12/RustPython that referenced this pull request