Skip to main content

Overview

Proper benchmarking is essential for understanding model performance and making optimization decisions. This guide covers tools, techniques, and best practices for benchmarking ONNX Runtime models.

Benchmarking Tools

1. Python Performance Testing

2. Google Benchmark Integration

ONNX Runtime includes support for Google Benchmark for C++ performance testing:

3. Using run_benchmark.py

ONNX Runtime provides a helper script for stable measurements:
The script runs the benchmark repeatedly until the coefficient of variation is within the desired threshold, ensuring stable and reproducible results.

Throughput Benchmarking

Batch Processing

Multi-threading Throughput

Memory Benchmarking

Memory Usage Tracking

GPU Benchmarking

CUDA Performance

Comparing Execution Providers

Best Practices

1. Always Use Warm-up Iterations

The first few inferences include initialization overhead:

2. Measure Multiple Runs

Single measurements can be misleading:

3. Report Percentiles

Mean latency doesn’t tell the full story:

4. Control System Resources

5. Use Realistic Input Data

Random data may not reflect real-world performance:

Profiling Integration

See Also