mirror of
https://github.com/kristoferssolo/tls-pq-bench.git
synced 2026-03-21 16:26:22 +00:00
feat(runner): add TOML matrix benchmark config support
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -17,3 +17,5 @@ target/
|
||||
|
||||
# MSVC Windows builds of rustc generate these, which store debugging information
|
||||
*.pdb
|
||||
|
||||
benchmarks.toml
|
||||
|
||||
@@ -11,8 +11,8 @@ pub struct Args {
|
||||
pub mode: KeyExchangeMode,
|
||||
|
||||
/// Server address to connect to.
|
||||
#[arg(long)]
|
||||
pub server: SocketAddr,
|
||||
#[arg(long, required_unless_present = "config")]
|
||||
pub server: Option<SocketAddr>,
|
||||
|
||||
/// Payload size in bytes to request from server.
|
||||
#[arg(long, default_value = "1024")]
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
use miette::{Context, IntoDiagnostic};
|
||||
use crate::args::Args;
|
||||
use common::KeyExchangeMode;
|
||||
use miette::{Context, IntoDiagnostic, miette};
|
||||
use serde::Deserialize;
|
||||
use std::{fs::read_to_string, net::SocketAddr, path::PathBuf};
|
||||
|
||||
@@ -25,7 +27,9 @@ pub fn load_from_file(path: &PathBuf) -> miette::Result<Config> {
|
||||
let content = read_to_string(path)
|
||||
.into_diagnostic()
|
||||
.context(format!("failed to read config file: {}", path.display()))?;
|
||||
let config: Config = toml::from_str(&content).into_diagnostic().context(format!(
|
||||
let config = toml::from_str::<Config>(&content)
|
||||
.into_diagnostic()
|
||||
.context(format!(
|
||||
"failed to parse TOML config from file {}",
|
||||
path.display()
|
||||
))?;
|
||||
@@ -36,16 +40,17 @@ pub fn load_from_file(path: &PathBuf) -> miette::Result<Config> {
|
||||
///
|
||||
/// # Errors
|
||||
/// Never returns an error, but returns Result for consistency.
|
||||
pub fn load_from_cli(args: &crate::args::Args) -> miette::Result<Config> {
|
||||
let mode = args.mode.to_string();
|
||||
pub fn load_from_cli(args: &Args) -> miette::Result<Config> {
|
||||
Ok(Config {
|
||||
benchmarks: vec![BenchmarkConfig {
|
||||
mode,
|
||||
mode: args.mode.to_string(),
|
||||
payload: args.payload_bytes,
|
||||
iters: args.iters,
|
||||
warmup: args.warmup,
|
||||
concurrency: args.concurrency,
|
||||
server: args.server,
|
||||
server: args
|
||||
.server
|
||||
.ok_or_else(|| miette!("--server is required when not using --config"))?,
|
||||
}],
|
||||
})
|
||||
}
|
||||
@@ -60,5 +65,3 @@ impl Config {
|
||||
.unwrap_or(KeyExchangeMode::X25519)
|
||||
}
|
||||
}
|
||||
|
||||
use common::KeyExchangeMode;
|
||||
|
||||
Reference in New Issue
Block a user