4 Commits

Author SHA1 Message Date
94218af170 Version bump to v0.2.0
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/tag/woodpecker Pipeline was successful
2022-08-06 01:27:38 -04:00
9856c59da9 Replaced dd with fio in the disk write subcommand; added subcommand for disk random writes
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2022-08-06 01:27:15 -04:00
e41a4dfffb Updated the disk read test to use fio instead of dd; added new test for 4k random reads (previous test was for sequential reads)
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2022-08-06 01:10:13 -04:00
6f86266dee Updated README
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2022-08-05 21:47:42 -04:00
4 changed files with 133 additions and 51 deletions

View File

@ -1,6 +1,6 @@
[package] [package]
name = "hardware-tests" name = "hardware-tests"
version = "0.2.1" version = "0.2.2"
edition = "2021" edition = "2021"
[[bin]] [[bin]]

View File

@ -1,6 +1,6 @@
# Bit Goblin Hardware Tests # Bit Goblin Hardware Tests
Scripts used for testing hardware in Bit Goblin's videos. Benchmarking suite used for testing hardware in Bit Goblin's videos.
## Download & Installation ## Download & Installation
@ -8,9 +8,16 @@ Check out the [Releases page](https://git.metaunix.net/BitGoblin/hardware-tests/
Currently there is no installation method other than downloading the provided release binaries. In the future I want to build Linux package repositories for this, and have a Windows installer. Currently there is no installation method other than downloading the provided release binaries. In the future I want to build Linux package repositories for this, and have a Windows installer.
## Running
Simply run the tool with `./bgbench` and you'll be presented with the available subcommands.
### Runtime requirements:
* disk - requires `fio`.
## Building ## Building
The easiest way to build the program is using the official Rust image from Docker Hub, for which there's a wrapper script at `bin/docker-build.sh` that can be used to build the test programs. These will be available under `target/debug/`. The easiest way to build the program is using the official Rust image from Docker Hub, for which there's a wrapper script at `bin/docker-build.sh` that can be used to build the test program. These will be available under `target/debug/`. Else you can just run a `cargo build` to compile the program.
## License ## License

View File

@ -28,19 +28,39 @@ struct Disk {
#[derive(Subcommand)] #[derive(Subcommand)]
enum DiskCommands { enum DiskCommands {
// disk read subcommand // sequential disk read subcommand
#[clap(name = "read-test", about = "Read from /dev/zero to determine sequential disk read speeds.")] #[clap(name = "read_seq", about = "Sequential disk read speed test.")]
ReadTest { ReadSeqTest {
#[clap(short = 'f', default_value_t = String::from("/tmp/disk-test.tmp"))]
tempfile: String,
#[clap(short = 's', default_value_t = 15)] #[clap(short = 's', default_value_t = 15)]
size: u8, size: u8,
}, },
// disk write subcommand // random disk read subcommand
#[clap(name = "write-test", about = "Write a large file to determine sequential disk write speeds.")] #[clap(name = "read_rand", about = "Random 4K disk read speed test.")]
WriteTest { ReadRandTest {
#[clap(short = 'f', default_value_t = String::from("/tmp/disk-test.tmp"))]
tempfile: String,
#[clap(short = 's', default_value_t = 15)]
size: u8,
},
// sequential disk write subcommand
#[clap(name = "write_seq", about = "Write a large file to determine sequential disk write speeds.")]
WriteSeqTest {
#[clap(short = 't', default_value_t = String::from("/tmp/disk-test.tmp"))] #[clap(short = 't', default_value_t = String::from("/tmp/disk-test.tmp"))]
tempfile: String, tempfile: String,
#[clap(short = 's', default_value_t = 5)] #[clap(short = 's', default_value_t = 15)]
size: u8,
},
// random 4K disk write subcommand
#[clap(name = "write_rand", about = "Write a bunch of smallfiles to determine random disk write speeds.")]
WriteRandTest {
#[clap(short = 't', default_value_t = String::from("/tmp/disk-test.tmp"))]
tempfile: String,
#[clap(short = 's', default_value_t = 15)]
size: u8, size: u8,
}, },
} }
@ -78,8 +98,10 @@ fn main() {
// map subcommands back to the main command // map subcommands back to the main command
match &cli.command { match &cli.command {
Commands::Disk(args) => match &args.disk_commands { Commands::Disk(args) => match &args.disk_commands {
DiskCommands::ReadTest { size } => tests::disk::disk_read_test(size), DiskCommands::ReadSeqTest { tempfile, size } => tests::disk::disk_read_seq_test(tempfile, size),
DiskCommands::WriteTest { tempfile, size } => tests::disk::disk_write_test(tempfile, size), DiskCommands::ReadRandTest { tempfile, size } => tests::disk::disk_read_rand_test(tempfile, size),
DiskCommands::WriteSeqTest { tempfile, size } => tests::disk::disk_write_seq_test(tempfile, size),
DiskCommands::WriteRandTest { tempfile, size } => tests::disk::disk_write_rand_test(tempfile, size),
} }
Commands::Net(args) => match &args.net_commands { Commands::Net(args) => match &args.net_commands {

View File

@ -1,56 +1,109 @@
use std::fs;
use std::process::Command; use std::process::Command;
// test disk read speeds by reading for /dev/zero and writing it to /dev/null // test disk sequential read speeds w/ fio
pub fn disk_read_test(size: &u8) { pub fn disk_read_seq_test(tempfile: &str, size: &u8) {
// convert size in Gigabytes down to Megabytes // run the fio command
let size_gigs: u32 = (*size as u32 * 1024 * 8).into(); let output = Command::new("fio")
.arg("--name=TEST")
// run sync to clear out any disk caches prior to running .arg(format!("--filename={}", tempfile))
Command::new("sync"); .arg("--rw=read")
.arg("--size=2g")
// run the dd command .arg(format!("--io_size={}g", size))
let output = Command::new("dd") .arg("--blocksize=1024k")
.arg("bs=128k") .arg("--ioengine=libaio")
.arg(format!("count={}", size_gigs)) .arg("--fsync=10000")
.arg("if=/dev/zero") .arg("--iodepth=32")
.arg("of=/dev/null") .arg("--direct=1")
.arg("--numjobs=1")
.arg("--runtime=60")
.arg("--group_reporting")
.output() .output()
.expect("Failed to execute command"); .expect("Failed to execute command");
// check that the command succeeded // check that the command succeeded
assert!(output.status.success()); assert!(output.status.success());
// dd's output ends up in stderr // print the test's output
println!("{}", String::from_utf8_lossy(&output.stderr)); println!("{}", String::from_utf8_lossy(&output.stdout));
// run another sync to clear out the disk's cache
Command::new("sync");
} }
// test disk write speeds by continually writing zeroes to it // test disk 4K random read speeds w/ fio
pub fn disk_write_test(tempfile: &str, size: &u8) { pub fn disk_read_rand_test(tempfile: &str, size: &u8) {
// convert size in Gigabytes down to Megabytes // run the fio command
let size_gigs: u32 = (*size as u32 * 1024).into(); let output = Command::new("fio")
.arg("--name=TEST")
// run the dd command with a block size of 1 MB .arg(format!("--filename={}", tempfile))
let output = Command::new("dd") .arg("--rw=randread")
.arg("bs=1M") .arg("--size=2g")
.arg(format!("count={}", size_gigs)) .arg(format!("--io_size={}g", size))
.arg("if=/dev/zero") .arg("--blocksize=4k")
.arg(format!("of={}", tempfile)) .arg("--ioengine=libaio")
.arg("--fsync=1")
.arg("--iodepth=1")
.arg("--direct=1")
.arg("--numjobs=32")
.arg("--runtime=60")
.arg("--group_reporting")
.output() .output()
.expect("Failed to execute command"); .expect("Failed to execute command");
// check that the command succeeded // check that the command succeeded
assert!(output.status.success()); assert!(output.status.success());
// for whatever reason, `dd` output ends up in stderr // print the test's output
println!("{}", String::from_utf8_lossy(&output.stderr)); println!("{}", String::from_utf8_lossy(&output.stdout));
}
// remove the test file
match fs::remove_file(tempfile) { // test sequential disk write speeds w/ fio
Ok(()) => println!("Cleaning up..."), pub fn disk_write_seq_test(tempfile: &str, size: &u8) {
Err(e) => println!("There was a problem during cleanup - {}", e), // run the fio command
} let output = Command::new("fio")
.arg("--name=TEST")
.arg(format!("--filename={}", tempfile))
.arg("--rw=write")
.arg("--size=2g")
.arg(format!("--io_size={}g", size))
.arg("--blocksize=1024k")
.arg("--ioengine=libaio")
.arg("--fsync=10000")
.arg("--iodepth=32")
.arg("--direct=1")
.arg("--numjobs=1")
.arg("--runtime=60")
.arg("--group_reporting")
.output()
.expect("Failed to execute command");
// check that the command succeeded
assert!(output.status.success());
// print the test's output
println!("{}", String::from_utf8_lossy(&output.stdout));
}
// test random 4K disk write speeds w/ fio
pub fn disk_write_rand_test(tempfile: &str, size: &u8) {
// run the fio command
let output = Command::new("fio")
.arg("--name=TEST")
.arg(format!("--filename={}", tempfile))
.arg("--rw=randrw")
.arg("--size=2g")
.arg(format!("--io_size={}g", size))
.arg("--blocksize=4k")
.arg("--ioengine=libaio")
.arg("--fsync=1")
.arg("--iodepth=1")
.arg("--direct=1")
.arg("--numjobs=32")
.arg("--runtime=60")
.arg("--group_reporting")
.output()
.expect("Failed to execute command");
// check that the command succeeded
assert!(output.status.success());
// print the test's output
println!("{}", String::from_utf8_lossy(&output.stdout));
} }