Skip to content

Commit b57b5e9

Browse files
committed
perf(avm): minor benchmarking
1 parent d158b08 commit b57b5e9

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

yarn-project/simulator/src/avm/avm_tree.test.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -488,3 +488,24 @@ describe('AVM Ephemeral Tree Sanity Test', () => {
488488
expect(localRoot.toBuffer()).toEqual(treeInfo.root);
489489
});
490490
});
491+
492+
/* eslint no-console: ["error", { allow: ["time", "timeEnd"] }] */
493+
describe('A basic benchmark', () => {
494+
it('Should benchmark writes', async () => {
495+
// This random is fine for now, since the entry leaves are between 0-127
496+
// We just want to make sure there are minimal "updates" from this set
497+
const leaves = Array.from({ length: 64 }, _ => Fr.random());
498+
const slots = leaves.map((_, i) => new Fr(i + 128));
499+
500+
const container = await AvmEphemeralForest.create(copyState);
501+
502+
// Updating the first slot, triggers the index 0 to be added to the minimum stored key in the container
503+
await container.writePublicStorage(new Fr(0), new Fr(128));
504+
console.time('benchmark');
505+
// These writes are all new leaves and should be impacted by the key sorted algorithm of the tree.
506+
for (let i = 0; i < leaves.length; i++) {
507+
await container.writePublicStorage(slots[i], leaves[i]);
508+
}
509+
console.timeEnd('benchmark');
510+
});
511+
});

0 commit comments

Comments
 (0)