From df8650b242d4daf2083e1d0c2e2afda8f66b864c Mon Sep 17 00:00:00 2001 From: Alin Tomescu Date: Tue, 9 Jul 2024 17:11:53 +0200 Subject: [PATCH] added benchmarks for G_T --- Cargo.toml | 1 - benches/bls12_381/ec.rs | 53 +++++++++++++++++++++++++++++++++++++++++ rust-toolchain | 1 - 3 files changed, 53 insertions(+), 2 deletions(-) delete mode 100644 rust-toolchain diff --git a/Cargo.toml b/Cargo.toml index b38c755..3a81ab4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,7 +9,6 @@ repository = "https://github.com/filecoin-project/blstrs" documentation = "https://docs.rs/blstrs" categories = ["cryptography", "algorithms"] readme = "README.md" -rust-version = "1.56.1" [package.metadata.docs.rs] rustdoc-args = [ "--html-in-header", "katex-header.html" ] diff --git a/benches/bls12_381/ec.rs b/benches/bls12_381/ec.rs index 639bcad..59a6d09 100644 --- a/benches/bls12_381/ec.rs +++ b/benches/bls12_381/ec.rs @@ -167,3 +167,56 @@ mod g2 { }); } } + +mod gt { + use rand_core::SeedableRng; + use rand_xorshift::XorShiftRng; + + use blstrs::*; + use ff::Field; + use group::Group; + + #[bench] + fn bench_gt_add_assign(b: &mut ::test::Bencher) { + const SAMPLES: usize = 1000; + + let mut rng = XorShiftRng::from_seed([ + 0x59, 0x62, 0xbe, 0x5d, 0x76, 0x3d, 0x31, 0x8d, 0x17, 0xdb, 0x37, 0x32, 0x54, 0x06, + 0xbc, 0xe5, + ]); + + let v: Vec<(Gt, Gt)> = (0..SAMPLES) + .map(|_| (Gt::random(&mut rng), Gt::random(&mut rng))) + .collect(); + + let mut count = 0; + b.iter(|| { + let mut tmp = v[count].0; + tmp += v[count].1; + count = (count + 1) % SAMPLES; + tmp + }); + } + + #[bench] + fn bench_gt_mul_assign(b: &mut ::test::Bencher) { + const SAMPLES: usize = 1000; + + let mut rng = XorShiftRng::from_seed([ + 0x59, 0x62, 0xbe, 0x5d, 0x76, 0x3d, 0x31, 0x8d, 0x17, 0xdb, 0x37, 0x32, 0x54, 0x06, + 0xbc, 0xe5, + ]); + + let v: Vec<(Gt, Scalar)> = (0..SAMPLES) + .map(|_| (Gt::random(&mut rng), Scalar::random(&mut rng))) + .collect(); + + let mut count = 0; + b.iter(|| { + let mut tmp = v[count].0; + tmp *= v[count].1; + count = (count + 1) % SAMPLES; + tmp + }); + } +} diff --git a/rust-toolchain b/rust-toolchain deleted file mode 100644 index 43c989b..0000000 --- a/rust-toolchain +++ /dev/null @@ -1 +0,0 @@ -1.56.1