import sys
import time
import pandapower as pp
import pandapower.networks as pn
case_name = sys.argv[1] if len(sys.argv) > 1 else "case14"
t0 = time.perf_counter()
net = getattr(pn, case_name)()
t1 = time.perf_counter()
print(f"model construction: {(t1 - t0) * 1e3:.3f} ms", file=sys.stderr)
def run() -> None:
pp.runpp(net)
run()
times = []
for _ in range(5):
t0 = time.perf_counter()
run()
t1 = time.perf_counter()
times.append(t1 - t0)
n_bus = len(net.bus)
print(f"nodes={n_bus}")
print(f"runpp (warm, 5 runs, ms): {[f'{t * 1e3:.3f}' for t in times]}")
print(f"min={min(times) * 1e3:.3f}ms mean={sum(times) / len(times) * 1e3:.3f}ms")
vm_pu = net.res_bus["vm_pu"]
print(f"vm_pu min/max = {vm_pu.min():.6f} / {vm_pu.max():.6f}")
t0 = time.perf_counter()
net2 = getattr(pn, case_name)()
pp.runpp(net2)
t1 = time.perf_counter()
print(f"cold (construct+calc): {(t1 - t0) * 1e3:.3f} ms")