From a2803e6f50297e0efd9a53868bbfa9afbfd67ea4 Mon Sep 17 00:00:00 2001 From: clabby Date: Sat, 23 Sep 2023 19:47:10 -0400 Subject: [PATCH] =?UTF-8?q?=E2=8C=9B=20Add=20memory=20merkle=20root=20benc?= =?UTF-8?q?hmarks?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 12 +++++++++++- crates/mipsevm/benches/memory.rs | 12 ++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 832c55e..17526b2 100644 --- a/README.md +++ b/README.md @@ -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* diff --git a/crates/mipsevm/benches/memory.rs b/crates/mipsevm/benches/memory.rs index 6188a07..d2507c1 100644 --- a/crates/mipsevm/benches/memory.rs +++ b/crates/mipsevm/benches/memory.rs @@ -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);