From 1c909195c40ef59e1d5bd75ade0ba29d58f4c6be Mon Sep 17 00:00:00 2001 From: IlyasRidhuan Date: Sun, 10 Nov 2024 17:12:31 +0000 Subject: [PATCH] perf(avm): minor benchmarking --- .../simulator/src/avm/avm_tree.test.ts | 21 +++++++++++++++++++ yarn.lock | 4 ---- 2 files changed, 21 insertions(+), 4 deletions(-) delete mode 100644 yarn.lock diff --git a/yarn-project/simulator/src/avm/avm_tree.test.ts b/yarn-project/simulator/src/avm/avm_tree.test.ts index fbb30accfe2a..e910a49ff622 100644 --- a/yarn-project/simulator/src/avm/avm_tree.test.ts +++ b/yarn-project/simulator/src/avm/avm_tree.test.ts @@ -488,3 +488,24 @@ describe('AVM Ephemeral Tree Sanity Test', () => { expect(localRoot.toBuffer()).toEqual(treeInfo.root); }); }); + +/* eslint no-console: ["error", { allow: ["time", "timeEnd"] }] */ +describe('A basic benchmark', () => { + it('Should benchmark writes', async () => { + // This random is fine for now, since the entry leaves are between 0-127 + // We just want to make sure there are minimal "updates" from this set + const leaves = Array.from({ length: 64 }, _ => Fr.random()); + const slots = leaves.map((_, i) => new Fr(i + 128)); + + const container = await AvmEphemeralForest.create(copyState); + + // Updating the first slot, triggers the index 0 to be added to the minimum stored key in the container + await container.writePublicStorage(new Fr(0), new Fr(128)); + console.time('benchmark'); + // These writes are all new leaves and should be impacted by the key sorted algorithm of the tree. + for (let i = 0; i < leaves.length; i++) { + await container.writePublicStorage(slots[i], leaves[i]); + } + console.timeEnd('benchmark'); + }); +}); diff --git a/yarn.lock b/yarn.lock deleted file mode 100644 index fb57ccd13afb..000000000000 --- a/yarn.lock +++ /dev/null @@ -1,4 +0,0 @@ -# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. -# yarn lockfile v1 - -