fparser.scripts.fparser2_bench

Generates a large Fortran program in memory and then measures how long it takes fparser2 to parse it. This is based on the benchmark suggested by Ondřej Čertík via Ioannis Nikiteas.

Module Contents

Functions

gen_sub(num)

Constructs a Fortran subroutine named g<num>.

create_bench(num_routines)

Creates the Fortran benchmark code.

runner(num_routines)

Entry point for running the benchmark.

fparser.scripts.fparser2_bench.gen_sub(num: int)[source]

Constructs a Fortran subroutine named g<num>.

Parameters:

num – the number of the subroutine (used to name it).

Returns:

Fortran subroutine.

Return type:

str

fparser.scripts.fparser2_bench.create_bench(num_routines: int)[source]

Creates the Fortran benchmark code.

Parameters:

num_routines – the number of subroutines to create.

Returns:

benchmark Fortran code.

Return type:

str

fparser.scripts.fparser2_bench.runner(num_routines: int)[source]

Entry point for running the benchmark.

Parameters:

num_routines – the number of subroutines to create in the Fortran benchmark.

Raises:

ValueError – if num_routines < 1.