mirror of
https://github.com/YGGverse/aquatic.git
synced 2026-03-31 09:45:31 +00:00
move plot_pareto from aquatic_udp_bench crate into own crate
This commit is contained in:
parent
2f13e1e1a8
commit
3addab07f0
14 changed files with 53 additions and 35 deletions
10
Cargo.lock
generated
10
Cargo.lock
generated
|
|
@ -73,7 +73,6 @@ dependencies = [
|
||||||
"indicatif",
|
"indicatif",
|
||||||
"mimalloc",
|
"mimalloc",
|
||||||
"num-format",
|
"num-format",
|
||||||
"plotly",
|
|
||||||
"rand",
|
"rand",
|
||||||
"rand_distr",
|
"rand_distr",
|
||||||
"serde",
|
"serde",
|
||||||
|
|
@ -935,6 +934,15 @@ version = "0.3.17"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "05da548ad6865900e60eaba7f589cc0783590a92e940c26953ff81ddbab2d677"
|
checksum = "05da548ad6865900e60eaba7f589cc0783590a92e940c26953ff81ddbab2d677"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "plot_pareto"
|
||||||
|
version = "0.1.0"
|
||||||
|
dependencies = [
|
||||||
|
"plotly",
|
||||||
|
"rand",
|
||||||
|
"rand_distr",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "plotly"
|
name = "plotly"
|
||||||
version = "0.4.1"
|
version = "0.4.1"
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@ members = [
|
||||||
"aquatic_udp_load_test",
|
"aquatic_udp_load_test",
|
||||||
"aquatic_udp_protocol",
|
"aquatic_udp_protocol",
|
||||||
"aquatic_ws",
|
"aquatic_ws",
|
||||||
|
"plot_pareto"
|
||||||
]
|
]
|
||||||
|
|
||||||
[profile.release]
|
[profile.release]
|
||||||
|
|
|
||||||
3
TODO.md
3
TODO.md
|
|
@ -11,9 +11,6 @@
|
||||||
use of Ipv4 ones, I have to check.
|
use of Ipv4 ones, I have to check.
|
||||||
* More tests?
|
* More tests?
|
||||||
|
|
||||||
## aquatic_udp_bench
|
|
||||||
* move plot_pareto to own crate
|
|
||||||
|
|
||||||
## bittorrent_udp
|
## bittorrent_udp
|
||||||
* Tests with good known byte sequences (requests and responses)
|
* Tests with good known byte sequences (requests and responses)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,15 +5,9 @@ authors = ["Joakim Frostegård <joakim.frostegard@gmail.com>"]
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
license = "Apache-2.0"
|
license = "Apache-2.0"
|
||||||
|
|
||||||
[lib]
|
[[bin]]
|
||||||
name = "aquatic_udp_bench"
|
name = "aquatic_udp_bench"
|
||||||
|
|
||||||
[[bin]]
|
|
||||||
name = "aquatic_udp_bench_handlers"
|
|
||||||
|
|
||||||
[[bin]]
|
|
||||||
name = "plot_pareto"
|
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
anyhow = "1"
|
anyhow = "1"
|
||||||
aquatic_cli_helpers = { path = "../aquatic_cli_helpers" }
|
aquatic_cli_helpers = { path = "../aquatic_cli_helpers" }
|
||||||
|
|
@ -22,7 +16,6 @@ crossbeam-channel = "0.4"
|
||||||
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"
|
|
||||||
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"] }
|
serde = { version = "1", features = ["derive"] }
|
||||||
|
|
|
||||||
|
|
@ -9,8 +9,6 @@ use rand_distr::Pareto;
|
||||||
use aquatic_udp::common::*;
|
use aquatic_udp::common::*;
|
||||||
use aquatic_udp::config::Config;
|
use aquatic_udp::config::Config;
|
||||||
|
|
||||||
use aquatic_udp_bench::pareto_usize;
|
|
||||||
|
|
||||||
use crate::common::*;
|
use crate::common::*;
|
||||||
use crate::config::BenchConfig;
|
use crate::config::BenchConfig;
|
||||||
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
|
|
||||||
use indicatif::{ProgressBar, ProgressStyle};
|
use indicatif::{ProgressBar, ProgressStyle};
|
||||||
|
use rand::Rng;
|
||||||
|
use rand_distr::Pareto;
|
||||||
|
|
||||||
|
|
||||||
pub const PARETO_SHAPE: f64 = 0.1;
|
pub const PARETO_SHAPE: f64 = 0.1;
|
||||||
|
|
@ -12,3 +13,15 @@ pub fn create_progress_bar(name: &str, iterations: u64) -> ProgressBar {
|
||||||
|
|
||||||
ProgressBar::new(iterations).with_style(style)
|
ProgressBar::new(iterations).with_style(style)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
pub fn pareto_usize(
|
||||||
|
rng: &mut impl Rng,
|
||||||
|
pareto: Pareto<f64>,
|
||||||
|
max: usize,
|
||||||
|
) -> usize {
|
||||||
|
let p: f64 = rng.sample(pareto);
|
||||||
|
let p = (p.min(101.0f64) - 1.0) / 100.0;
|
||||||
|
|
||||||
|
(p * max as f64) as usize
|
||||||
|
}
|
||||||
|
|
@ -1,14 +0,0 @@
|
||||||
use rand::Rng;
|
|
||||||
use rand_distr::Pareto;
|
|
||||||
|
|
||||||
|
|
||||||
pub fn pareto_usize(
|
|
||||||
rng: &mut impl Rng,
|
|
||||||
pareto: Pareto<f64>,
|
|
||||||
max: usize,
|
|
||||||
) -> usize {
|
|
||||||
let p: f64 = rng.sample(pareto);
|
|
||||||
let p = (p.min(101.0f64) - 1.0) / 100.0;
|
|
||||||
|
|
||||||
(p * max as f64) as usize
|
|
||||||
}
|
|
||||||
|
|
@ -9,8 +9,6 @@ use rand_distr::Pareto;
|
||||||
use aquatic_udp::common::*;
|
use aquatic_udp::common::*;
|
||||||
use aquatic_udp::config::Config;
|
use aquatic_udp::config::Config;
|
||||||
|
|
||||||
use aquatic_udp_bench::pareto_usize;
|
|
||||||
|
|
||||||
use crate::common::*;
|
use crate::common::*;
|
||||||
use crate::config::BenchConfig;
|
use crate::config::BenchConfig;
|
||||||
|
|
||||||
14
plot_pareto/Cargo.toml
Normal file
14
plot_pareto/Cargo.toml
Normal file
|
|
@ -0,0 +1,14 @@
|
||||||
|
[package]
|
||||||
|
name = "plot_pareto"
|
||||||
|
version = "0.1.0"
|
||||||
|
authors = ["Joakim Frostegård <joakim.frostegard@gmail.com>"]
|
||||||
|
edition = "2018"
|
||||||
|
license = "Apache-2.0"
|
||||||
|
|
||||||
|
[[bin]]
|
||||||
|
name = "plot_pareto"
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
plotly = "0.4"
|
||||||
|
rand = { version = "0.7", features = ["small_rng"] }
|
||||||
|
rand_distr = "0.2"
|
||||||
|
|
@ -1,11 +1,9 @@
|
||||||
use plotly::{Plot, Scatter, Layout};
|
use plotly::{Plot, Scatter, Layout};
|
||||||
use plotly::common::Title;
|
use plotly::common::Title;
|
||||||
use plotly::layout::Axis;
|
use plotly::layout::Axis;
|
||||||
use rand::{thread_rng, rngs::SmallRng, SeedableRng};
|
use rand::{thread_rng, rngs::SmallRng, SeedableRng, Rng};
|
||||||
use rand_distr::Pareto;
|
use rand_distr::Pareto;
|
||||||
|
|
||||||
use aquatic_udp_bench::pareto_usize;
|
|
||||||
|
|
||||||
|
|
||||||
fn main(){
|
fn main(){
|
||||||
let mut plot = Plot::new();
|
let mut plot = Plot::new();
|
||||||
|
|
@ -42,3 +40,15 @@ fn main(){
|
||||||
|
|
||||||
plot.show();
|
plot.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
pub fn pareto_usize(
|
||||||
|
rng: &mut impl Rng,
|
||||||
|
pareto: Pareto<f64>,
|
||||||
|
max: usize,
|
||||||
|
) -> usize {
|
||||||
|
let p: f64 = rng.sample(pareto);
|
||||||
|
let p = (p.min(101.0f64) - 1.0) / 100.0;
|
||||||
|
|
||||||
|
(p * max as f64) as usize
|
||||||
|
}
|
||||||
|
|
@ -2,4 +2,4 @@
|
||||||
|
|
||||||
export RUSTFLAGS="-C target-cpu=native"
|
export RUSTFLAGS="-C target-cpu=native"
|
||||||
|
|
||||||
cargo run --release --bin aquatic_udp_bench_handlers -- $@
|
cargo run --release --bin aquatic_udp_bench -- $@
|
||||||
Loading…
Add table
Add a link
Reference in a new issue