50 lines
1.8 KiB
Python
50 lines
1.8 KiB
Python
"""Run sequential, warm-cache end-to-end Maven comparisons from the repository root."""
|
|
from pathlib import Path
|
|
import json
|
|
import subprocess
|
|
import time
|
|
|
|
root = Path(__file__).resolve().parents[2]
|
|
results = []
|
|
pom = root / "pom.xml"
|
|
original_pom = pom.read_bytes()
|
|
pom_text = original_pom.decode()
|
|
start = pom_text.rfind(" <plugin>", 0, pom_text.index("<artifactId>exec-maven-plugin</artifactId>"))
|
|
end = pom_text.index(" </plugin>", start) + len(" </plugin>\n")
|
|
baseline_pom = (pom_text[:start] + pom_text[end:]).encode()
|
|
|
|
def run(label, *arguments):
|
|
command = ["mvn", "-B", "-ntp", *arguments]
|
|
start = time.monotonic()
|
|
baseline = "baseline" in label
|
|
try:
|
|
if baseline:
|
|
pom.write_bytes(baseline_pom)
|
|
result = subprocess.run(command, cwd=root, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True)
|
|
finally:
|
|
pom.write_bytes(original_pom)
|
|
elapsed = time.monotonic() - start
|
|
(root / "target").mkdir(exist_ok=True)
|
|
(root / "target" / ("s8-" + label + ".log")).write_text(result.stdout)
|
|
row = dict(label=label, command=command, seconds=round(elapsed, 3), exit=result.returncode)
|
|
results.append(row)
|
|
print(json.dumps(row), flush=True)
|
|
if result.returncode:
|
|
raise RuntimeError(result.stdout)
|
|
|
|
run("warmup", "compile")
|
|
run("baseline-warmup", "compile")
|
|
for number in range(3):
|
|
run("baseline-" + str(number), "compile")
|
|
run("formatted-" + str(number), "compile")
|
|
source = root / "ci/runner/WaitForDocker.java"
|
|
original = source.read_bytes()
|
|
try:
|
|
source.write_bytes(original + b"\n")
|
|
run("changed-file", "compile")
|
|
finally:
|
|
source.write_bytes(original)
|
|
run("clean-baseline", "clean", "verify")
|
|
run("clean-formatted", "-Dformat.mode=check", "clean", "verify")
|
|
(root / "target/s8-benchmark.json").write_text(json.dumps(results, indent=2) + "\n")
|