Skip to content

test_exp_bench_arithmetic()

Documentation for tests/benchmark/compute/instruction/test_arithmetic.py::test_exp_bench_arithmetic@21507778.

Generate fixtures for these test cases for Amsterdam with:

fill -v tests/benchmark/compute/instruction/test_arithmetic.py::test_exp_bench_arithmetic --gas-benchmark-values 1

Benchmark EXP instruction.

Source code in tests/benchmark/compute/instruction/test_arithmetic.py
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
@pytest.mark.parametrize("base", [3, 5, 7, 11, 13, 136279841])
@pytest.mark.parametrize("exp", [3, 5, 7, 11, 13, 136279841])
def test_exp_bench_arithmetic(
    benchmark_test: BenchmarkTestFiller, base: int, exp: int
) -> None:
    """Benchmark EXP instruction."""
    tx_data = b"".join(
        arg.to_bytes(32, byteorder="big") for arg in (base, exp)
    )

    setup = Op.CALLDATALOAD(0) + Op.CALLDATALOAD(32) + Op.DUP2 + Op.DUP2
    attack_block = Op.DUP2 + Op.EXP
    cleanup = Op.POP + Op.POP + Op.DUP2 + Op.DUP2
    benchmark_test(
        target_opcode=Op.EXP,
        code_generator=JumpLoopGenerator(
            setup=setup,
            attack_block=attack_block,
            cleanup=cleanup,
            tx_kwargs={"data": tx_data},
        ),
    )

Parametrized Test Cases

This test generates 36 parametrized test cases across 3 forks.