(rows: List[Row], out_path: Path)
| 482 | |
| 483 | |
| 484 | def write_per_document_csv(rows: List[Row], out_path: Path) -> Path: |
| 485 | per_doc = compute_per_document_stats(rows) |
| 486 | per_doc_path = out_path.with_name(out_path.stem + "_per_doc" + out_path.suffix) |
| 487 | with per_doc_path.open("w", newline="") as f: |
| 488 | w = csv.writer(f) |
| 489 | w.writerow( |
| 490 | [ |
| 491 | "basename", |
| 492 | "document", |
| 493 | "pages", |
| 494 | "total", |
| 495 | "mean", |
| 496 | "median", |
| 497 | "min", |
| 498 | "max", |
| 499 | "p90", |
| 500 | "p95", |
| 501 | "p99", |
| 502 | ] |
| 503 | ) |
| 504 | for s in per_doc: |
| 505 | w.writerow( |
| 506 | [ |
| 507 | Path(s["document"]).name, |
| 508 | s["document"], |
| 509 | s["pages"], |
| 510 | fmt_seconds(s["total"]), |
| 511 | fmt_seconds(s["mean"]), |
| 512 | fmt_seconds(s["median"]), |
| 513 | fmt_seconds(s["min"]), |
| 514 | fmt_seconds(s["max"]), |
| 515 | fmt_seconds(s["p90"]), |
| 516 | fmt_seconds(s["p95"]), |
| 517 | fmt_seconds(s["p99"]), |
| 518 | ] |
| 519 | ) |
| 520 | return per_doc_path |
| 521 | |
| 522 | |
| 523 | def _get_timing_keys_from_rows(rows: List[Row]) -> List[str]: |
no test coverage detected