Skip to content

Commit

Permalink
fix: update benches
Browse files Browse the repository at this point in the history
  • Loading branch information
cryptonemo committed Nov 11, 2020
1 parent 8a9d971 commit 8e27774
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 9 deletions.
12 changes: 8 additions & 4 deletions storage-proofs/core/benches/drgraph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,21 @@ use storage_proofs_core::drgraph::*;

#[allow(clippy::unit_arg)]
fn drgraph(c: &mut Criterion) {
let api_version = ApiVersion::V1_1;
let params = vec![12, 24, 128, 1024];

c.bench(
"sample",
ParameterizedBenchmark::new(
"bucket/m=6",
|b, n| {
let graph =
BucketGraph::<PoseidonHasher>::new(*n, BASE_DEGREE, 0, [32; 32], api_version)
.unwrap();
let graph = BucketGraph::<PoseidonHasher>::new(
*n,
BASE_DEGREE,
0,
[32; 32],
ApiVersion::V1_1,
)
.unwrap();

b.iter(|| {
let mut parents = vec![0; 6];
Expand Down
4 changes: 3 additions & 1 deletion storage-proofs/porep/benches/encode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use filecoin_hashers::{
{Domain, Hasher},
};
use rand::thread_rng;
use storage_proofs_core::api_version::ApiVersion;
use storage_proofs_core::fr32::fr_into_bytes;
use storage_proofs_porep::stacked::{
create_label::single::{create_label, create_label_exp},
Expand All @@ -22,12 +23,13 @@ fn pregenerate_data<H: Hasher>(degree: usize) -> Pregenerated<H> {
assert_eq!(degree, 6 + 8);
let mut rng = thread_rng();
let size = degree * 4 * 1024 * 1024;
let api_version = ApiVersion::V1_0;
let data: Vec<u8> = (0..size)
.flat_map(|_| fr_into_bytes(&Fr::random(&mut rng)))
.collect();
let replica_id: H::Domain = H::Domain::random(&mut rng);

let graph = StackedBucketGraph::<H>::new_stacked(size, 6, 8, [32; 32]).unwrap();
let graph = StackedBucketGraph::<H>::new_stacked(size, 6, 8, [32; 32], api_version).unwrap();

Pregenerated {
data,
Expand Down
10 changes: 6 additions & 4 deletions storage-proofs/porep/benches/parents.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use criterion::{black_box, criterion_group, criterion_main, Criterion, ParameterizedBenchmark};
use filecoin_hashers::{blake2s::Blake2sHasher, sha256::Sha256Hasher, Hasher};
use storage_proofs_core::api_version::ApiVersion;
use storage_proofs_core::drgraph::{Graph, BASE_DEGREE};
use storage_proofs_porep::stacked::{StackedBucketGraph, EXP_DEGREE};

Expand Down Expand Up @@ -31,8 +32,9 @@ fn stop_profile() {
#[inline(always)]
fn stop_profile() {}

fn pregenerate_graph<H: Hasher>(size: usize) -> StackedBucketGraph<H> {
StackedBucketGraph::<H>::new_stacked(size, BASE_DEGREE, EXP_DEGREE, [32; 32]).unwrap()
fn pregenerate_graph<H: Hasher>(size: usize, api_version: ApiVersion) -> StackedBucketGraph<H> {
StackedBucketGraph::<H>::new_stacked(size, BASE_DEGREE, EXP_DEGREE, [32; 32], api_version)
.unwrap()
}

fn parents_loop<H: Hasher, G: Graph<H>>(graph: &G, parents: &mut [u32]) {
Expand All @@ -50,7 +52,7 @@ fn parents_loop_benchmark(cc: &mut Criterion) {
ParameterizedBenchmark::new(
"Blake2s",
|b, size| {
let graph = pregenerate_graph::<Blake2sHasher>(*size);
let graph = pregenerate_graph::<Blake2sHasher>(*size, ApiVersion::V1_1);
let mut parents = vec![0; graph.degree()];
start_profile(&format!("parents-blake2s-{}", *size));
b.iter(|| black_box(parents_loop::<Blake2sHasher, _>(&graph, &mut parents)));
Expand All @@ -59,7 +61,7 @@ fn parents_loop_benchmark(cc: &mut Criterion) {
sizes,
)
.with_function("Sha256", |b, degree| {
let graph = pregenerate_graph::<Sha256Hasher>(*degree);
let graph = pregenerate_graph::<Sha256Hasher>(*degree, ApiVersion::V1_1);
let mut parents = vec![0; graph.degree()];
b.iter(|| black_box(parents_loop::<Sha256Hasher, _>(&graph, &mut parents)))
}),
Expand Down

0 comments on commit 8e27774

Please sign in to comment.