7 Commits

Author SHA1 Message Date
3169c11cc5 Version bump to v0.3.3
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/tag/woodpecker Pipeline was successful
2022-09-05 12:31:47 -04:00
d4d3e37e8d Completed the network bandwidth test function using iperf3; adjusted Cargo.toml a bit to allow patch updates for dependencies
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2022-09-05 12:31:18 -04:00
7b7150886a Made the Steam game download function work for both Windows and Linux
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2022-08-22 13:47:49 -04:00
4aa3eddc91 Added scaffolding for a few game benchmarks - they currently just make sure the game is installed via Steam, nothing else
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2022-08-22 13:45:16 -04:00
8a7d8c1860 Version bump to v0.3.2
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/tag/woodpecker Pipeline was successful
2022-08-17 18:49:12 -04:00
39ce86d2c3 Fixed the network ping and jitter tests to run on Windows
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2022-08-17 18:48:07 -04:00
88be1ad2ba Added the scaffolding for the jitter test. Now just need to perform the proper calculations.
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2022-08-17 18:39:53 -04:00
5 changed files with 149 additions and 39 deletions

View File

@ -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.3.1" version = "0.3.3"
edition = "2021" edition = "2021"
readme = "README.md" readme = "README.md"
license = "BSD 2-Clause" license = "BSD 2-Clause"
@ -12,9 +12,9 @@ name = "bgbench"
path = "src/main.rs" path = "src/main.rs"
[dependencies] [dependencies]
chrono = "0.4.20" chrono = "0.4"
clap = { version = "3.2.16", features = ["derive"] } clap = { version = "3.2", features = ["derive"] }
sysinfo = "0.25.1" sysinfo = "0.25"
[package.metadata.deb] [package.metadata.deb]
depends = "fio" depends = "fio"

36
src/benchmarks/games.rs Normal file
View File

@ -0,0 +1,36 @@
use std::process::Command;
pub fn run_civ6_ai_benchmark() {
// make sure CS:GO is installed via Steam
download_game_steam(289070);
}
// run the CS:GO benchmark (using benchmark file from PTS)
pub fn run_csgo_benchmark() {
// make sure CS:GO is installed via Steam
download_game_steam(730);
}
pub fn run_demd_benchmark() {
// make sure CS:GO is installed via Steam
download_game_steam(337000);
}
fn download_game_steam(game_id: u32) {
let mut steam_path = "steam";
if cfg!(windows) {
steam_path = "C:\\Program Files (x86)\\Steam\\steam.exe";
}
// first we need to make sure CS:GO is installed via Steam
let install_output = Command::new(steam_path)
.arg(format!("steam://install/{}", game_id))
.output()
.expect("Failed to execute command");
// check that the command succeeded
assert!(install_output.status.success());
// print the test's output
println!("{}", String::from_utf8_lossy(&install_output.stdout));
}

View File

@ -1,2 +1,3 @@
pub mod disk; pub mod disk;
pub mod games;
pub mod network; pub mod network;

View File

