Skip to content

Latest commit

 

History

History
53 lines (38 loc) · 1.56 KB

File metadata and controls

53 lines (38 loc) · 1.56 KB

Disk Benchmark (Rust)

A cross-platform disk benchmark tool written in Rust, inspired by the original disk-bench.sh script.

Features

  • Cross-Platform: Works on Windows, Linux, and macOS.
  • Buffered & Unbuffered I/O:
    • Buffered: Uses OS page cache (default). Good for testing cached performance.
    • Unbuffered (--no-buffer): Bypasses OS cache using O_DIRECT (Linux) or FILE_FLAG_NO_BUFFERING (Windows). Good for testing raw disk performance.
  • Customizable: Set iterations, file size, speed unit.
  • Safety: Automatically cleans up test files even if the program is interrupted (best effort).

Usage

disk_bench [ITERATIONS] [SIZE] [SPEED_UNIT] [CLEAR_CACHE] [DESTINATION_PATH] [OPTIONS]

Arguments

  • ITERATIONS: Number of test iterations.
  • SIZE: File size (e.g., 1G, 500M, 100MiB).
  • SPEED_UNIT: Display unit (K, M, G).
  • CLEAR_CACHE: yes or no (clears OS cache before read test).
    • Note: On Windows, this only flushes file buffers. On Linux/macOS, it attempts to drop caches (requires root).
  • DESTINATION_PATH: Directory to run the test in (default: home directory).

Options

  • --no-buffer: Use direct I/O (bypass cache).
  • -h, --help: Print help.

Examples

Run 3 iterations, 1GB file, display in MBps, buffered:

disk_bench 3 1G M no .

Run 1 iteration, 500MB file, unbuffered (raw disk speed):

disk_bench 1 500M M no . --no-buffer

Building

cd disk_bench
cargo build --release

The binary will be in disk_bench/target/release/disk_bench.