Gitea CI / Assemble and validate CI artifacts (push) Successful in 1m47s
Gitea CI / Check code and tests (push) Successful in 7m15s
Gitea CI / Build Android APK (push) Successful in 4m6s
Gitea CI / Build Windows x64 app (push) Successful in 3m34s
Gitea CI / Audit and package Windows x64 (push) Successful in 1m29s
Gitea CI / Gitea CI passed (push) Successful in 1s
Gitea Release / Prepare draft Release (push) Failing after 8s
Gitea Release / Upload Android to draft Release (push) Skipped
Gitea Release / Upload Windows to draft Release (push) Skipped
Gitea Release / Verify and publish Release (push) Skipped
89 lines
4.0 KiB
Python
89 lines
4.0 KiB
Python
#!/usr/bin/env python3
|
|
"""Compare repeated release-mode PropertyPerformanceTests logs; fail on regressions."""
|
|
|
|
import argparse
|
|
import json
|
|
import math
|
|
import re
|
|
import statistics
|
|
from pathlib import Path
|
|
|
|
LINE = re.compile(
|
|
r"PROPERTY_BENCH (\w+) median_us=(\S+) p95_us=(\S+) checksum=(\S+)"
|
|
)
|
|
|
|
|
|
def read(paths):
|
|
runs = {}
|
|
for path in paths:
|
|
current = {}
|
|
for name, median, p95, checksum in LINE.findall(Path(path).read_text()):
|
|
values = tuple(float(value) for value in (median, p95, checksum))
|
|
if (name in current or not all(math.isfinite(value) for value in values)
|
|
or values[0] < 0 or values[1] < values[0]):
|
|
raise ValueError(f"Invalid or duplicate measurement in {path}: {name}")
|
|
current[name] = values
|
|
if not current or (runs and current.keys() != runs.keys()):
|
|
raise ValueError(f"Missing benchmark scenarios in {path}")
|
|
for name, values in current.items():
|
|
runs.setdefault(name, []).append(values)
|
|
return runs
|
|
|
|
|
|
def main():
|
|
parser = argparse.ArgumentParser(description=__doc__)
|
|
parser.add_argument("--before", nargs="+", required=True)
|
|
parser.add_argument("--after", nargs="+", required=True)
|
|
parser.add_argument("--output", type=Path)
|
|
parser.add_argument("--tolerance", type=float, default=0.15,
|
|
help="Allowed relative timing noise (default: 0.15)")
|
|
args = parser.parse_args()
|
|
if not 0 <= args.tolerance < 1:
|
|
parser.error("--tolerance must be in [0, 1)")
|
|
if len(args.before) < 3 or len(args.after) < 3:
|
|
parser.error("At least three independent runs are required on each side")
|
|
try:
|
|
before, after = read(args.before), read(args.after)
|
|
expected = {"render_plain", "render_effects", "sampling_empty", "sampling_normal", "sampling_dense"}
|
|
if before.keys() != expected or after.keys() != expected:
|
|
raise ValueError("Before/after scenarios do not match")
|
|
result = {
|
|
"method": "Median of independent run medians and run P95 values; times in microseconds",
|
|
"scope": "Scalar sampling and 640x360 native frozen-frame compositor, not display FPS",
|
|
"checksumScope": "Scalar outputs and rendered-frame work counters; pixel parity is tested separately",
|
|
"relativeNoiseTolerance": args.tolerance,
|
|
"beforeLogs": args.before,
|
|
"afterLogs": args.after,
|
|
"scenarios": {},
|
|
}
|
|
passed = True
|
|
for name in before:
|
|
checksums = {row[2] for row in before[name] + after[name]}
|
|
scenario = {"checksumMatches": len(checksums) == 1,
|
|
"beforeRuns": len(before[name]), "afterRuns": len(after[name])}
|
|
passed &= scenario["checksumMatches"]
|
|
# Timer noise dominates empty, sub-microsecond sampling measurements.
|
|
absolute_noise = 0.1 if name.startswith("sampling_") else 100.0
|
|
for index, metric in enumerate(["median", "p95"]):
|
|
old = statistics.median(row[index] for row in before[name])
|
|
new = statistics.median(row[index] for row in after[name])
|
|
limit = old * (1 + args.tolerance) + absolute_noise
|
|
scenario[metric] = {"beforeUs": old, "afterUs": new,
|
|
"changePercent": (new / old - 1) * 100 if old else None,
|
|
"limitUs": limit, "passed": new <= limit}
|
|
passed &= new <= limit
|
|
result["scenarios"][name] = scenario
|
|
result["passed"] = bool(passed)
|
|
encoded = json.dumps(result, indent=2) + "\n"
|
|
if args.output:
|
|
args.output.parent.mkdir(parents=True, exist_ok=True)
|
|
args.output.write_text(encoded)
|
|
print(encoded, end="")
|
|
return 0 if passed else 1
|
|
except (OSError, ValueError) as error:
|
|
parser.exit(2, f"Invalid benchmark input: {error}\n")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
raise SystemExit(main())
|