#!/usr/bin/env python3
"""Engine time: the engine-reported latency_us of HelixorEngine.evaluate().

5,000 evaluations cycling over the shared payloads. latency_us covers extraction
through remedy only (see Methodology); size budgets from call time, not this.
"""
import time

from helixor_runtime import HelixorEngine

from _common import PAYLOADS, environment, summarize

N = 5_000


def main() -> None:
    print(environment())
    engine = HelixorEngine()
    reported_us: list[float] = []
    start = time.perf_counter()
    for i in range(N):
        reported_us.append(engine.evaluate(PAYLOADS[i % len(PAYLOADS)]).latency_us)
    wall_s = time.perf_counter() - start
    summarize("evaluate() engine-reported latency_us", [int(u * 1000) for u in reported_us])
    print(f"evaluations/s (wall clock): {N / wall_s:,.0f}")


if __name__ == "__main__":
    main()
