refactor: run all benchmarks at once, leave only size run option
This commit is contained in:
parent
2214ff2425
commit
c1d0612115
1 changed files with 9 additions and 44 deletions
53
src/main.rs
53
src/main.rs
|
@ -19,18 +19,6 @@ pub struct BenchmarkCmd {
|
||||||
/// Size of the tree
|
/// Size of the tree
|
||||||
#[clap(short = 's', long = "size")]
|
#[clap(short = 's', long = "size")]
|
||||||
size: u64,
|
size: u64,
|
||||||
|
|
||||||
/// Run the construction benchmark
|
|
||||||
#[clap(short = 'c', long = "construction")]
|
|
||||||
construction: bool,
|
|
||||||
|
|
||||||
/// Run the insertion benchmark
|
|
||||||
#[clap(short = 'i', long = "insertion")]
|
|
||||||
insertion: bool,
|
|
||||||
|
|
||||||
/// Run the proof generation benchmark
|
|
||||||
#[clap(short = 'p', long = "proof-generation")]
|
|
||||||
proof_generation: bool,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
|
@ -50,35 +38,12 @@ pub fn benchmark_tsmt() {
|
||||||
leaves.push((key, value));
|
leaves.push((key, value));
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut tree: Option<TieredSmt> = None;
|
let mut tree = construction(leaves, tree_size).unwrap();
|
||||||
|
insertion(&mut tree, tree_size).unwrap();
|
||||||
// if the `-c` argument was specified
|
proof_generation(&mut tree, tree_size).unwrap();
|
||||||
if args.construction {
|
|
||||||
tree = Some(construction(leaves.clone(), tree_size).unwrap());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// if the `-i` argument was specified
|
/// Runs the construction benchmark for the Tiered SMT, returning the constructed tree.
|
||||||
if args.insertion {
|
|
||||||
if let Some(inner_tree) = tree {
|
|
||||||
tree = Some(insertion(inner_tree, tree_size).unwrap());
|
|
||||||
} else {
|
|
||||||
let inner_tree = TieredSmt::with_leaves(leaves.clone()).unwrap();
|
|
||||||
tree = Some(insertion(inner_tree, tree_size).unwrap());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// if the `-p` argument was specified
|
|
||||||
if args.proof_generation {
|
|
||||||
if let Some(inner_tree) = tree {
|
|
||||||
proof_generation(inner_tree, tree_size).unwrap();
|
|
||||||
} else {
|
|
||||||
let inner_tree = TieredSmt::with_leaves(leaves).unwrap();
|
|
||||||
proof_generation(inner_tree, tree_size).unwrap();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Run the construction benchmark for the Tiered SMT.
|
|
||||||
pub fn construction(leaves: Vec<(RpoDigest, Word)>, size: u64) -> Result<TieredSmt, MerkleError> {
|
pub fn construction(leaves: Vec<(RpoDigest, Word)>, size: u64) -> Result<TieredSmt, MerkleError> {
|
||||||
println!("Running a construction benchmark:");
|
println!("Running a construction benchmark:");
|
||||||
let now = Instant::now();
|
let now = Instant::now();
|
||||||
|
@ -108,8 +73,8 @@ pub fn construction(leaves: Vec<(RpoDigest, Word)>, size: u64) -> Result<TieredS
|
||||||
Ok(tree)
|
Ok(tree)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Run the insertion benchmark for the Tiered SMT.
|
/// Runs the insertion benchmark for the Tiered SMT.
|
||||||
pub fn insertion(mut tree: TieredSmt, size: u64) -> Result<TieredSmt, MerkleError> {
|
pub fn insertion(tree: &mut TieredSmt, size: u64) -> Result<(), MerkleError> {
|
||||||
println!("Running an insertion benchmark:");
|
println!("Running an insertion benchmark:");
|
||||||
|
|
||||||
let mut insertion_times = Vec::new();
|
let mut insertion_times = Vec::new();
|
||||||
|
@ -132,11 +97,11 @@ pub fn insertion(mut tree: TieredSmt, size: u64) -> Result<TieredSmt, MerkleErro
|
||||||
insertion_times.iter().sum::<f32>() * 50f32,
|
insertion_times.iter().sum::<f32>() * 50f32,
|
||||||
);
|
);
|
||||||
|
|
||||||
Ok(tree)
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Run the proof generation benchmark for the Tiered SMT.
|
/// Runs the proof generation benchmark for the Tiered SMT.
|
||||||
pub fn proof_generation(mut tree: TieredSmt, size: u64) -> Result<(), MerkleError> {
|
pub fn proof_generation(tree: &mut TieredSmt, size: u64) -> Result<(), MerkleError> {
|
||||||
println!("Running a proof generation benchmark:");
|
println!("Running a proof generation benchmark:");
|
||||||
|
|
||||||
let mut insertion_times = Vec::new();
|
let mut insertion_times = Vec::new();
|
||||||
|
|
Loading…
Add table
Reference in a new issue