예제 #1
0
        public void transient_storage_performance_test()
        {
            Stopwatch stopwatch     = new Stopwatch();
            long      blockGasLimit = 30000000;
            long      numOfOps      = (long)(blockGasLimit * .95) / (GasCostOf.TLoad + GasCostOf.TStore + GasCostOf.VeryLow * 4);
            Prepare   prepare       = Prepare.EvmCode;

            for (long i = 0; i < numOfOps; i++)
            {
                prepare.StoreDataInTransientStorage(1, 8);
                prepare.LoadDataFromTransientStorage(1);
                prepare.Op(Instruction.POP);
            }

            byte[] code = prepare.Done;

            stopwatch.Start();
            TestAllTracerWithOutput result = Execute(MainnetSpecProvider.ShanghaiBlockNumber, blockGasLimit, code, blockGasLimit);

            Assert.AreEqual(StatusCode.Success, result.StatusCode);
            stopwatch.Stop();
            Assert.IsTrue(stopwatch.ElapsedMilliseconds < 5000);
        }