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
|
# MSVC Windows builds of rustc generate these, which store debugging information
|
||||||
*.pdb
|
*.pdb
|
||||||
|
|
||||||
|
benchmarks.toml
|
||||||
|
|||||||
@@ -11,8 +11,8 @@ pub struct Args {
|
|||||||
pub mode: KeyExchangeMode,
|
pub mode: KeyExchangeMode,
|
||||||
|
|
||||||
/// Server address to connect to.
|
/// Server address to connect to.
|
||||||
#[arg(long)]
|
#[arg(long, required_unless_present = "config")]
|
||||||
pub server: SocketAddr,
|
pub server: Option<SocketAddr>,
|
||||||
|
|
||||||
/// Payload size in bytes to request from server.
|
/// Payload size in bytes to request from server.
|
||||||
#[arg(long, default_value = "1024")]
|
#[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 serde::Deserialize;
|
||||||
use std::{fs::read_to_string, net::SocketAddr, path::PathBuf};
|
use std::{fs::read_to_string, net::SocketAddr, path::PathBuf};
|
||||||
|
|
||||||
@@ -25,10 +27,12 @@ pub fn load_from_file(path: &PathBuf) -> miette::Result<Config> {
|
|||||||
let content = read_to_string(path)
|
let content = read_to_string(path)
|
||||||
.into_diagnostic()
|
.into_diagnostic()
|
||||||
.context(format!("failed to read config file: {}", path.display()))?;
|
.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)
|
||||||
"failed to parse TOML config from file {}",
|
.into_diagnostic()
|
||||||
path.display()
|
.context(format!(
|
||||||
))?;
|
"failed to parse TOML config from file {}",
|
||||||
|
path.display()
|
||||||
|
))?;
|
||||||
Ok(config)
|
Ok(config)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -36,16 +40,17 @@ pub fn load_from_file(path: &PathBuf) -> miette::Result<Config> {
|
|||||||
///
|
///
|
||||||
/// # Errors
|
/// # Errors
|
||||||
/// Never returns an error, but returns Result for consistency.
|
/// Never returns an error, but returns Result for consistency.
|
||||||
pub fn load_from_cli(args: &crate::args::Args) -> miette::Result<Config> {
|
pub fn load_from_cli(args: &Args) -> miette::Result<Config> {
|
||||||
let mode = args.mode.to_string();
|
|
||||||
Ok(Config {
|
Ok(Config {
|
||||||
benchmarks: vec![BenchmarkConfig {
|
benchmarks: vec![BenchmarkConfig {
|
||||||
mode,
|
mode: args.mode.to_string(),
|
||||||
payload: args.payload_bytes,
|
payload: args.payload_bytes,
|
||||||
iters: args.iters,
|
iters: args.iters,
|
||||||
warmup: args.warmup,
|
warmup: args.warmup,
|
||||||
concurrency: args.concurrency,
|
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)
|
.unwrap_or(KeyExchangeMode::X25519)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
use common::KeyExchangeMode;
|
|
||||||
|
|||||||
Reference in New Issue
Block a user