- hand::klasse: KLASSEN/klasse (aus sim::poolruf) und percentile (aus sim::bettor_tor) woertlich verschoben; sim re-exportiert. Live-Aufrufer (solver_kern, multi3_spieler, ranges_echt, kern_zeile) zeigen auf hand::klasse. - lib.rs: pub mod sim nur mit --features sim (Vorgabe aus); blueprint::welt_gegner ebenso. - Cargo.toml: 36 Sim-Bins required-features = ["sim"]; tests/sim_*.rs cfg(feature = "sim"). - rechner baut ohne Sim; jede uebrige Sim-Abhaengigkeit scheitert beim Bauen. - readme_staerken: Sim-Bloecke gegner/lbr nur noch als Hinweis ausgemustert, Matrix ohne Sim-Spalte, REFERENZ.txt nicht mehr gelesen; README entsprechend markiert. - messung/sim-raus/bitgleich.py: Vergleich neuer gegen Live-Kern auf hhDealer-Spots. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
91 lines
3.6 KiB
Python
91 lines
3.6 KiB
Python
"""Bitgleich-Vergleich: neuer Kern ohne Sim gegen den Live-Kern auf echten hhDealer-Spots.
|
|
|
|
Beide Binaries bekommen dieselben Anfragen (Feld `req` der Gewinnerspots), dieselben Live-Schalter aus
|
|
`betrieb/kern_schalter.txt` des Livebaums und SOLVER_ZEIT=fest (Solver ignorieren Uhrzeit). Verglichen
|
|
wird jede Antwortzeile byteweise, nur die gemessene Rechenzeit im Begruendungstext (`<zahl> ms`) ist
|
|
maskiert (sie schwankt von Lauf zu Lauf). Jeder Worker haelt ein Prozesspaar (live, neu), Prioritaet BelowNormal.
|
|
|
|
python messung/sim-raus/bitgleich.py <live.exe> <neu.exe> <schalter.txt> <n> <worker> <ausgabe.json>
|
|
"""
|
|
import glob, json, os, re, subprocess, sys, threading
|
|
from concurrent.futures import ThreadPoolExecutor
|
|
|
|
SPOTS = os.path.join(os.path.expanduser("~"), "pokerfreak-regulars", "gewinnerspots", "spots", "*.jsonl")
|
|
BELOW_NORMAL = 0x00004000
|
|
ZEIT = re.compile(r"\b\d+(\.\d+)? ms\b")
|
|
|
|
|
|
def schalter(pfad):
|
|
env = {}
|
|
for zeile in open(pfad, encoding="utf-8"):
|
|
zeile = zeile.split("#", 1)[0].strip()
|
|
if "=" in zeile:
|
|
k, v = (t.strip() for t in zeile.split("=", 1))
|
|
if v:
|
|
env[k] = v
|
|
return env
|
|
|
|
|
|
def anfragen(n):
|
|
dateien = sorted(glob.glob(SPOTS))
|
|
zeilen = []
|
|
for d in dateien:
|
|
with open(d, encoding="utf-8") as f:
|
|
zeilen.extend(f)
|
|
schritt = max(1, len(zeilen) // n)
|
|
return [json.dumps(json.loads(z)["req"], separators=(",", ":")) for z in zeilen[::schritt][:n]], len(zeilen)
|
|
|
|
|
|
def kern(exe, env):
|
|
return subprocess.Popen([exe], stdin=subprocess.PIPE, stdout=subprocess.PIPE, env=env, text=True,
|
|
encoding="utf-8", bufsize=1, creationflags=BELOW_NORMAL)
|
|
|
|
|
|
def senden(p, req):
|
|
p.stdin.write(req + "\n")
|
|
p.stdin.flush()
|
|
|
|
|
|
def antwort(p):
|
|
return ZEIT.sub("<t> ms", p.stdout.readline().rstrip("\n"))
|
|
|
|
|
|
def main():
|
|
live, neu, sdatei, n, worker, aus = os.path.abspath(sys.argv[1]), os.path.abspath(sys.argv[2]), sys.argv[3], int(sys.argv[4]), int(sys.argv[5]), sys.argv[6]
|
|
env = {**os.environ, **schalter(sdatei), "SOLVER_ZEIT": "fest"}
|
|
env.pop("KERN_NOTBREMSE_MS", None)
|
|
reqs, gesamt = anfragen(n)
|
|
teile = [reqs[i::worker] for i in range(worker)]
|
|
lock = threading.Lock()
|
|
stand = {"n": 0, "diff": 0, "aktion_diff": 0, "beispiele": []}
|
|
|
|
def lauf(teil):
|
|
a, b = kern(live, env), kern(neu, env)
|
|
for req in teil:
|
|
senden(a, req); senden(b, req)
|
|
x, y = antwort(a), antwort(b)
|
|
with lock:
|
|
stand["n"] += 1
|
|
if x != y:
|
|
stand["diff"] += 1
|
|
ja, jb = json.loads(x), json.loads(y)
|
|
if (ja.get("action"), ja.get("size")) != (jb.get("action"), jb.get("size")):
|
|
stand["aktion_diff"] += 1
|
|
if len(stand["beispiele"]) < 20:
|
|
stand["beispiele"].append({"req": req, "live": x, "neu": y})
|
|
if stand["n"] % 1000 == 0:
|
|
print(stand["n"], "diff", stand["diff"], flush=True)
|
|
a.stdin.close(); b.stdin.close(); a.wait(); b.wait()
|
|
|
|
with ThreadPoolExecutor(worker) as ex:
|
|
list(ex.map(lauf, teile))
|
|
erg = {"spots_gesamt": gesamt, "verglichen": stand["n"], "unterschiede": stand["diff"], "aktion_oder_groesse_anders": stand["aktion_diff"],
|
|
"schalter": sdatei, "SOLVER_ZEIT": "fest", "beispiele": stand["beispiele"]}
|
|
with open(aus, "w", encoding="utf-8", newline="\n") as f:
|
|
json.dump(erg, f, ensure_ascii=False, indent=1)
|
|
print(json.dumps({k: v for k, v in erg.items() if k != "beispiele"}))
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|