A simple Go-based utility for measuring disk I/O performance. The tool simulates various I/O workloads by reading from and writing to a test file.
- Supports sequential and random I/O patterns.
- Configurable test parameters:
- File size
- Block size
- Duration of the test
- Parallelism (number of threads)
- I/O mode: read, write, or mixed
- Write-to-read ratio for mixed mode
- Outputs key performance metrics:
- Total operations
- Total data processed
- Throughput in MB/s
-
File Setup:
- A test file of a configurable size is created (default: 1GB).
- The file is filled with test data to ensure realistic conditions for I/O operations.
-
Worker Threads:
- Multiple worker threads operate in parallel, performing I/O operations based on the selected mode and parameters.
- Each thread performs either:
- Random I/O: Operations occur at random offsets within the file.
- Sequential I/O: Operations proceed from the beginning of the file.
-
Modes of Operation:
- Write: Threads write data blocks to the file.
- Read: Threads read data blocks from the file.
- Mixed: A configurable ratio determines the percentage of write versus read operations.
-
Metrics Calculation:
- Total number of operations is counted.
- Total amount of data processed is calculated.
- Throughput is reported in MB/s based on the test duration.
go run . [options]| Flag | Default Value | Description |
|---|---|---|
--filesize |
testfile |
Path to the test file. |
--bs |
4096 |
Block size in bytes. |
--time |
10 |
Test duration in seconds. |
--threads |
1 |
Number of parallel threads. |
--mode |
write |
Mode of operation: read, write, or mixed. |
--write-ratio |
50 |
Write-to-read ratio for mixed mode (0-100). |
--random |
true |
Use random I/O if true, sequential if false. |
--size |
1GB |
Size of the file in bytes. |
- File size: 2GB
- Block size: 4KB
- Duration: 15 seconds
- Parallelism: 4 threads
- Mixed mode with 70% writes and 30% reads
- Random I/O enabled
go run . --file testfile --bs 4096 --time 10 --threads 1 --mode write --write-ratio 60 --random --filesize 5GTest completed:
Total Operations: 512345
Total Data: 2098764800 bytes
Throughput: 133.30 MB/s
- The tool ensures the test file is large enough for realistic random access.
- Ensure adequate disk space is available before running tests.
- Performance may vary based on disk type, system load, and configuration.