Compare commits
No commits in common. "master" and "v0.3.3" have entirely different histories.
@ -1,7 +1,7 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "hardware-tests"
|
name = "hardware-tests"
|
||||||
description = "Bit Goblin PC hardware test suite."
|
description = "Bit Goblin PC hardware test suite."
|
||||||
version = "0.4.0"
|
version = "0.3.3"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
license = "BSD 2-Clause"
|
license = "BSD 2-Clause"
|
||||||
|
@ -13,8 +13,7 @@ Currently there is no installation method other than downloading the provided re
|
|||||||
Simply run the tool with `./bgbench` and you'll be presented with the available subcommands.
|
Simply run the tool with `./bgbench` and you'll be presented with the available subcommands.
|
||||||
|
|
||||||
### Runtime requirements:
|
### Runtime requirements:
|
||||||
* `disk` - requires `fio`.
|
* disk - requires `fio`.
|
||||||
* `network bandwidth` - requires `iperf3`
|
|
||||||
|
|
||||||
## Building
|
## Building
|
||||||
|
|
||||||
|
@ -3,25 +3,19 @@ use std::process;
|
|||||||
use crate::text;
|
use crate::text;
|
||||||
|
|
||||||
// ping a host
|
// ping a host
|
||||||
pub fn latency_test(address: &str, count: &u16, interval: &u16) {
|
pub fn ping_host(address: &str, count: &u16) {
|
||||||
println!("Pinging host {}, {} times.", address, count);
|
println!("Pinging host {}, {} times.", address, count);
|
||||||
|
|
||||||
// if we're on Windows we need to use the -n flag for ping counts
|
|
||||||
let mut count_arg = "-c";
|
let mut count_arg = "-c";
|
||||||
if cfg!(windows) {
|
if cfg!(windows) {
|
||||||
count_arg = "-n";
|
count_arg = "-n";
|
||||||
}
|
}
|
||||||
|
|
||||||
// convert the ping interval to seconds
|
|
||||||
let interval_secs = *interval as f64 / 1000 as f64;
|
|
||||||
|
|
||||||
// run the ping command
|
// run the ping command
|
||||||
let output = process::Command::new("ping")
|
let output = process::Command::new("ping")
|
||||||
.arg(address)
|
.arg(address)
|
||||||
.arg(count_arg)
|
.arg(count_arg)
|
||||||
.arg(format!("{}", count))
|
.arg(format!("{}", count))
|
||||||
.arg("-i")
|
|
||||||
.arg(format!("{}", interval_secs))
|
|
||||||
.output()
|
.output()
|
||||||
.expect("Failed to execute command");
|
.expect("Failed to execute command");
|
||||||
|
|
||||||
@ -37,25 +31,19 @@ pub fn latency_test(address: &str, count: &u16, interval: &u16) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// network jitter test
|
// network jitter test
|
||||||
pub fn jitter_test(address: &str, count: &u16, interval: &u16) {
|
pub fn jitter_test(address: &str, count: &u16) {
|
||||||
println!("Pinging host {}, {} times to determine network jitter.", address, count);
|
println!("Pinging host {}, {} times to determine network jitter.", address, count);
|
||||||
|
|
||||||
// if we're on Windows we need to use the -n flag for ping counts
|
|
||||||
let mut count_arg = "-c";
|
let mut count_arg = "-c";
|
||||||
if cfg!(windows) {
|
if cfg!(windows) {
|
||||||
count_arg = "-n";
|
count_arg = "-n";
|
||||||
}
|
}
|
||||||
|
|
||||||
// convert the ping interval to seconds
|
|
||||||
let interval_secs = *interval as f64 / 1000 as f64;
|
|
||||||
|
|
||||||
// run the ping command
|
// run the ping command
|
||||||
let output = process::Command::new("ping")
|
let output = process::Command::new("ping")
|
||||||
.arg(address)
|
.arg(address)
|
||||||
.arg(count_arg)
|
.arg(count_arg)
|
||||||
.arg(format!("{}", count))
|
.arg(format!("{}", count))
|
||||||
.arg("-i")
|
|
||||||
.arg(format!("{}", interval_secs))
|
|
||||||
.output()
|
.output()
|
||||||
.expect("Failed to execute command");
|
.expect("Failed to execute command");
|
||||||
|
|
||||||
|
68
src/main.rs
68
src/main.rs
@ -11,8 +11,8 @@ struct Cli {
|
|||||||
#[clap(subcommand)]
|
#[clap(subcommand)]
|
||||||
command: Commands,
|
command: Commands,
|
||||||
|
|
||||||
#[clap(short = 'l', long, default_value_t = 1, help = "Number of times to run test. Default = 1", global = true)]
|
#[clap(short = 'i', long, default_value_t = 1, help = "Number of times to run test. Default = 1", global = true)]
|
||||||
loopcount: u8,
|
iterations: u8,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Subcommand)]
|
#[derive(Subcommand)]
|
||||||
@ -123,11 +123,13 @@ struct Net {
|
|||||||
|
|
||||||
#[derive(Subcommand)]
|
#[derive(Subcommand)]
|
||||||
enum NetCommands {
|
enum NetCommands {
|
||||||
// bandwidth test subcommand
|
// ping subcommand
|
||||||
#[clap(name = "bandwidth", about = "Uses iperf to test network bandwidth.")]
|
#[clap(name = "ping", about = "Ping a host to determine network latency.")]
|
||||||
Bandwidth {
|
Ping {
|
||||||
#[clap(short = 'a', long, required = true)]
|
#[clap(short = 'a', long, default_value_t = String::from("8.8.8.8"))]
|
||||||
host: String,
|
address: String,
|
||||||
|
#[clap(short = 'c', long, default_value_t = 30)]
|
||||||
|
count: u16,
|
||||||
},
|
},
|
||||||
|
|
||||||
// jitter subcommand
|
// jitter subcommand
|
||||||
@ -135,21 +137,15 @@ enum NetCommands {
|
|||||||
Jitter {
|
Jitter {
|
||||||
#[clap(short = 'a', long, default_value_t = String::from("8.8.8.8"))]
|
#[clap(short = 'a', long, default_value_t = String::from("8.8.8.8"))]
|
||||||
address: String,
|
address: String,
|
||||||
#[clap(short = 'c', long, default_value_t = 100)]
|
#[clap(short = 'c', long, default_value_t = 30)]
|
||||||
count: u16,
|
count: u16,
|
||||||
#[clap(short = 'i', long, default_value_t = 1000)]
|
|
||||||
interval: u16,
|
|
||||||
},
|
},
|
||||||
|
|
||||||
// latency subcommand
|
// bandwidth test subcommand
|
||||||
#[clap(name = "latency", about = "Ping a host to determine network latency.")]
|
#[clap(name = "bandwidth", about = "Uses iperf to test network bandwidth.")]
|
||||||
Latency {
|
Bandwidth {
|
||||||
#[clap(short = 'a', long, default_value_t = String::from("8.8.8.8"))]
|
#[clap(short = 'a', long, required = true)]
|
||||||
address: String,
|
host: String,
|
||||||
#[clap(short = 'c', long, default_value_t = 100)]
|
|
||||||
count: u16,
|
|
||||||
#[clap(short = 'i', long, default_value_t = 1000)]
|
|
||||||
interval: u16,
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -164,25 +160,25 @@ fn main() {
|
|||||||
|
|
||||||
Commands::Disk(args) => match &args.disk_commands {
|
Commands::Disk(args) => match &args.disk_commands {
|
||||||
DiskCommands::ReadSeqTest { tempfile, size } => {
|
DiskCommands::ReadSeqTest { tempfile, size } => {
|
||||||
for i in 0..cli.loopcount {
|
for i in 0..cli.iterations {
|
||||||
println!("Test run number {}.", i + 1);
|
println!("Test run number {}.", i + 1);
|
||||||
benchmarks::disk::disk_read_seq_test(tempfile, size);
|
benchmarks::disk::disk_read_seq_test(tempfile, size);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
DiskCommands::ReadRandTest { tempfile, size } => {
|
DiskCommands::ReadRandTest { tempfile, size } => {
|
||||||
for i in 0..cli.loopcount {
|
for i in 0..cli.iterations {
|
||||||
println!("Test run number {}.", i + 1);
|
println!("Test run number {}.", i + 1);
|
||||||
benchmarks::disk::disk_read_rand_test(tempfile, size);
|
benchmarks::disk::disk_read_rand_test(tempfile, size);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
DiskCommands::WriteSeqTest { tempfile, size } => {
|
DiskCommands::WriteSeqTest { tempfile, size } => {
|
||||||
for i in 0..cli.loopcount {
|
for i in 0..cli.iterations {
|
||||||
println!("Test run number {}.", i + 1);
|
println!("Test run number {}.", i + 1);
|
||||||
benchmarks::disk::disk_write_seq_test(tempfile, size);
|
benchmarks::disk::disk_write_seq_test(tempfile, size);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
DiskCommands::WriteRandTest { tempfile, size } => {
|
DiskCommands::WriteRandTest { tempfile, size } => {
|
||||||
for i in 0..cli.loopcount {
|
for i in 0..cli.iterations {
|
||||||
println!("Test run number {}.", i + 1);
|
println!("Test run number {}.", i + 1);
|
||||||
benchmarks::disk::disk_write_rand_test(tempfile, size);
|
benchmarks::disk::disk_write_rand_test(tempfile, size);
|
||||||
}
|
}
|
||||||
@ -196,24 +192,24 @@ fn main() {
|
|||||||
},
|
},
|
||||||
|
|
||||||
Commands::Net(args) => match &args.net_commands {
|
Commands::Net(args) => match &args.net_commands {
|
||||||
|
NetCommands::Ping { address, count } => {
|
||||||
|
for i in 0..cli.iterations {
|
||||||
|
println!("Test run number {}.", i + 1);
|
||||||
|
benchmarks::network::ping_host(address, count);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
NetCommands::Jitter { address, count } => {
|
||||||
|
for i in 0..cli.iterations {
|
||||||
|
println!("Test run number {}.", i + 1);
|
||||||
|
benchmarks::network::jitter_test(address, count);
|
||||||
|
}
|
||||||
|
},
|
||||||
NetCommands::Bandwidth { host } => {
|
NetCommands::Bandwidth { host } => {
|
||||||
for i in 0..cli.loopcount {
|
for i in 0..cli.iterations {
|
||||||
println!("Test run number {}.", i + 1);
|
println!("Test run number {}.", i + 1);
|
||||||
benchmarks::network::bandwidth_test(host);
|
benchmarks::network::bandwidth_test(host);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
NetCommands::Jitter { address, count, interval } => {
|
|
||||||
for i in 0..cli.loopcount {
|
|
||||||
println!("Test run number {}.", i + 1);
|
|
||||||
benchmarks::network::jitter_test(address, count, interval);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
NetCommands::Latency { address, count, interval } => {
|
|
||||||
for i in 0..cli.loopcount {
|
|
||||||
println!("Test run number {}.", i + 1);
|
|
||||||
benchmarks::network::latency_test(address, count, interval);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user