github.com/iotexproject/iotex-core@v1.14.1-rc1/action/protocol/execution/testdata-istanbul/maxtime.sol (about)

     1  pragma solidity >=0.4.24;
     2  
     3  contract SimpleStorage {
     4     uint[32] storedData;
     5  
     6     event Set(uint256 indexed);
     7     event Get(address, uint256);
     8  
     9     function set(uint x) public {
    10         for (uint i = 0; i < 32; i++) {
    11             storedData[i] = x;
    12         }
    13         emit Set(x);
    14     }
    15  
    16     function test1(uint loop) public returns (uint) {
    17         uint x = 0;
    18         for (uint j = 0; j < loop; j++) {
    19             for (uint i = 0; i < 32; i++) {
    20                 x += storedData[i];
    21                 x = x >> 8;
    22                 x = x * 257;
    23             }
    24         }
    25         emit Set(x);
    26         return x;
    27     }
    28  
    29     function store1(uint loop) public returns (uint) {
    30         uint x = 0;
    31         for (uint j = 0; j < loop; j++) {
    32             for (uint i = 0; i < 32; i++) {
    33                 x += storedData[i];
    34                 x = x >> 8;
    35                 x = x * 257;
    36             }
    37             storedData[j%32] = x;
    38         }
    39         emit Set(x);
    40         return x;
    41     }
    42  
    43     function test2(uint loop) public returns (uint) {
    44         uint x = 0;
    45         for (uint j = 0; j < loop; j++) {
    46             for (uint i = 0; i < 32; i++) {
    47                 x += storedData[i];
    48                 x = x >> 8;
    49             }
    50         }
    51         emit Set(x);
    52         return x;
    53     }
    54  }