Skip to content

test_log_benchmark()

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

Generate fixtures for these test cases for Bogota 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
@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 4 forks.