Skip to content

Commit

Permalink
added benchmarks for G_T
Browse files Browse the repository at this point in the history
  • Loading branch information
alinush committed Jul 9, 2024
1 parent d4df485 commit df8650b
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 2 deletions.
1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" ]
Expand Down
53 changes: 53 additions & 0 deletions benches/bls12_381/ec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
});
}
}
1 change: 0 additions & 1 deletion rust-toolchain

This file was deleted.

0 comments on commit df8650b

Please sign in to comment.