-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
113 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -89,3 +89,7 @@ harness = false | |
[[bench]] | ||
name = "lincomb" | ||
harness = false | ||
|
||
[[bench]] | ||
name = "trusted_setup" | ||
harness = false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
use criterion::{criterion_group, criterion_main, Criterion}; | ||
use kzg::eip_4844::load_trusted_setup_rust; | ||
use kzg_bench::benches::trusted_setup::bench_load_trusted_setup; | ||
use rust_kzg_blst::{ | ||
eip_4844::load_trusted_setup_filename_rust, | ||
types::{ | ||
fft_settings::FsFFTSettings, | ||
fp::FsFp, | ||
fr::FsFr, | ||
g1::{FsG1, FsG1Affine}, | ||
g2::FsG2, | ||
kzg_settings::FsKZGSettings, | ||
poly::FsPoly, | ||
}, | ||
}; | ||
|
||
fn bench_load_trusted_setup_(c: &mut Criterion) { | ||
bench_load_trusted_setup::< | ||
FsFr, | ||
FsG1, | ||
FsG2, | ||
FsPoly, | ||
FsFFTSettings, | ||
FsKZGSettings, | ||
FsFp, | ||
FsG1Affine, | ||
>( | ||
c, | ||
&load_trusted_setup_filename_rust, | ||
&load_trusted_setup_rust, | ||
); | ||
} | ||
|
||
criterion_group!(benches, bench_load_trusted_setup_); | ||
criterion_main!(benches); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,4 +7,5 @@ pub mod kzg; | |
pub mod lincomb; | ||
pub mod poly; | ||
pub mod recover; | ||
pub mod trusted_setup; | ||
pub mod zero_poly; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
use criterion::Criterion; | ||
use kzg::{ | ||
eip_4844::TRUSTED_SETUP_PATH, FFTSettings, Fr, G1Affine, G1Fp, G1GetFp, G1Mul, KZGSettings, | ||
Poly, G1, G2, | ||
}; | ||
use std::{fs::File, io::Read, path::PathBuf}; | ||
|
||
pub fn bench_load_trusted_setup< | ||
TFr: Fr + std::fmt::Debug, | ||
TG1: G1 + G1Mul<TFr> + G1GetFp<TG1Fp>, | ||
TG2: G2, | ||
TPoly: Poly<TFr>, | ||
TFFTSettings: FFTSettings<TFr>, | ||
TKZGSettings: KZGSettings<TFr, TG1, TG2, TFFTSettings, TPoly, TG1Fp, TG1Affine>, | ||
TG1Fp: G1Fp, | ||
TG1Affine: G1Affine<TG1, TG1Fp>, | ||
>( | ||
c: &mut Criterion, | ||
load_trusted_setup_file: &dyn Fn(&str) -> Result<TKZGSettings, String>, | ||
load_trusted_setup: &dyn Fn(&[u8], &[u8], &[u8]) -> Result<TKZGSettings, String>, | ||
Check failure on line 20 in kzg-bench/src/benches/trusted_setup.rs GitHub Actions / kzg_ci
Check failure on line 20 in kzg-bench/src/benches/trusted_setup.rs GitHub Actions / backend_ci (ubuntu-latest, blst)
Check failure on line 20 in kzg-bench/src/benches/trusted_setup.rs GitHub Actions / backend_ci (ubuntu-latest, arkworks)
|
||
) { | ||
let path = PathBuf::from(env!("CARGO_MANIFEST_DIR")) | ||
.join(TRUSTED_SETUP_PATH) | ||
.to_string_lossy() | ||
.to_string(); | ||
|
||
c.bench_function("load_trusted_setup_file", |b| { | ||
b.iter(|| { | ||
let _ = load_trusted_setup_file(path.as_str()).unwrap(); | ||
}); | ||
}); | ||
|
||
c.bench_function("load_trusted_setup", |b| { | ||
let mut file = File::open(path.clone()).unwrap(); | ||
let mut source = String::new(); | ||
file.read_to_string(&mut source).unwrap(); | ||
let bytes = kzg::eip_4844::load_trusted_setup_string(source.as_str()).unwrap(); | ||
|
||
b.iter(|| { | ||
let _ = load_trusted_setup(&bytes.0, &bytes.1, &bytes.2).unwrap(); | ||
}); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
use criterion::{criterion_group, criterion_main, Criterion}; | ||
use rust_eth_kzg::{DASContext, TrustedSetup, UsePrecomp}; | ||
|
||
fn bench_load_trusted_setup( | ||
c: &mut Criterion | ||
) { | ||
c.bench_function("load_trusted_setup", |b| { | ||
|
||
b.iter(|| { | ||
let trusted_setup = TrustedSetup::default(); | ||
|
||
#[cfg(feature = "parallel")] | ||
let _ = DASContext::with_threads( | ||
&trusted_setup, | ||
rust_eth_kzg::ThreadCount::Multi(std::thread::available_parallelism().unwrap().into()), | ||
UsePrecomp::Yes { width: 8 }, | ||
); | ||
|
||
#[cfg(not(feature = "parallel"))] | ||
let _ = DASContext::new(&trusted_setup, UsePrecomp::Yes { width: 8 }); | ||
}); | ||
}); | ||
} | ||
|
||
criterion_group!(benches, bench_load_trusted_setup); | ||
criterion_main!(benches); |