feat(bench): add SQLite and PostgreSQL wrappers for benchmark queries
- implement SQLite and PostgreSQL wrappers to execute benchmark queries - update README to reflect task 09 as implemented - enhance storage size updates to handle (format, variant) replacements - clarify benchmarking methodology for remote PostgreSQL setup
This commit is contained in:
@@ -1,8 +1,10 @@
|
||||
"""Idempotent per-format updates to out/bench/storage_sizes.csv.
|
||||
"""Idempotent per-(format, variant) updates to out/bench/storage_sizes.csv.
|
||||
|
||||
Contract (docs/rules/build-pipeline-tasks.md section 4): columns
|
||||
format,variant,bytes; a task re-run REPLACES its own format's rows and never
|
||||
touches other formats' rows.
|
||||
format,variant,bytes; a task re-run REPLACES its own (format, variant) rows
|
||||
and never touches other rows. Replacement is per variant, not per format:
|
||||
converters 04-07 own the working-footprint variants while task 09 appends
|
||||
archival variants of the same formats.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
@@ -25,12 +27,13 @@ def update_storage_sizes(bench_dir: Path, fmt: str, variants: list[tuple[str, in
|
||||
lock = bench_dir / "storage_sizes.lock"
|
||||
fd = _acquire(lock)
|
||||
try:
|
||||
replaced = {(fmt, variant) for variant, _ in variants}
|
||||
kept: list[str] = []
|
||||
if path.exists():
|
||||
lines = path.read_text(encoding="ascii").splitlines()
|
||||
if lines and lines[0] != HEADER:
|
||||
raise ValueError(f"{path}: unexpected header {lines[0]!r}")
|
||||
kept = [ln for ln in lines[1:] if ln and ln.split(",", 1)[0] != fmt]
|
||||
kept = [ln for ln in lines[1:] if ln and tuple(ln.split(",")[:2]) not in replaced]
|
||||
rows = kept + [f"{fmt},{variant},{nbytes}" for variant, nbytes in variants]
|
||||
with open(path, "w", encoding="ascii", newline="\n") as fh:
|
||||
fh.write(HEADER + "\n" + "\n".join(rows) + "\n")
|
||||
|
||||
Reference in New Issue
Block a user