Skip to main content

A lightweight toolkit for benchmarking ML model inference performance.

Project description

ModelBenchX

PyPI License Python

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

modelbenchx-1.0.4.tar.gz (5.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

modelbenchx-1.0.4-py3-none-any.whl (7.0 kB view details)

Uploaded Python 3

File details

Details for the file modelbenchx-1.0.4.tar.gz.

File metadata

  • Download URL: modelbenchx-1.0.4.tar.gz
  • Upload date:
  • Size: 5.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.0

File hashes

Hashes for modelbenchx-1.0.4.tar.gz
Algorithm Hash digest
SHA256 2558df7ddcae1798fd4421d851266fe5bdd9b7d023873e8b36d2aa5cfbc98d1a
MD5 f09bd70c1c64acb68129a75a89b7372c
BLAKE2b-256 89c4950dce9a2367b349a632d8aaa4712e66f6d6d2c98fd9a2f0410fc55dfc93

See more details on using hashes here.

File details

Details for the file modelbenchx-1.0.4-py3-none-any.whl.

File metadata

  • Download URL: modelbenchx-1.0.4-py3-none-any.whl
  • Upload date:
  • Size: 7.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.0

File hashes

Hashes for modelbenchx-1.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 c0848e7b7cf10b8999e5a125c97c25b21b395a9c2405d3d7f70b261119e66b7a
MD5 43fa86f6a1217996a8216f7a9d29e268
BLAKE2b-256 b9c0a49b4a66b7f9ec47884cb855a55c819832d82a77911c1233f791cd799cd7

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page