4 Commits

Author SHA1 Message Date
2a7e6f4092 Version bump to v0.4.1
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/tag/woodpecker Pipeline was successful
2025-01-16 17:31:24 -05:00
baf8630832 Added benchmarks for CPU and memory
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2025-01-16 17:31:01 -05:00
000a33cfe4 Updating version of Rust used to build
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2025-01-16 17:21:02 -05:00
a6f6994c2b Added runtime req for iperf3
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
2024-01-28 19:59:31 -05:00
7 changed files with 86 additions and 4 deletions

View File

@ -1,11 +1,11 @@
pipeline: pipeline:
test_build: test_build:
image: rust:1.62 image: rust:1.75
commands: commands:
- "cargo build" - "cargo build"
build_release: build_release:
image: rust:1.62 image: rust:1.75
commands: commands:
- "cargo install cargo-deb cargo-generate-rpm" - "cargo install cargo-deb cargo-generate-rpm"
- "cargo build --release" - "cargo build --release"

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.4.0" version = "0.4.1"
edition = "2021" edition = "2021"
readme = "README.md" readme = "README.md"
license = "BSD 2-Clause" license = "BSD 2-Clause"

View File

@ -13,7 +13,8 @@ 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

19
src/benchmarks/cpu.rs Normal file
View File

@ -0,0 +1,19 @@
use std::process::Command;
// test system memory with sysbench
pub fn sysbench(threads: &u8, maxprime: &u32) {
// run the fio command
let output = Command::new("sysbench")
.arg("cpu")
.arg(format!("--threads={}", threads))
.arg(format!("--cpu-max-prime={}", maxprime))
.arg("run")
.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));
}

21
src/benchmarks/memory.rs Normal file
View File

@ -0,0 +1,21 @@
use std::process::Command;
// test system memory with sysbench
pub fn sysbench(accessmode: &str, operation: &str, blocksize: &str, totalsize: &str) {
// run the fio command
let output = Command::new("sysbench")
.arg("memory")
.arg(format!("--memory-access-mode={}", accessmode))
.arg(format!("--memory-oper={}", operation))
.arg(format!("--memory-block-size={}", blocksize))
.arg(format!("--memory-total-size={}", totalsize))
.arg("run")
.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));
}

View File

@ -1,3 +1,5 @@
pub mod cpu;
pub mod disk; pub mod disk;
pub mod games; pub mod games;
pub mod memory;
pub mod network; pub mod network;

View File

@ -20,6 +20,9 @@ enum Commands {
// CPU benchmarks subcommand // CPU benchmarks subcommand
#[clap(name = "cpu", about = "CPU benchmarks and stress tests.")] #[clap(name = "cpu", about = "CPU benchmarks and stress tests.")]
Cpu(Cpu), Cpu(Cpu),
// memory benchmarks subcommand
#[clap(name = "memory", about = "Memory benchmarks and stress tests.")]
Mem(Mem),
// 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),
@ -47,6 +50,37 @@ enum CpuCommands {
#[clap(short = 't', long, default_value_t = 0, help = "Number of threads to use; defaults to CPU's max thread count. Defaults to 0 (automatic)")] #[clap(short = 't', long, default_value_t = 0, help = "Number of threads to use; defaults to CPU's max thread count. Defaults to 0 (automatic)")]
threads: usize, threads: usize,
}, },
// CPU benchmark test subcommand
#[clap(name = "benchmark", about = "Benchmark the CPU")]
Benchmark {
#[clap(short = 'm', long, default_value_t = 4)]
threads: u8,
#[clap(short = 'o', long, default_value_t = 10000)]
maxprime: u32,
},
}
#[derive(Args)]
struct Mem {
#[clap(subcommand)]
mem_commands: MemCommands,
}
#[derive(Subcommand)]
enum MemCommands {
// Memory benchmark test subcommand
#[clap(name = "benchmark", about = "Benchmark the system memory")]
Benchmark {
#[clap(short = 'm', long, default_value_t = String::from("seq"))]
accessmode: String,
#[clap(short = 'o', long, default_value_t = String::from("write"))]
operation: String,
#[clap(short = 'b', long, default_value_t = String::from("1K"))]
blocksize: String,
#[clap(short = 's', long, default_value_t = String::from("100G"))]
totalsize: String,
},
} }
#[derive(Args)] #[derive(Args)]
@ -160,6 +194,11 @@ fn main() {
match &cli.command { match &cli.command {
Commands::Cpu(args) => match &args.cpu_commands { Commands::Cpu(args) => match &args.cpu_commands {
CpuCommands::StressTest { runtime, threads } => stress::cpu::cpu_stress_math(*runtime, *threads), CpuCommands::StressTest { runtime, threads } => stress::cpu::cpu_stress_math(*runtime, *threads),
CpuCommands::Benchmark { threads, maxprime } => benchmarks::cpu::sysbench(threads, maxprime),
},
Commands::Mem(args) => match &args.mem_commands {
MemCommands::Benchmark { accessmode, operation, blocksize, totalsize } => benchmarks::memory::sysbench(accessmode, operation, blocksize, totalsize),
}, },
Commands::Disk(args) => match &args.disk_commands { Commands::Disk(args) => match &args.disk_commands {