Skip to content

Commit

Permalink
⌛ Add memory merkle root benchmarks
Browse files Browse the repository at this point in the history
  • Loading branch information
clabby committed Sep 23, 2023
1 parent 83e4c56 commit a2803e6
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
12 changes: 11 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,17 @@ credits for the original idea and reference implementation of this concept go to

## Benchmarks

Benchmarks are ran on a 2021 Macbook Pro with an M1 Max and 64 GB of unified memory.
The below benchmarks are ran on a 2021 Macbook Pro with an M1 Max and 32 GB of unified memory and taken
on commit [`83e4c56`](https://github.com/anton-rs/cannon-rs/tree/83e4c5643193aac19046ef29b5018137b5eb05f2).

### `cannon-mipsevm` benchmarks

| Benchmark Name | `cannon` mean (Reference) | `cannon-rs` mean |
|----------------------------|---------------------------|---------------------|
| Memory Merkle Root (25MB) | 736.94 ms | 328.67 µs (-99%) |
| Memory Merkle Root (50MB) | 1.54s | 548.85 ms (-63.36%) |
| Memory Merkle Root (100MB) | 3.34s | 1.16s (-65.29%) |
| Memory Merkle Root (200MB) | 6.30s | 2.14s (-66.01%) |

*todo*

Expand Down
12 changes: 12 additions & 0 deletions crates/mipsevm/benches/memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,18 @@ fn merkle_root(c: &mut Criterion) {
memory.merkle_root().unwrap();
});
});

c.bench_function("Merkle Root (memory size = 200 MB)", |b| {
let mut memory = Memory::default();
let mut data = vec![0u8; 200_000_000];
rand::thread_rng().fill_bytes(&mut data[..]);
memory
.set_memory_range(0, &data[..])
.expect("Should not error");
b.iter(|| {
memory.merkle_root().unwrap();
});
});
}

criterion_group!(benches, merkle_root);
Expand Down

0 comments on commit a2803e6

Please sign in to comment.