A lightweight toolkit for benchmarking ML model inference performance.
Project description
ModelBenchX: ML Inference Benchmarking Toolkit
A lightweight, extensible toolkit for benchmarking ML model inference performance.
ModelBenchX is designed for ML engineers who need quick and reliable measurements of:
- Inference latency
- Throughput (requests/sec)
- Memory usage
- Model performance comparison
- Automated Markdown report generation
🚀 Installation
pip install modelbenchx
🧩 Requirements
Component Version
Python 3.9 -- 3.11 OS Linux, macOS, Windows Dependency psutil
ModelBenchX is continuously tested against:
- Python 3.9\
- Python 3.10\
- Python 3.11
⚡ Quick Example
from modelbench import benchmark_model
import numpy as np
def model(x):
return x * 2
input_data = np.array([1, 2, 3])
results = benchmark_model(model, input_data, runs=200)
print(results)
🔍 Comparing Multiple Models
from modelbench import compare_models
import numpy as np
import time
def fast_model(x):
return x
def slow_model(x):
time.sleep(0.01)
return x
models = {
"FastModel": fast_model,
"SlowModel": slow_model
}
input_data = np.array([1])
results = compare_models(models, input_data, runs=100)
for name, metrics in results.items():
print(name, metrics)
📄 Generate Benchmark Report
from modelbench.report import generate_markdown_report
generate_markdown_report(results)
This creates:
benchmark_report.md
🛠 CLI Usage
Benchmark pickled models directly from the command line:
modelbench --model model.pkl --input input.pkl --runs 200
📐 Benchmarking Methodology
ModelBenchX follows a consistent benchmarking approach:
- Warm-up runs to reduce cold-start bias
- High-resolution timing using
time.perf_counter() - Memory tracking via process RSS measurement
- Throughput calculated as total runs / total execution time
⚠ Microsecond-level latency measurements may include Python loop
overhead.
For production-critical benchmarking, batch benchmarking is recommended
(planned in v1.1).
📦 Versioning & Stability
ModelBenchX follows Semantic Versioning:
- MAJOR → Breaking API changes
- MINOR → New features
- PATCH → Bug fixes & improvements
The public API (benchmark_model, compare_models) is considered
stable as of v1.0.x.
🧪 Testing & CI
ModelBenchX includes automated unit tests covering:
- Core benchmarking engine\
- Model comparison logic\
- Metric structure validation
Continuous Integration runs on:
- Python 3.9\
- Python 3.10\
- Python 3.11
Run tests locally:
pip install -e .
pip install pytest
pytest
🎯 Ideal Use Cases
- Model optimization workflows
- Latency-sensitive systems
- Edge deployment benchmarking
- ML infrastructure experimentation
- Performance regression detection
🗺 Roadmap
v1.1 (Planned)
- Batch size benchmarking
- Peak memory tracking
- JSON + HTML reporting support
- Extended framework adapters (PyTorch / TensorFlow)
Future
- GPU benchmarking support
- Visualization utilities
- Async benchmarking
- Dockerized benchmarking mode
🤝 Contributing
Contributions are welcome.
Please read CONTRIBUTING.md before submitting pull requests.
📜 License
This project is licensed under the MIT License.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file modelbenchx-1.0.5.tar.gz.
File metadata
- Download URL: modelbenchx-1.0.5.tar.gz
- Upload date:
- Size: 6.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
70ec96957f529a3bb0ddd7dcebff1fa07b5f602f8f0951bfa77382974d34544f
|
|
| MD5 |
803b0baabe3525199fbbe4355ef1219c
|
|
| BLAKE2b-256 |
14b7b282f6ff020718ab5f5e258e2a04177a79389d4ef4fa6b81099528ed9b0d
|
File details
Details for the file modelbenchx-1.0.5-py3-none-any.whl.
File metadata
- Download URL: modelbenchx-1.0.5-py3-none-any.whl
- Upload date:
- Size: 7.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d05634af08d6d1fbfa06c2554888db0299f60735d6372e13f6afee9bee3e9f7a
|
|
| MD5 |
57044a35a12a07d1100ebf03a2a9484a
|
|
| BLAKE2b-256 |
050c4f6cce47ded3ca9649428c16e6a5f4902f305b76788f0af5eeb58237bb90
|