def generate_benchmarks()

in benchmark/run_benchmark.py [0:0]


def generate_benchmarks(dir):
    benchmark = Path(__file__).parent.joinpath("benchmark.py")

    with open(benchmark, "r") as file:
        src = file.read()

    # Find all the benchmarks
    benchmarks = [
        x[4:-3]
        for x in src.splitlines()
        if x.startswith("def benchmark") and x.endswith("():")
    ]

    outputs = {}
    for benchmark in benchmarks:
        # Whichever one is committed, make sure we switch it for this one
        src2 = src
        for x in benchmarks:
            src2 = src2.replace("print(" + x + "())", "print(" + benchmark + "())")
        output = Path(dir).joinpath(benchmark + ".py")
        with open(output, "w") as out:
            out.write(src2)
        outputs[benchmark] = output
    return outputs