move plot_pareto from aquatic_udp_bench crate into own crate

This commit is contained in:
Joakim Frostegård 2020-05-25 19:37:11 +02:00
parent 2f13e1e1a8
commit 3addab07f0
14 changed files with 53 additions and 35 deletions

10
Cargo.lock generated
View file

@ -73,7 +73,6 @@ dependencies = [
"indicatif",
"mimalloc",
"num-format",
"plotly",
"rand",
"rand_distr",
"serde",
@ -935,6 +934,15 @@ version = "0.3.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "05da548ad6865900e60eaba7f589cc0783590a92e940c26953ff81ddbab2d677"
[[package]]
name = "plot_pareto"
version = "0.1.0"
dependencies = [
"plotly",
"rand",
"rand_distr",
]
[[package]]
name = "plotly"
version = "0.4.1"

View file

@ -8,6 +8,7 @@ members = [
"aquatic_udp_load_test",
"aquatic_udp_protocol",
"aquatic_ws",
"plot_pareto"
]
[profile.release]

View file

@ -11,9 +11,6 @@
use of Ipv4 ones, I have to check.
* More tests?
## aquatic_udp_bench
* move plot_pareto to own crate
## bittorrent_udp
* Tests with good known byte sequences (requests and responses)

View file

@ -5,15 +5,9 @@ authors = ["Joakim Frostegård <joakim.frostegard@gmail.com>"]
edition = "2018"
license = "Apache-2.0"
[lib]
[[bin]]
name = "aquatic_udp_bench"
[[bin]]
name = "aquatic_udp_bench_handlers"
[[bin]]
name = "plot_pareto"
[dependencies]
anyhow = "1"
aquatic_cli_helpers = { path = "../aquatic_cli_helpers" }
@ -22,7 +16,6 @@ crossbeam-channel = "0.4"
indicatif = "0.14"
mimalloc = { version = "0.1", default-features = false }
num-format = "0.4"
plotly = "0.4"
rand = { version = "0.7", features = ["small_rng"] }
rand_distr = "0.2"
serde = { version = "1", features = ["derive"] }

View file

@ -9,8 +9,6 @@ use rand_distr::Pareto;
use aquatic_udp::common::*;
use aquatic_udp::config::Config;
use aquatic_udp_bench::pareto_usize;
use crate::common::*;
use crate::config::BenchConfig;

View file

@ -1,5 +1,6 @@
use indicatif::{ProgressBar, ProgressStyle};
use rand::Rng;
use rand_distr::Pareto;
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)
}
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
}

View file

@ -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
}

View file

@ -9,8 +9,6 @@ use rand_distr::Pareto;
use aquatic_udp::common::*;
use aquatic_udp::config::Config;
use aquatic_udp_bench::pareto_usize;
use crate::common::*;
use crate::config::BenchConfig;

14
plot_pareto/Cargo.toml Normal file
View 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"

View file

@ -1,11 +1,9 @@
use plotly::{Plot, Scatter, Layout};
use plotly::common::Title;
use plotly::layout::Axis;
use rand::{thread_rng, rngs::SmallRng, SeedableRng};
use rand::{thread_rng, rngs::SmallRng, SeedableRng, Rng};
use rand_distr::Pareto;
use aquatic_udp_bench::pareto_usize;
fn main(){
let mut plot = Plot::new();
@ -42,3 +40,15 @@ fn main(){
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
}

View file

@ -2,4 +2,4 @@
export RUSTFLAGS="-C target-cpu=native"
cargo run --release --bin aquatic_udp_bench_handlers -- $@
cargo run --release --bin aquatic_udp_bench -- $@