mirror of
https://github.com/YGGverse/aquatic.git
synced 2026-03-31 17:55:36 +00:00
aquatic_bench: enable loading configuration from file
This commit is contained in:
parent
4691080602
commit
9a1143ffac
6 changed files with 35 additions and 3 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -1 +1,2 @@
|
||||||
/target
|
/target
|
||||||
|
/tmp
|
||||||
2
Cargo.lock
generated
2
Cargo.lock
generated
|
|
@ -48,12 +48,14 @@ version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"aquatic",
|
"aquatic",
|
||||||
"bittorrent_udp",
|
"bittorrent_udp",
|
||||||
|
"cli_helpers",
|
||||||
"indicatif",
|
"indicatif",
|
||||||
"mimalloc",
|
"mimalloc",
|
||||||
"num-format",
|
"num-format",
|
||||||
"plotly",
|
"plotly",
|
||||||
"rand",
|
"rand",
|
||||||
"rand_distr",
|
"rand_distr",
|
||||||
|
"serde",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
|
|
||||||
|
|
@ -17,9 +17,11 @@ name = "plot_pareto"
|
||||||
[dependencies]
|
[dependencies]
|
||||||
aquatic = { path = "../aquatic" }
|
aquatic = { path = "../aquatic" }
|
||||||
bittorrent_udp = { path = "../bittorrent_udp" }
|
bittorrent_udp = { path = "../bittorrent_udp" }
|
||||||
|
cli_helpers = { path = "../cli_helpers" }
|
||||||
indicatif = "0.14"
|
indicatif = "0.14"
|
||||||
mimalloc = { version = "0.1", default-features = false }
|
mimalloc = { version = "0.1", default-features = false }
|
||||||
num-format = "0.4"
|
num-format = "0.4"
|
||||||
plotly = "0.4"
|
plotly = "0.4"
|
||||||
rand = { version = "0.7", features = ["small_rng"] }
|
rand = { version = "0.7", features = ["small_rng"] }
|
||||||
rand_distr = "0.2"
|
rand_distr = "0.2"
|
||||||
|
serde = { version = "1", features = ["derive"] }
|
||||||
16
aquatic_bench/src/bin/bench_handlers/config.rs
Normal file
16
aquatic_bench/src/bin/bench_handlers/config.rs
Normal file
|
|
@ -0,0 +1,16 @@
|
||||||
|
use serde::{Serialize, Deserialize};
|
||||||
|
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Serialize, Deserialize)]
|
||||||
|
pub struct BenchConfig {
|
||||||
|
pub num_rounds: u64,
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
impl Default for BenchConfig {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self {
|
||||||
|
num_rounds: 20,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -20,14 +20,17 @@ use rand::{Rng, thread_rng, rngs::SmallRng, SeedableRng};
|
||||||
use aquatic::common::*;
|
use aquatic::common::*;
|
||||||
use aquatic::config::Config;
|
use aquatic::config::Config;
|
||||||
use bittorrent_udp::converters::*;
|
use bittorrent_udp::converters::*;
|
||||||
|
use cli_helpers::run_app_with_cli_and_config;
|
||||||
|
|
||||||
|
|
||||||
mod announce;
|
mod announce;
|
||||||
mod common;
|
mod common;
|
||||||
|
mod config;
|
||||||
mod connect;
|
mod connect;
|
||||||
mod scrape;
|
mod scrape;
|
||||||
|
|
||||||
use common::*;
|
use common::*;
|
||||||
|
use config::BenchConfig;
|
||||||
|
|
||||||
|
|
||||||
#[global_allocator]
|
#[global_allocator]
|
||||||
|
|
@ -53,7 +56,15 @@ fn print_results(
|
||||||
|
|
||||||
|
|
||||||
fn main(){
|
fn main(){
|
||||||
let num_rounds = 20;
|
run_app_with_cli_and_config::<BenchConfig>(
|
||||||
|
"aquatic benchmarker",
|
||||||
|
run
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
fn run(bench_config: BenchConfig){
|
||||||
|
let num_rounds = bench_config.num_rounds;
|
||||||
|
|
||||||
let mut connect_data = (0.0, 0.0);
|
let mut connect_data = (0.0, 0.0);
|
||||||
let mut announce_data = (0.0, 0.0);
|
let mut announce_data = (0.0, 0.0);
|
||||||
|
|
|
||||||
|
|
@ -2,4 +2,4 @@
|
||||||
|
|
||||||
export RUSTFLAGS="-C target-cpu=native"
|
export RUSTFLAGS="-C target-cpu=native"
|
||||||
|
|
||||||
cargo run --release --bin bench_handlers
|
cargo run --release --bin bench_handlers -- $@
|
||||||
Loading…
Add table
Add a link
Reference in a new issue