|
|
@ -46,7 +46,7 @@ pub fn construction(entries: Vec<(RpoDigest, Word)>, size: u64) -> Result |
|
|
|
let tree = Smt::with_entries(entries)?;
|
|
|
|
let elapsed = now.elapsed();
|
|
|
|
println!(
|
|
|
|
"Constructed a SMT with {} key-value pairs in {:.3} seconds",
|
|
|
|
"Constructed a SMT with {} key-value pairs in {:.1} seconds",
|
|
|
|
size,
|
|
|
|
elapsed.as_secs_f32(),
|
|
|
|
);
|
|
|
@ -62,7 +62,8 @@ pub fn insertion(tree: &mut Smt, size: u64) -> Result<(), MerkleError> { |
|
|
|
|
|
|
|
let mut insertion_times = Vec::new();
|
|
|
|
|
|
|
|
for i in 0..20 {
|
|
|
|
const N: u64 = 100;
|
|
|
|
for i in 0..N {
|
|
|
|
let test_key = Rpo256::hash(&rand_value::<u64>().to_be_bytes());
|
|
|
|
let test_value = [ONE, ONE, ONE, Felt::new(size + i)];
|
|
|
|
|
|
|
@ -73,11 +74,10 @@ pub fn insertion(tree: &mut Smt, size: u64) -> Result<(), MerkleError> { |
|
|
|
}
|
|
|
|
|
|
|
|
println!(
|
|
|
|
"An average insertion time measured by 20 inserts into a SMT with {} key-value pairs is {:.3} milliseconds\n",
|
|
|
|
size,
|
|
|
|
// calculate the average by dividing by 20 and convert to milliseconds by multiplying by
|
|
|
|
// 1000. As a result, we can only multiply by 50
|
|
|
|
insertion_times.iter().sum::<f32>() * 50f32,
|
|
|
|
"An average insertion time measured by {N} inserts into a SMT with {size} key-value pairs is {:.1} ms\n",
|
|
|
|
// calculate the average by dividing by 100 and convert to milliseconds by multiplying by
|
|
|
|
// 1000. As a result, we can only multiply by 10
|
|
|
|
insertion_times.iter().sum::<f32>() * 10_f32,
|
|
|
|
);
|
|
|
|
|
|
|
|
Ok(())
|
|
|
@ -103,7 +103,7 @@ pub fn batched_insertion(tree: &mut Smt, size: u64) -> Result<(), MerkleError> { |
|
|
|
let apply_elapsed = now.elapsed();
|
|
|
|
|
|
|
|
println!(
|
|
|
|
"An average batch computation time measured by a 1k-batch into an SMT with {} key-value pairs over {:.3} milliseconds is {:.3} milliseconds",
|
|
|
|
"An average batch computation time measured by a 1k-batch into an SMT with {} key-value pairs over {:.1} ms is {:.3} ms",
|
|
|
|
size,
|
|
|
|
compute_elapsed.as_secs_f32() * 1000f32,
|
|
|
|
// Dividing by the number of iterations, 1000, and then multiplying by 1000 to get
|
|
|
@ -112,7 +112,7 @@ pub fn batched_insertion(tree: &mut Smt, size: u64) -> Result<(), MerkleError> { |
|
|
|
);
|
|
|
|
|
|
|
|
println!(
|
|
|
|
"An average batch application time measured by a 1k-batch into an SMT with {} key-value pairs over {:.3} milliseconds is {:.3} milliseconds",
|
|
|
|
"An average batch application time measured by a 1k-batch into an SMT with {} key-value pairs over {:.1} ms is {:.3} ms",
|
|
|
|
size,
|
|
|
|
apply_elapsed.as_secs_f32() * 1000f32,
|
|
|
|
// Dividing by the number of iterations, 1000, and then multiplying by 1000 to get
|
|
|
@ -121,7 +121,7 @@ pub fn batched_insertion(tree: &mut Smt, size: u64) -> Result<(), MerkleError> { |
|
|
|
);
|
|
|
|
|
|
|
|
println!(
|
|
|
|
"An average batch insertion time measured by a 1k-batch into an SMT with {} key-value pairs totals to {:.3} milliseconds",
|
|
|
|
"An average batch insertion time measured by a 1k-batch into an SMT with {} key-value pairs totals to {:.1} ms",
|
|
|
|
size,
|
|
|
|
(compute_elapsed + apply_elapsed).as_secs_f32() * 1000f32,
|
|
|
|
);
|
|
|
@ -137,7 +137,8 @@ pub fn proof_generation(tree: &mut Smt, size: u64) -> Result<(), MerkleError> { |
|
|
|
|
|
|
|
let mut insertion_times = Vec::new();
|
|
|
|
|
|
|
|
for i in 0..20 {
|
|
|
|
const N: u64 = 100;
|
|
|
|
for i in 0..N {
|
|
|
|
let test_key = Rpo256::hash(&rand_value::<u64>().to_be_bytes());
|
|
|
|
let test_value = [ONE, ONE, ONE, Felt::new(size + i)];
|
|
|
|
tree.insert(test_key, test_value);
|
|
|
@ -149,11 +150,10 @@ pub fn proof_generation(tree: &mut Smt, size: u64) -> Result<(), MerkleError> { |
|
|
|
}
|
|
|
|
|
|
|
|
println!(
|
|
|
|
"An average proving time measured by 20 value proofs in a SMT with {} key-value pairs in {:.3} microseconds",
|
|
|
|
size,
|
|
|
|
// calculate the average by dividing by 20 and convert to microseconds by multiplying by
|
|
|
|
// 1000000. As a result, we can only multiply by 50000
|
|
|
|
insertion_times.iter().sum::<f32>() * 50000f32,
|
|
|
|
"An average proving time measured by {N} value proofs in a SMT with {size} key-value pairs is {:.1} μs",
|
|
|
|
// calculate the average by dividing by 100 and convert to microseconds by multiplying by
|
|
|
|
// 1000000. As a result, we can only multiply by 10000
|
|
|
|
insertion_times.iter().sum::<f32>() * 10000_f32,
|
|
|
|
);
|
|
|
|
|
|
|
|
Ok(())
|
|
|
|