How to Measure AI Device Performance, Power, and Latency
In this article
Measuring an AI device's performance, power use, and latency is essential for comparing hardware, tuning models, and estimating deployment costs. This guide walks you through a practical benchmarking process that works for edge devices, phones, and small servers. You'll need the device itself, a way to run inference workloads, and a few free tools to capture metrics.
What You'll Need
- The AI device (phone, Raspberry Pi, Jetson, or similar) with its OS and drivers installed
- A test model or inference script (e.g., TensorFlow Lite, ONNX, PyTorch)
- A power meter (USB-C power monitor, wall plug meter, or built-in battery stats)
- A stopwatch or logging script (Python's
timemodule works) - Optional: a thermal camera or temperature sensor for heat checks
Step-by-Step
- Define your workload. Choose a representative task—image classification, object detection, or text generation. Use the same model and input size for every test run so results are comparable. Note the model's input resolution and batch size.
- Set up the device. Ensure the device is fully charged (or plugged into a stable power source), has all updates installed, and is in a consistent state—close background apps, disable auto-updates, and set screen brightness to a fixed level if using a screen.
- Prepare the benchmark script. Write a script that loads the model, runs inference multiple times (e.g., 100 iterations), and records the time of each run. Use a warm-up of 10 runs before measuring to let the hardware reach steady-state performance.
- Measure latency. For each inference, record the time from input to output. Use the median (not the average) of all runs to reduce the impact of outliers. Also record the 95th percentile to understand worst-case delays.
- Measure power use. Connect your power meter between the wall outlet and the device's charger. Record the power draw (in watts) during the benchmark. If using a battery-powered device, use built-in battery stats or a USB power monitor to get real-time consumption.
- Calculate energy per inference. Multiply the average power (in watts) by the average time per inference (in seconds) to get energy in joules. For example, 5 W × 0.2 s = 1 J per inference. This is the key metric for battery life.
- Run the benchmark multiple times. Run the entire test at least three times, ideally on different days or after the device cools down. Take the median of the medians to get a stable result.
- Record and compare. Write down the median latency, average power, and energy per inference. If comparing devices, keep the same model, input, and ambient temperature for all.
Common Mistakes
- Not warming up. The first few inferences are often slower due to model loading and cache misses. Always discard the first 10-20 runs.
- Using the average instead of the median. A single slow run can skew the average. Use the median for a representative value.
- Mixing units. Power is in watts, time in seconds, energy in joules. Don't confuse milliwatts with watts or milliseconds with seconds.
- Ignoring thermal throttling. Devices slow down when hot. Run tests in a cool room and allow cooldown between runs.
- Measuring power from the wall vs. the device. Wall power includes charger losses. If you need the device's actual draw, use a USB power meter or battery stats.
Tips
- Use the same input data for every run to avoid variability from image or text content.
- For edge devices, consider using a benchmark suite like MLPerf Tiny or AI-Benchmark, but verify the suite matches your hardware.
- Record the ambient temperature—it affects performance significantly.
- If your device has different power modes (e.g., performance vs. battery saver), test each mode separately.
- For cloud or server GPUs, use tools like
nvidia-smito log power and utilization during inference.
Troubleshooting
- Latency is wildly inconsistent. Check for background processes, network activity, or thermal throttling. Run the test again after closing all apps and letting the device cool.
- Power readings are zero or negative. Your power meter may not be compatible with the device's charger. Try a different meter, or use the device's built-in battery stats.
- Model fails to load. Verify the model format matches the runtime (e.g., .tflite for TensorFlow Lite). Check that you've installed the correct libraries and drivers.
- Results differ between runs. This is normal. Run more iterations (e.g., 200) and take the median. If still unstable, check for background updates or temperature changes.
- Device shuts down during test. This usually indicates overheating or insufficient power. Reduce the number of iterations, lower the input resolution, or improve cooling.
Frequently Asked Questions
- What is the difference between latency and throughput? Latency is the time for one inference. Throughput is the number of inferences per second (1 / latency). Both are useful; latency matters for real-time apps, throughput for batch processing.
- How do I measure power on a phone? Use a USB power meter between the charger and the phone, or use a battery monitoring app that reads the battery's voltage and current. For more accuracy, use a professional tool like a Monsoon power monitor.
- Should I measure peak power or average power? Both are useful. Peak power tells you the maximum load on the battery and thermal system. Average power over a workload gives you energy consumption, which is what affects battery life.
- Can I use a benchmark app instead of writing my own script? Yes, but be cautious. Prebuilt benchmarks may not match your specific use case. If you use one, note the exact model and settings it uses.
- How many runs should I do? At least 50 after warm-up, but 100-200 is better for stable medians. More runs take longer but give more reliable results.
- What is a good energy-per-inference number? It depends on the task and device. A small edge device might use 0.1-1 J per image classification, while a large GPU might use 10-100 J. Compare only within the same task and model.