github.com/iotexproject/iotex-core@v1.14.1-rc1/action/protocol/execution/testdata-london/maxtime.sol (about) 1 // SPDX-License-Identifier: GPL-3.0 2 3 pragma solidity ^0.8.14; 4 5 contract SimpleStorage { 6 uint256[32] storedData; 7 8 event Set(uint256 indexed); 9 event Get(address, uint256); 10 11 function set(uint256 x) public { 12 for (uint256 i = 0; i < 32; i++) { 13 storedData[i] = x; 14 } 15 emit Set(x); 16 } 17 18 function test1(uint256 loop) public returns (uint256) { 19 uint256 x = 0; 20 for (uint256 j = 0; j < loop; j++) { 21 for (uint256 i = 0; i < 32; i++) { 22 x += storedData[i]; 23 x = x >> 8; 24 x = x * 257; 25 } 26 } 27 emit Set(x); 28 return x; 29 } 30 31 function store1(uint256 loop) public returns (uint256) { 32 uint256 x = 0; 33 for (uint256 j = 0; j < loop; j++) { 34 for (uint256 i = 0; i < 32; i++) { 35 x += storedData[i]; 36 x = x >> 8; 37 x = x * 257; 38 } 39 storedData[j % 32] = x; 40 } 41 emit Set(x); 42 return x; 43 } 44 45 function test2(uint256 loop) public returns (uint256) { 46 uint256 x = 0; 47 for (uint256 j = 0; j < loop; j++) { 48 for (uint256 i = 0; i < 32; i++) { 49 x += storedData[i]; 50 x = x >> 8; 51 } 52 } 53 emit Set(x); 54 return x; 55 } 56 }