Skip to content

test_log_benchmark()

Documentation for tests/benchmark/compute/instruction/test_log.py::test_log_benchmark@8db70f93.

Generate fixtures for these test cases for Amsterdam with:

fill -v tests/benchmark/compute/instruction/test_log.py::test_log_benchmark --gas-benchmark-values 1

Benchmark LOG instructions with specific memory and log size.

Source code in tests/benchmark/compute/instruction/test_log.py
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
@pytest.mark.repricing
@pytest.mark.parametrize(
    "opcode",
    [
        Op.LOG0,
        Op.LOG1,
        Op.LOG2,
        Op.LOG3,
        Op.LOG4,
    ],
)
@pytest.mark.parametrize("mem_size", [0, 32, 256, 1024])
@pytest.mark.parametrize("log_size", [0, 32, 256, 1024])
def test_log_benchmark(
    benchmark_test: BenchmarkTestFiller,
    mem_size: int,
    log_size: int,
    opcode: Op,
) -> None:
    """Benchmark LOG instructions with specific memory and log size."""
    setup = (
        Op.CODECOPY(dest_offset=0, offset=0, size=mem_size)
        + Op.PUSH3(log_size)
        + Op.PUSH32(2**256 - 1)
    )

    topic_count = len(opcode.kwargs or []) - 2
    size_op = getattr(Op, f"DUP{topic_count + 2}")
    offset = Op.PUSH0
    attack_block = Op.DUP1 * topic_count + size_op + offset + opcode

    benchmark_test(
        target_opcode=opcode,
        code_generator=JumpLoopGenerator(
            setup=setup,
            attack_block=attack_block,
            code_padding_opcode=Op.INVALID,
        ),
    )

Parametrized Test Cases

This test generates 80 parametrized test cases across 3 forks.