@ -1,5 +1,4 @@
use chrono::prelude::*; use std::process;
use std::{fs,process};
use crate::text; use crate::text;
@ -7,10 +6,44 @@ use crate::text;
pub fn ping_host(address: &str, count: &u16) { pub fn ping_host(address: &str, count: &u16) {
println!("Pinging host {}, {} times.", address, count); println!("Pinging host {}, {} times.", address, count);
let mut count_arg = "-c";
if cfg!(windows) {
count_arg = "-n";
}
// 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(format!("-c {}", count)) .arg(count_arg)
.arg(format!("{}", count))
.output()
.expect("Failed to execute command");
// check that the command succeeded
assert!(output.status.success());
// grab the ping results from stdout
let results_raw = &String::from_utf8_lossy(&output.stdout);
let results = text::format::trim_output(results_raw, 4);
for line in results {
println!("{}", line);
}
}
// network jitter test
pub fn jitter_test(address: &str, count: &u16) {
println!("Pinging host {}, {} times to determine network jitter.", address, count);
let mut count_arg = "-c";
if cfg!(windows) {
count_arg = "-n";
}
// run the ping command
let output = process::Command::new("ping")
.arg(address)
.arg(count_arg)
.arg(format!("{}", count))
.output() .output()
.expect("Failed to execute command"); .expect("Failed to execute command");
@ -26,23 +59,20 @@ pub fn ping_host(address: &str, count: &u16) {
} }
// timed file copy test to guage bandwidth speeds // timed file copy test to guage bandwidth speeds
pub fn bandwidth_test(download: &str, output: &str) { pub fn bandwidth_test(host: &str) {
println!("Testing network bandwidth by downloading {}.", download); println!("Testing network bandwidth using iperf; connecting to {}.", host);
println!("{}", host);
// get start time so we can track how long it takes to complete let output = process::Command::new("iperf3")
let start_time = Utc::now(); .arg("-c")
.arg(host)
.output()
.expect("Failed to execute command");
// do the download // check that the command succeeded
assert!(output.status.success());
// get finish time // grab and print the command's results
let finish_time = Utc::now(); let results_raw = &String::from_utf8_lossy(&output.stdout);
// compute time to complete println!("{}", results_raw);
let comp_time = finish_time - start_time;
println!("{}", comp_time.num_milliseconds());
// clean up the test file
match fs::remove_file(output) {
Ok(()) => println!("Cleaning up..."),
Err(e) => println!("There was a problem during cleanup - {}", e),
}
} }

View File

@ -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)]
@ -23,6 +23,9 @@ enum Commands {
// disk benchmarks subcommand // disk benchmarks subcommand
#[clap(name = "disk", about = "Hard drive and SSD benchmarks.")] #[clap(name = "disk", about = "Hard drive and SSD benchmarks.")]
Disk(Disk), Disk(Disk),
// games benchmarks subcommand
#[clap(name = "games", about = "Benchmark your system with games.")]
Games(Games),
// network benchmarks subcommand // network benchmarks subcommand
#[clap(name = "network", about = "Test various aspects of your network.")] #[clap(name = "network", about = "Test various aspects of your network.")]
Net(Net), Net(Net),
@ -91,6 +94,27 @@ enum DiskCommands {
}, },
} }
#[derive(Parser)]
struct Games {
#[structopt(subcommand)]
games_commands: GamesCommands,
}
#[derive(Subcommand)]
enum GamesCommands {
// Civilization 6 AI benchmark subcommand
#[clap(name = "civ6_ai", about = "Run the Civilization 6 AI benchmark via Steam.")]
Civ6AI {},
// CS:GO benchmark subcommand
#[clap(name = "csgo", about = "Run the CS:GO game benchmark via Steam.")]
CSGO {},
// Deus Ex: Mankind Divided benchmark subcommand
#[clap(name = "demd", about = "Run the Deus Ex: Mankind Divided game benchmark via Steam.")]
DEMD {},
}
#[derive(Parser)] #[derive(Parser)]
struct Net { struct Net {
#[structopt(subcommand)] #[structopt(subcommand)]
@ -108,13 +132,20 @@ enum NetCommands {
count: u16, count: u16,
}, },
// jitter subcommand
#[clap(name = "jitter", about = "Ping a host to determine network jitter.")]
Jitter {
#[clap(short = 'a', long, default_value_t = String::from("8.8.8.8"))]
address: String,
#[clap(short = 'c', long, default_value_t = 30)]
count: u16,
},
// bandwidth test subcommand // bandwidth test subcommand
#[clap(name = "bandwidth", about = "Downloads a remote file to determine network bandwidth.")] #[clap(name = "bandwidth", about = "Uses iperf to test network bandwidth.")]
Bandwidth { Bandwidth {
#[clap(short = 'd', long, default_value_t = String::from("https://www.bitgoblin.tech/hardware-tests/export-01.mp4"))] #[clap(short = 'a', long, required = true)]
download: String, host: String,
#[clap(short = 't', long, default_value_t = String::from("/tmp/bw-test.tmp"))]
output: String,
}, },
} }
@ -129,42 +160,54 @@ 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);
} }
}, },
} },
Commands::Games(args) => match &args.games_commands {
GamesCommands::Civ6AI {} => benchmarks::games::run_civ6_ai_benchmark(),
GamesCommands::CSGO {} => benchmarks::games::run_csgo_benchmark(),
GamesCommands::DEMD {} => benchmarks::games::run_demd_benchmark(),
},
Commands::Net(args) => match &args.net_commands { Commands::Net(args) => match &args.net_commands {
NetCommands::Ping { address, count } => { NetCommands::Ping { address, count } => {
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::ping_host(address, count); benchmarks::network::ping_host(address, count);
} }
}, },
NetCommands::Bandwidth { download, output } => { NetCommands::Jitter { address, count } => {
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(download, output); benchmarks::network::jitter_test(address, count);
}
},
NetCommands::Bandwidth { host } => {
for i in 0..cli.iterations {
println!("Test run number {}.", i + 1);
benchmarks::network::bandwidth_test(host);
} }
}, },
}, },