2019-06-13 15:22:24 +00:00
|
|
|
contract C {
|
2019-09-18 13:38:38 +00:00
|
|
|
uint[] storageArray;
|
|
|
|
function test_indices(uint256 len) public
|
|
|
|
{
|
2019-11-18 13:36:45 +00:00
|
|
|
while (storageArray.length < len)
|
|
|
|
storageArray.push();
|
|
|
|
while (storageArray.length > len)
|
|
|
|
storageArray.pop();
|
2019-09-18 13:38:38 +00:00
|
|
|
for (uint i = 0; i < len; i++)
|
|
|
|
storageArray[i] = i + 1;
|
2019-06-13 15:22:24 +00:00
|
|
|
|
2019-09-18 13:38:38 +00:00
|
|
|
for (uint i = 0; i < len; i++)
|
|
|
|
require(storageArray[i] == i + 1);
|
|
|
|
}
|
2019-06-13 15:22:24 +00:00
|
|
|
}
|
2019-11-07 20:22:58 +00:00
|
|
|
// ====
|
2020-11-24 23:25:42 +00:00
|
|
|
// compileViaYul: also
|
2019-06-13 15:22:24 +00:00
|
|
|
// ----
|
2019-09-18 13:38:38 +00:00
|
|
|
// test_indices(uint256): 1 ->
|
|
|
|
// test_indices(uint256): 129 ->
|
2021-04-12 10:53:09 +00:00
|
|
|
// gas irOptimized: 3442268
|
2021-02-12 12:45:15 +00:00
|
|
|
// gas legacy: 3340105
|
|
|
|
// gas legacyOptimized: 3280773
|
2019-09-18 13:38:38 +00:00
|
|
|
// test_indices(uint256): 5 ->
|
2021-04-12 10:53:09 +00:00
|
|
|
// gas irOptimized: 467656
|
2021-02-12 12:45:15 +00:00
|
|
|
// gas legacy: 458941
|
|
|
|
// gas legacyOptimized: 455849
|
2019-09-18 13:38:38 +00:00
|
|
|
// test_indices(uint256): 10 ->
|
|
|
|
// test_indices(uint256): 15 ->
|
2021-04-12 10:53:09 +00:00
|
|
|
// gas irOptimized: 109070
|
2019-09-18 13:38:38 +00:00
|
|
|
// test_indices(uint256): 0xFF ->
|
2021-04-12 10:53:09 +00:00
|
|
|
// gas irOptimized: 4308940
|
2021-02-12 12:45:15 +00:00
|
|
|
// gas legacy: 4107867
|
|
|
|
// gas legacyOptimized: 3991807
|
2019-09-18 13:38:38 +00:00
|
|
|
// test_indices(uint256): 1000 ->
|
2021-04-12 10:53:09 +00:00
|
|
|
// gas irOptimized: 21133562
|
2021-02-12 12:45:15 +00:00
|
|
|
// gas legacy: 20360399
|
|
|
|
// gas legacyOptimized: 19921344
|
2019-09-18 13:38:38 +00:00
|
|
|
// test_indices(uint256): 129 ->
|
2021-04-12 10:53:09 +00:00
|
|
|
// gas irOptimized: 3601383
|
2021-02-12 12:45:15 +00:00
|
|
|
// gas legacy: 3472135
|
|
|
|
// gas legacyOptimized: 3415947
|
2019-09-18 13:38:38 +00:00
|
|
|
// test_indices(uint256): 128 ->
|
2021-04-12 10:53:09 +00:00
|
|
|
// gas irOptimized: 648097
|
2021-02-12 12:45:15 +00:00
|
|
|
// gas legacy: 556972
|
|
|
|
// gas legacyOptimized: 508124
|
2019-09-18 13:38:38 +00:00
|
|
|
// test_indices(uint256): 1 ->
|
2021-04-12 10:53:09 +00:00
|
|
|
// gas irOptimized: 458399
|
2021-02-12 12:45:15 +00:00
|
|
|
// gas legacy: 452407
|
|
|
|
// gas legacyOptimized: 450811
|