Skip to content

test_sload_same_key_benchmark()

Documentation for tests/benchmark/stateful/bloatnet/test_sload.py::test_sload_same_key_benchmark@5fa5938b.

Generate fixtures for these test cases for Amsterdam with:

fill -v tests/benchmark/stateful/bloatnet/test_sload.py::test_sload_same_key_benchmark --gas-benchmark-values 1

Benchmark SLOAD instruction when loading the same key over and over.

Variants:

  • storage_keys_pre_set: The key is pre-set to a non-zero value.
Source code in tests/benchmark/stateful/bloatnet/test_sload.py
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
@pytest.mark.repricing
@pytest.mark.parametrize("storage_keys_pre_set", [False, True])
def test_sload_same_key_benchmark(
    benchmark_test: BenchmarkTestFiller,
    storage_keys_pre_set: bool,
) -> None:
    """
    Benchmark SLOAD instruction when loading the same key over and over.

    Variants:

    - storage_keys_pre_set: The key is pre-set to a non-zero value.
    """
    contract_storage = Storage()
    if storage_keys_pre_set:
        contract_storage[1] = 1

    benchmark_test(
        target_opcode=Op.SLOAD,
        code_generator=JumpLoopGenerator(
            setup=Op.PUSH1(1) if storage_keys_pre_set else Op.PUSH0,
            attack_block=Op.SLOAD,
            contract_storage=contract_storage,
        ),
    )

Parametrized Test Cases

This test generates 2 parametrized test cases across 3 forks.