solidity/test/libsolidity/semanticTests/array/array_storage_index_access.sol

54 lines
1.4 KiB
Solidity
Raw Normal View History

contract C {
uint[] storageArray;
function test_indices(uint256 len) public
{
while (storageArray.length < len)
storageArray.push();
while (storageArray.length > len)
storageArray.pop();
for (uint i = 0; i < len; i++)
storageArray[i] = i + 1;
for (uint i = 0; i < len; i++)
require(storageArray[i] == i + 1);
}
}
// ----
// test_indices(uint256): 1 ->
// test_indices(uint256): 129 ->
2023-08-04 10:27:18 +00:00
// gas irOptimized: 3016570
// gas legacy: 3069098
// gas legacyOptimized: 3013250
// test_indices(uint256): 5 ->
2023-08-04 10:27:18 +00:00
// gas irOptimized: 576716
// gas legacy: 574754
// gas legacyOptimized: 572383
// test_indices(uint256): 10 ->
2023-08-04 10:27:18 +00:00
// gas irOptimized: 158059
// gas legacy: 162468
// gas legacyOptimized: 158336
// test_indices(uint256): 15 ->
2023-08-04 10:27:18 +00:00
// gas irOptimized: 172984
// gas legacy: 179513
// gas legacyOptimized: 173606
// test_indices(uint256): 0xFF ->
2023-08-04 10:27:18 +00:00
// gas irOptimized: 5672104
// gas legacy: 5775928
// gas legacyOptimized: 5666726
// test_indices(uint256): 1000 ->
2023-08-04 10:27:18 +00:00
// gas irOptimized: 18173701
// gas legacy: 18583810
// gas legacyOptimized: 18171248
// test_indices(uint256): 129 ->
2023-08-04 10:27:18 +00:00
// gas irOptimized: 4147676
// gas legacy: 4164468
// gas legacyOptimized: 4122100
// test_indices(uint256): 128 ->
2023-08-04 10:27:18 +00:00
// gas irOptimized: 409209
// gas legacy: 463706
// gas legacyOptimized: 418061
// test_indices(uint256): 1 ->
2023-08-04 10:27:18 +00:00
// gas irOptimized: 580316
// gas legacy: 576904
// gas legacyOptimized: 575649