File tree Expand file tree Collapse file tree
yarn-project/simulator/src/avm Expand file tree Collapse file tree Original file line number Diff line number Diff 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+ } ) ;
You can’t perform that action at this time.
0 commit comments