#!/usr/bin/python3

import time
import subprocess as sp

COMPILE_FORMAT = (
    "clang++ -c -std=c++17 -I include -I build/code/dependencies/Boost/include"
    " -DBREADTH={breadth} -DDEPTH={depth} -DMETHOD={method} tests/lab.cpp"
)
RUNS = 20


def compile(**kwargs):
    sp.check_call(COMPILE_FORMAT.format(**kwargs), shell=True, stderr=sp.DEVNULL)


for breadth in range(1, 20 + 1):
    print(f"\n{breadth=}")
    died = []
    for depth in range(1, 50 + 1):
        tara = 0
        print(f"{depth:>2d}", end="")

        for method in range(1, 3 + 1):
            if method in died:
                print(" -", end="")
                continue
                
            sum = 0
            try:
                for _ in range(RUNS):
                    start = time.perf_counter()
                    compile(breadth=breadth, depth=depth, method=method)
                    sum += time.perf_counter() - start
                print(f" {(sum - tara)/RUNS:6.2f}", end="")
            except sp.CalledProcessError:
                died.append(method)
                print(" -", end="")

        print()
