A small utility for benchmarking read / write throughput (both sequential and random) of storage medium(s) on a Raspberry Pi running Linux.
This Python script performs benchmarking of a storage drive's read and write performance, intedned to be run on a Raspberry Pi 4B. The benchmarking uses both fio
for synthetic I/O performance tests and custom tests simulating real-world operations like writing and reading CSV files. The results are saved to a CSV file and also printed to the console.
Make sure you have the following installed:
- Python 3.x
fio
for benchmarking:sudo apt-get install fio
pyyaml
for reading the configuration file:pip install -r requirements.txt
Before running the script, configure the benchmark_config.yaml
file:
test_hw: "RPi_4B_USB_flash_drive" # Hardware identifier for the test (enter your own)
test_data_sizes_mB: [10, 100, 1000] # Data sizes to benchmark in MB
num_runs: 1 # Number of runs for each test
test_hw
: A string identifying the hardware (e.g., "RPi_4B_USB_flash_drive"). This is required to generate the results folder.test_data_sizes_mB
: A list of data sizes in megabytes that will be used in the tests.num_runs
: The number of times each test will be repeated to average the results.
- Ensure you have configured the
benchmark_config.yaml
file. - Run the benchmark script:
python run_benchmark.py
The script will attempt to install fio
if it is not installed. If the automatic installation fails, you will be prompted to manually install it using:
sudo apt install fio
The results will be saved to benchmark_results.csv
in a folder named hw_benchmark_results_<your_test_hw>
.
Example results in benchmark_results.csv
:
Test Type | Data Size (MB) | Run | Result (MB/s) |
---|---|---|---|
Sequential Write | 10.00 | 1 | 50.12 |
Sequential Read | 10.00 | 1 | 52.34 |
Random Write | 10.00 | 1 | 1.42 |
Random Read | 10.00 | 1 | 1.37 |
Custom CSV Write | 10.00 | 1 | 21.87 |
Custom CSV Read | 10.00 | 1 | 14.45 |