diff --git a/examples/benches/README.md b/examples/benches/README.md index ad97741a04119364960df373e28678ed04dd5cfb..e8cb4e5d14f3825bc1f2a35f712c56ec0b805966 100644 --- a/examples/benches/README.md +++ b/examples/benches/README.md @@ -77,7 +77,7 @@ for graph in [ ## trusted setup ```nushell -use scripts/setup/run.nu; seq 0 13 | each { 2 ** $in } | run --output setup.ndjson +use scripts/setup/run.nu; seq 0 13 | each { 2 ** $in } | run --output setup.ndjson --curves [ bls12381, pallas, bn254 ] ``` ```nushell use ./scripts/setup/plot.nu; plot setup.ndjson @@ -85,7 +85,7 @@ use ./scripts/setup/plot.nu; plot setup.ndjson ## commit ```nushell -use scripts/commit/run.nu; seq 0 13 | each { 2 ** $in } | run --output commit.ndjson +use scripts/commit/run.nu; seq 0 13 | each { 2 ** $in } | run --output commit.ndjson --curves [bls12381, pallas, bn254 ] ``` ```nushell use ./scripts/commit/plot.nu; plot commit.ndjson @@ -95,7 +95,7 @@ use ./scripts/commit/plot.nu; plot commit.ndjson ### recoding ```nushell use scripts/recoding/run.nu -seq 0 18 | each { 512 * 2 ** $in } | run --ks [2, 4, 8, 16] --output recoding.ndjson +seq 0 18 | each { 512 * 2 ** $in } | run --ks [2, 4, 8, 16] --output recoding.ndjson --curves [ bls12381 ] ``` ```nushell use ./scripts/recoding/plot.nu; plot recoding.ndjson @@ -104,7 +104,7 @@ use ./scripts/recoding/plot.nu; plot recoding.ndjson ### FEC ```nushell use scripts/fec/run.nu -seq 0 18 | each { 512 * 2 ** $in } | run --ks [2, 4, 8, 16] --output fec.ndjson +seq 0 18 | each { 512 * 2 ** $in } | run --ks [2, 4, 8, 16] --output fec.ndjson --curves [ bls12381 ] ``` ```nushell use ./scripts/fec/plot.nu; plot encoding fec.ndjson diff --git a/examples/benches/commit.rs b/examples/benches/commit.rs index 653c6474d6e1091c02c103d046ce4dab4d770df4..8cda5e4616ce89b136244cc4013e98f67f597815 100644 --- a/examples/benches/commit.rs +++ b/examples/benches/commit.rs @@ -5,7 +5,7 @@ use ark_poly::{univariate::DensePolynomial, DenseUVPolynomial}; use ark_poly_commit::kzg10::{self, KZG10}; use ark_std::ops::Div; -use clap::{arg, command, Parser}; +use clap::{arg, command, Parser, ValueEnum}; use komodo::zk; fn run<F, G, P>(degrees: &Vec<usize>, curve: &str, nb_measurements: usize) @@ -86,27 +86,37 @@ where /// G1 = G1Projective, /// E = Bls12_381, /// name = "BLS12-381" -/// ); +/// ) /// ``` /// will produce /// ```rust -/// run::<ark_bls12_381::Fr, ark_bls12_381::G1Projective, DensePolynomial<ark_bls12_381::Fr> >(°rees, "BLS12-381", 10); -/// ark_run::<ark_bls12_381::Bls12_381, DensePolynomial<<ark_bls12_381::Bls12_381 as Pairing>::ScalarField>>(°rees, "BLS12-381", 10); +/// ark_run::<ark_bls12_381::Bls12_381, DensePolynomial<<ark_bls12_381::Bls12_381 as Pairing>::ScalarField>>(°rees, "BLS12-381", 10) /// ``` macro_rules! measure { ($c:ident, $d:ident, $m:expr, G1=$g:ident, name=$n:expr) => { - run::<$c::Fr, $c::$g, DensePolynomial<$c::Fr>>(&$d, $n, $m); + run::<$c::Fr, $c::$g, DensePolynomial<$c::Fr>>(&$d, $n, $m) }; ($c:ident, $d:ident, $m:expr, G1=$g:ident, E=$e:ident, name=$n:expr) => { - measure!($c, $d, $m, G1 = $g, name = $n); ark_run::<$c::$e, DensePolynomial<<$c::$e as Pairing>::ScalarField>>( &$d, concat!($n, "-ark"), $m, - ); + ) }; } +#[derive(ValueEnum, Clone, Hash, PartialEq, Eq)] +enum Curve { + BLS12381, + BN254, + Pallas, + ARKBLS12381, + ARKBN254, + SECP256K1, + SECP256R1, + Vesta, +} + #[derive(Parser)] #[command(version, about, long_about = None)] struct Cli { @@ -118,54 +128,91 @@ struct Cli { /// the measurements #[arg(short, long)] nb_measurements: usize, + + #[arg(short, long, num_args=1.., value_delimiter = ',')] + curves: Vec<Curve>, } fn main() { let cli = Cli::parse(); let degrees = cli.degrees; - measure!( - ark_pallas, - degrees, - cli.nb_measurements, - G1 = Projective, - name = "PALLAS" - ); - measure!( - ark_bls12_381, - degrees, - cli.nb_measurements, - G1 = G1Projective, - E = Bls12_381, - name = "BLS12-381" - ); - measure!( - ark_bn254, - degrees, - cli.nb_measurements, - G1 = G1Projective, - E = Bn254, - name = "BN-254" - ); - measure!( - ark_secp256k1, - degrees, - cli.nb_measurements, - G1 = Projective, - name = "SECP256-K1" - ); - measure!( - ark_secp256r1, - degrees, - cli.nb_measurements, - G1 = Projective, - name = "SECP256-R1" - ); - measure!( - ark_vesta, - degrees, - cli.nb_measurements, - G1 = Projective, - name = "VESTA" - ); + for curve in cli.curves { + match curve { + Curve::Pallas => { + measure!( + ark_pallas, + degrees, + cli.nb_measurements, + G1 = Projective, + name = "PALLAS" + ) + } + Curve::ARKBLS12381 => { + measure!( + ark_bls12_381, + degrees, + cli.nb_measurements, + G1 = G1Projective, + E = Bls12_381, + name = "BLS12-381" + ) + } + Curve::ARKBN254 => { + measure!( + ark_bn254, + degrees, + cli.nb_measurements, + G1 = G1Projective, + E = Bn254, + name = "BN254" + ) + } + Curve::BLS12381 => { + measure!( + ark_bls12_381, + degrees, + cli.nb_measurements, + G1 = G1Projective, + name = "BLS12-381" + ) + } + Curve::BN254 => { + measure!( + ark_bn254, + degrees, + cli.nb_measurements, + G1 = G1Projective, + name = "BN254" + ) + } + Curve::SECP256K1 => { + measure!( + ark_secp256k1, + degrees, + cli.nb_measurements, + G1 = Projective, + name = "SECP256-K1" + ) + } + Curve::SECP256R1 => { + measure!( + ark_secp256r1, + degrees, + cli.nb_measurements, + G1 = Projective, + name = "SECP256-R1" + ) + } + Curve::Vesta => { + measure!( + ark_vesta, + degrees, + cli.nb_measurements, + G1 = Projective, + name = "VESTA" + ) + } + } + } } diff --git a/examples/benches/fec.rs b/examples/benches/fec.rs index b4019becc910a539360d674b2655e257f6784cf1..90a16dd3a4021e1d6dfb840d1137edebd152c59a 100644 --- a/examples/benches/fec.rs +++ b/examples/benches/fec.rs @@ -68,6 +68,13 @@ enum Encoding { Random, } +#[derive(ValueEnum, Clone, Hash, PartialEq, Eq)] +enum Curve { + BLS12381, + BN254, + Pallas, +} + #[derive(Parser)] #[command(version, about, long_about = None)] struct Cli { @@ -78,6 +85,9 @@ struct Cli { #[arg(short, long)] encoding: Encoding, + #[arg(short, long, num_args=1.., value_delimiter = ' ')] + curves: Vec<Curve>, + #[arg(short)] k: usize, #[arg(short)] @@ -95,8 +105,26 @@ fn main() { let b = plnk::Bencher::new(cli.nb_measurements); for n in cli.sizes { - template::<ark_bls12_381::Fr>(&b.with_name("BLS12-381"), n, cli.k, cli.n, &cli.encoding); - template::<ark_bn254::Fr>(&b.with_name("BN-254"), n, cli.k, cli.n, &cli.encoding); - template::<ark_pallas::Fr>(&b.with_name("PALLAS"), n, cli.k, cli.n, &cli.encoding); + for curve in &cli.curves { + match curve { + Curve::BLS12381 => template::<ark_bls12_381::Fr>( + &b.with_name("BLS12-381"), + n, + cli.k, + cli.n, + &cli.encoding, + ), + Curve::BN254 => { + template::<ark_bn254::Fr>(&b.with_name("BN254"), n, cli.k, cli.n, &cli.encoding) + } + Curve::Pallas => template::<ark_pallas::Fr>( + &b.with_name("PALLAS"), + n, + cli.k, + cli.n, + &cli.encoding, + ), + } + } } } diff --git a/examples/benches/linalg.rs b/examples/benches/linalg.rs index 09950cfa41f4b6d5d7f72c5b3684722479d407c8..363317008ca2ad42f912b77089b7f19949119d52 100644 --- a/examples/benches/linalg.rs +++ b/examples/benches/linalg.rs @@ -53,15 +53,15 @@ fn main() { for n in cli.sizes { inverse_template::<ark_bls12_381::Fr>(&b.with_name("BLS12-381"), n); - inverse_template::<ark_bn254::Fr>(&b.with_name("BN-254"), n); + inverse_template::<ark_bn254::Fr>(&b.with_name("BN254"), n); inverse_template::<ark_pallas::Fr>(&b.with_name("PALLAS"), n); transpose_template::<ark_bls12_381::Fr>(&b.with_name("BLS12-381"), n); - transpose_template::<ark_bn254::Fr>(&b.with_name("BN-254"), n); + transpose_template::<ark_bn254::Fr>(&b.with_name("BN254"), n); transpose_template::<ark_pallas::Fr>(&b.with_name("PALLAS"), n); mul_template::<ark_bls12_381::Fr>(&b.with_name("BLS12-381"), n); - mul_template::<ark_bn254::Fr>(&b.with_name("BN-254"), n); + mul_template::<ark_bn254::Fr>(&b.with_name("BN254"), n); mul_template::<ark_pallas::Fr>(&b.with_name("PALLAS"), n); } } diff --git a/examples/benches/operations/curve_group.rs b/examples/benches/operations/curve_group.rs index 2d0aa793bc8a10f443e9058e887b3047604f9942..2f9bc2c41fdcb4e5c302b08adcb35b0d06388df4 100644 --- a/examples/benches/operations/curve_group.rs +++ b/examples/benches/operations/curve_group.rs @@ -79,6 +79,6 @@ fn main() { bench_template::<ark_bls12_381::Fr, ark_bls12_381::G1Projective>( &bencher.with_name("BLS12-381"), ); - bench_template::<ark_bn254::Fr, ark_bn254::G1Projective>(&bencher.with_name("BN-254")); + bench_template::<ark_bn254::Fr, ark_bn254::G1Projective>(&bencher.with_name("BN254")); bench_template::<ark_pallas::Fr, ark_pallas::Projective>(&bencher.with_name("PALLAS")); } diff --git a/examples/benches/operations/field.rs b/examples/benches/operations/field.rs index 9ebebd2b6a11cb6564a1808114b4d1f98ee8dea2..bbbbee53350cc5fc0635469199a2b41517b59128 100644 --- a/examples/benches/operations/field.rs +++ b/examples/benches/operations/field.rs @@ -91,6 +91,6 @@ fn main() { let bencher = plnk::Bencher::new(cli.nb_measurements); bench_template::<ark_bls12_381::Fr>(&bencher.with_name("BLS12-381")); - bench_template::<ark_bn254::Fr>(&bencher.with_name("BN-254")); + bench_template::<ark_bn254::Fr>(&bencher.with_name("BN254")); bench_template::<ark_pallas::Fr>(&bencher.with_name("PALLAS")); } diff --git a/examples/benches/recoding.rs b/examples/benches/recoding.rs index 96b3f3efbd8e5bb0da98f301621b24cc8717f5ea..b7bce6153e60c56073d78a381ab12236869de56b 100644 --- a/examples/benches/recoding.rs +++ b/examples/benches/recoding.rs @@ -2,7 +2,7 @@ use ark_ff::PrimeField; use ark_std::rand::Rng; -use clap::{arg, command, Parser}; +use clap::{arg, command, Parser, ValueEnum}; use komodo::{ fec::{recode_with_coeffs, Shard}, field, @@ -48,6 +48,13 @@ fn bench_template<F: PrimeField>(b: &Bencher, nb_bytes: usize, k: usize, nb_shar ); } +#[derive(ValueEnum, Clone, Hash, PartialEq, Eq)] +enum Curve { + BLS12381, + BN254, + Pallas, +} + #[derive(Parser)] #[command(version, about, long_about = None)] struct Cli { @@ -60,6 +67,9 @@ struct Cli { #[arg(short, long, num_args = 1.., value_delimiter = ' ')] ks: Vec<usize>, + #[arg(short, long, num_args=1.., value_delimiter = ' ')] + curves: Vec<Curve>, + /// the number of measurements to repeat each case, larger values will reduce the variance of /// the measurements #[arg(short, long)] @@ -74,9 +84,25 @@ fn main() { for b in cli.bytes { for s in &cli.shards { for k in &cli.ks { - bench_template::<ark_bls12_381::Fr>(&bencher.with_name("BLS12-381"), b, *k, *s); - bench_template::<ark_bn254::Fr>(&bencher.with_name("BN-254"), b, *k, *s); - bench_template::<ark_pallas::Fr>(&bencher.with_name("PALLAS"), b, *k, *s); + for curve in &cli.curves { + match curve { + Curve::BLS12381 => bench_template::<ark_bls12_381::Fr>( + &bencher.with_name("BLS12-381"), + b, + *k, + *s, + ), + Curve::BN254 => { + bench_template::<ark_bn254::Fr>(&bencher.with_name("BN254"), b, *k, *s) + } + Curve::Pallas => bench_template::<ark_pallas::Fr>( + &bencher.with_name("PALLAS"), + b, + *k, + *s, + ), + } + } } } } diff --git a/examples/benches/setup.rs b/examples/benches/setup.rs index 7c1b079f73fe0465947b3df04e8ceee2c2f5e9db..39b2ab770345460d0a59d371d922ddc3ab54ee64 100644 --- a/examples/benches/setup.rs +++ b/examples/benches/setup.rs @@ -6,7 +6,7 @@ use ark_poly_commit::kzg10::{self, KZG10}; use ark_serialize::{CanonicalDeserialize, CanonicalSerialize, Compress, Validate}; use ark_std::ops::Div; -use clap::{command, Parser}; +use clap::{command, Parser, ValueEnum}; use komodo::zk::{self, Powers}; use plnk::Bencher; @@ -117,21 +117,14 @@ where } } -fn setup(degrees: &[usize], nb_measurements: usize) { - fn aux<F: PrimeField, G: CurveGroup<ScalarField = F>>( - degree: usize, - curve: &str, - nb_measurements: usize, - ) { - let b = plnk::Bencher::new(nb_measurements).with_name(format!("setup on {}", curve)); - setup_template::<F, G, DensePolynomial<F>>(&b, degree); - } - +fn setup<F: PrimeField, G: CurveGroup<ScalarField = F>>( + degrees: &[usize], + nb_measurements: usize, + curve: &str, +) { for d in degrees { - aux::<ark_bls12_381::Fr, ark_bls12_381::G1Projective>(*d, "BLS12-381", nb_measurements); - aux::<ark_bn254::Fr, ark_bn254::G1Projective>(*d, "BN-254", nb_measurements); - aux::<ark_pallas::Fr, ark_pallas::Projective>(*d, "PALLAS", nb_measurements); - aux::<ark_vesta::Fr, ark_vesta::Projective>(*d, "VESTA", nb_measurements); + let b = plnk::Bencher::new(nb_measurements).with_name(format!("setup on {}", curve)); + setup_template::<F, G, DensePolynomial<F>>(&b, *d); } } @@ -149,22 +142,26 @@ fn serde(degrees: &[usize], nb_measurements: usize) { for d in degrees { aux::<ark_bls12_381::Fr, ark_bls12_381::G1Projective>(*d, "BLS12-381", nb_measurements); - aux::<ark_bn254::Fr, ark_bn254::G1Projective>(*d, "BN-254", nb_measurements); + aux::<ark_bn254::Fr, ark_bn254::G1Projective>(*d, "BN254", nb_measurements); aux::<ark_pallas::Fr, ark_pallas::Projective>(*d, "PALLAS", nb_measurements); aux::<ark_vesta::Fr, ark_vesta::Projective>(*d, "VESTA", nb_measurements); } } -fn ark_setup(degrees: &[usize], nb_measurements: usize) { - fn aux<E: Pairing>(degree: usize, curve: &str, nb_measurements: usize) { +fn ark_setup<E: Pairing>(degrees: &[usize], nb_measurements: usize, curve: &str) { + for d in degrees { let b = plnk::Bencher::new(nb_measurements).with_name(format!("ARK setup on {}", curve)); - ark_setup_template::<E, DensePolynomial<E::ScalarField>>(&b, degree); + ark_setup_template::<E, DensePolynomial<E::ScalarField>>(&b, *d); } +} - for d in degrees { - aux::<ark_bls12_381::Bls12_381>(*d, "BLS12-381", nb_measurements); - aux::<ark_bn254::Bn254>(*d, "BN-254", nb_measurements); - } +#[derive(ValueEnum, Clone, Hash, PartialEq, Eq)] +enum Curve { + BLS12381, + BN254, + Pallas, + ARKBLS12381, + ARKBN254, } #[derive(Parser)] @@ -178,13 +175,50 @@ struct Cli { /// the measurements #[arg(short, long)] nb_measurements: usize, + + #[arg(short, long, num_args=1.., value_delimiter = ',')] + curves: Vec<Curve>, } fn main() { let cli = Cli::parse(); - setup(&cli.degrees, cli.nb_measurements); - ark_setup(&cli.degrees, cli.nb_measurements); + for curve in cli.curves { + match curve { + Curve::ARKBN254 => { + ark_setup::<ark_bn254::Bn254>(&cli.degrees, cli.nb_measurements, "BN254"); + } + Curve::ARKBLS12381 => { + ark_setup::<ark_bls12_381::Bls12_381>( + &cli.degrees, + cli.nb_measurements, + "BLS12-381", + ); + } + Curve::Pallas => { + setup::<ark_pallas::Fr, ark_pallas::Projective>( + &cli.degrees, + cli.nb_measurements, + "PALLAS", + ); + } + Curve::BN254 => { + setup::<ark_bn254::Fr, ark_bn254::G1Projective>( + &cli.degrees, + cli.nb_measurements, + "BN254", + ); + } + Curve::BLS12381 => { + setup::<ark_bls12_381::Fr, ark_bls12_381::G1Projective>( + &cli.degrees, + cli.nb_measurements, + "BLS12-381", + ); + } + } + } + // NOTE: this is disabled for now because it takes so much time... // serde(&cli.degrees, cli.nb_measurements); } diff --git a/examples/benches/setup_size.rs b/examples/benches/setup_size.rs index d1a2127c123d1194c417eb65e280e210793748d3..0642912d96656f9662282f7db1f577f928d2b40d 100644 --- a/examples/benches/setup_size.rs +++ b/examples/benches/setup_size.rs @@ -41,7 +41,7 @@ fn main() { for n in [1, 2, 4, 8, 16] { aux::<ark_bls12_381::Fr, ark_bls12_381::G1Projective>(n, "BLS12-381"); - aux::<ark_bn254::Fr, ark_bn254::G1Projective>(n, "BN-254"); + aux::<ark_bn254::Fr, ark_bn254::G1Projective>(n, "BN254"); aux::<ark_pallas::Fr, ark_pallas::Projective>(n, "PALLAS"); } } diff --git a/scripts/commit/plot.nu b/scripts/commit/plot.nu index daf5d490cf30cb438d82963ea09f04bea0e194b6..d89ad560711f30075f602e51e978dcaa31f0a0e7 100644 --- a/scripts/commit/plot.nu +++ b/scripts/commit/plot.nu @@ -1,23 +1,11 @@ use ../math.nu * use ../fs.nu check-file -use ../plot.nu gplt +use ../plot.nu [ into-axis-options, COMMON_OPTIONS, gplt ] export def main [data: path, --save: path] { - let options = [ - # --title "time to commit polynomials for certain curves" - --x-label "degree" - --y-label "time (in ms)" - --fullscreen - --dpi 150 - --fig-size ...[16, 9] - --font ({ size: 30, family: serif, sans-serif: Helvetica } | to json) - --use-tex - (if $save != null { [ --save $save ] }) - ] - check-file $data --span (metadata $data).span - open $data + let graphs = open $data | where name !~ '^SEC' | ns-to-ms $.times | compute-stats $.times @@ -28,5 +16,15 @@ export def main [data: path, --save: path] { | reject items.name | rename --column { group: "name", items: "points" } | sort-by name - | gplt plot ($in | to json) ...($options | flatten | compact) + + let options = [ + # --title "time to create trusted setups for certain curves" + --x-label "degree" + --y-label "time (in ms)" + ...($graphs.points | flatten | into-axis-options -x "plain" -y "duration") + ...$COMMON_OPTIONS + (if $save != null { [ --save $save ] }) + ] + + gplt plot ($graphs | to json) ...($options | flatten | compact) } diff --git a/scripts/commit/run.nu b/scripts/commit/run.nu index 9c0df230eb38cb86ec70641efe84e75f777f1e1d..b5f4e940cff7ed4a82f55df1ecbdf8aa83184c5a 100644 --- a/scripts/commit/run.nu +++ b/scripts/commit/run.nu @@ -1,5 +1,13 @@ -export def main [--output: path = "./commit.ndjson", --nb-measurements: int = 10]: list<int> -> nothing { - cargo run --release --example bench_commit -- --nb-measurements $nb_measurements ...$in out> $output +export def main [ + --output: path = "./commit.ndjson", + --nb-measurements: int = 10, + --curves: list<string>, +]: list<int> -> nothing { + cargo run --release --example bench_commit -- ...[ + --nb-measurements $nb_measurements + ...$in + --curves ...$curves + ] out> $output print $"results saved to `($output)`" } diff --git a/scripts/fec/plot.nu b/scripts/fec/plot.nu index 95cec1e37df58157a9b3c21b2f69ff2fd5f44f43..e8b90bdfcc69d031d7019eea5901848a81d9d797 100644 --- a/scripts/fec/plot.nu +++ b/scripts/fec/plot.nu @@ -22,7 +22,7 @@ export def encoding [data: path, --save: path] { let options = [ # --title "1-encoding" - ...($graphs.points | flatten | into-axis-options -y "duration") + ...($graphs.points | flatten | into-axis-options -x "filesize" -y "duration") ...$COMMON_OPTIONS (if $save != null { [ --save $save ] }) ] @@ -49,7 +49,7 @@ export def decoding [data: path, --save: path] { let options = [ # --title "k-encoding" - ...($graphs.points | flatten | into-axis-options -y "duration") + ...($graphs.points | flatten | into-axis-options -x "filesize" -y "duration") --no-legend ...$COMMON_OPTIONS (if $save != null { [ --save $save ] }) @@ -87,7 +87,7 @@ export def e2e [data: path, --save: path] { let options = [ # --title "k-encoding + 1-encoding" - ...($graphs.points | flatten | into-axis-options -y "duration") + ...($graphs.points | flatten | into-axis-options -x "filesize" -y "duration") --no-legend ...$COMMON_OPTIONS (if $save != null { [ --save $save ] }) @@ -190,7 +190,7 @@ export def combined [data: path, --recoding: path, --save: path] { } let options = [ - ...($graphs.points | flatten | into-axis-options -y "duration") + ...($graphs.points | flatten | into-axis-options -x "filesize" -y "duration") --legend-loc "upper left" "lower right" ...$COMMON_OPTIONS (if $save != null { [ --save $save ] }) @@ -254,7 +254,7 @@ export def ratio [data: path, --recoding: path, --save: path] { | update name { $"$k = ($in)$" } let options = [ - ...($graphs.points | flatten | into-axis-options) + ...($graphs.points | flatten | into-axis-options -x "filesize" -y "plain") --legend-loc "upper right" ...$COMMON_OPTIONS (if $save != null { [ --save $save ] }) diff --git a/scripts/fec/run.nu b/scripts/fec/run.nu index 8027b861a5a11fbde8f4764f18e71fe17ada2378..9fec0eb413b0d99855f970475e1e179ea8b864d2 100644 --- a/scripts/fec/run.nu +++ b/scripts/fec/run.nu @@ -3,7 +3,8 @@ use ../formats.nu * export def main [ --output: path = "./fec.ndjson", --nb-measurements: int = 10, - --ks: list<int> + --ks: list<int>, + --curves: list<string>, ]: list<int> -> nothing { let input = $in @@ -21,6 +22,7 @@ export def main [ --encoding vandermonde -k $k -n 1 + --curves ...$curves ] | from ndnuon | to ndjson out>> $output } } diff --git a/scripts/plot.nu b/scripts/plot.nu index 254476e11eb04cf083ffbdcd3ee5c3f78a18faf8..76d5c7dc1fe388094815e70a48c309fd17a91082 100644 --- a/scripts/plot.nu +++ b/scripts/plot.nu @@ -30,15 +30,23 @@ export def into-filesize-tick-labels []: list<int> -> list<string> { | each { to text | str replace ".0 " " " } } -export def into-axis-options [-y: string]: table<x: float, y: float> -> list<string> { +export def into-axis-options [-x: string, -y: string]: table<x: float, y: float> -> list<string> { let input = $in let xs = $input | flatten | get x | uniq + let x_tick_labels = match $x { + "filesize" => ($xs | into-filesize-tick-labels), + "plain" => $xs, + _ => { + print $"warning: ($y) option is unknown for -y" + $xs + }, + } let options = [ --x-lim ($xs | first) ($xs | last) --x-ticks ...$xs - --x-tick-labels ...($xs | into-filesize-tick-labels) + --x-tick-labels ...$x_tick_labels ] let ys = $input | flatten | get y diff --git a/scripts/recoding/plot.nu b/scripts/recoding/plot.nu index 486657e102b049768c569eb006f12e1ae114fa7e..c803fcd48fe45e5ae75bfd97b6d8b0520fc13730 100644 --- a/scripts/recoding/plot.nu +++ b/scripts/recoding/plot.nu @@ -21,7 +21,7 @@ export def main [data: path, --save: path] { let options = [ # --y-label "time (in ms)" - ...($graphs.points | flatten | into-axis-options -y "duration") + ...($graphs.points | flatten | into-axis-options -x "filesize" -y "duration") --no-legend ...$COMMON_OPTIONS (if $save != null { [ --save $save ] }) diff --git a/scripts/recoding/run.nu b/scripts/recoding/run.nu index c716546efe703cb52372979accb500f1adebd0f6..4b1ef6e552004908ac6a0d660377915c4ec87fd4 100644 --- a/scripts/recoding/run.nu +++ b/scripts/recoding/run.nu @@ -3,7 +3,8 @@ use ../formats.nu * export def main [ --output: path = "./recoding.ndjson", --nb-measurements: int = 10, - --ks: list<int> + --ks: list<int>, + --curves: list<string>, ]: list<int> -> nothing { let input = $in @@ -20,6 +21,7 @@ export def main [ ...$input --shards $k --ks $k + --curves ...$curves ] | from ndnuon | to ndjson out>> $output } } diff --git a/scripts/setup/plot.nu b/scripts/setup/plot.nu index 001d6aacfb8cad759e311c3adbc69f459e150d59..a6baeebaeb64f944bb1ae992b5e2d2f0a3862a4f 100644 --- a/scripts/setup/plot.nu +++ b/scripts/setup/plot.nu @@ -1,23 +1,11 @@ use ../math.nu * use ../fs.nu check-file -use ../plot.nu gplt +use ../plot.nu [ into-axis-options, COMMON_OPTIONS, gplt ] export def main [data: path, --save: path] { - let options = [ - # --title "time to create trusted setups for certain curves" - --x-label "degree" - --y-label "time (in ms)" - --fullscreen - --dpi 150 - --fig-size ...[16, 9] - --font ({ size: 30, family: serif, sans-serif: Helvetica } | to json) - --use-tex - (if $save != null { [ --save $save ] }) - ] - check-file $data --span (metadata $data).span - open $data + let graphs = open $data | ns-to-ms times | compute-stats times | insert degree { get label | parse "degree {d}" | into record | get d | into int} @@ -33,5 +21,15 @@ export def main [data: path, --save: path] { | reject items.name | rename --column { group: "name", items: "points" } | sort-by name - | gplt plot ($in | to json) ...($options | flatten | compact) + + let options = [ + # --title "time to create trusted setups for certain curves" + --x-label "degree" + --y-label "time (in ms)" + ...($graphs.points | flatten | into-axis-options -x "plain" -y "duration") + ...$COMMON_OPTIONS + (if $save != null { [ --save $save ] }) + ] + + gplt plot ($graphs | to json) ...($options | flatten | compact) } diff --git a/scripts/setup/run.nu b/scripts/setup/run.nu index d5ad502b79b30abce68c0cd9a33124584b46b4a9..5473d54a52dfd8d74aa39439aa8d7fb790c65326 100644 --- a/scripts/setup/run.nu +++ b/scripts/setup/run.nu @@ -1,5 +1,13 @@ -export def main [--output: path = "./setup.ndjson", --nb-measurements: int = 10]: list<int> -> nothing { - cargo run --release --example bench_setup -- --nb-measurements $nb_measurements ...$in out> $output +export def main [ + --output: path = "./setup.ndjson", + --nb-measurements: int = 10, + --curves: list<string>, +]: list<int> -> nothing { + cargo run --release --example bench_setup -- ...[ + --nb-measurements $nb_measurements + ...$in + --curves ...$curves + ] out> $output print $"results saved to `($output)`" }