| 461 | Ok(()) |
| 462 | } |
| 463 | fn main() -> Result<()> { |
| 464 | let source = std::env::args() |
| 465 | .nth(1) |
| 466 | .context("usage: semantic_codec_lab <change-file-or-directory>")?; |
| 467 | let mut paths = vec![]; |
| 468 | collect(Path::new(&source), &mut paths)?; |
| 469 | paths.sort(); |
| 470 | ensure!(!paths.is_empty(), "no change files"); |
| 471 | let mut rows = vec![]; |
| 472 | let mut failures = vec![]; |
| 473 | for path in paths { |
| 474 | match measure(&path).with_context(|| path.display().to_string()) { |
| 475 | Ok(row) => { |
| 476 | eprintln!( |
| 477 | "{}: production semantics={} candidate minimum={}", |
| 478 | path.display(), |
| 479 | row.baseline_semantic_bytes, |
| 480 | row.candidates |
| 481 | .iter() |
| 482 | .map(|c| c.semantic_bytes) |
| 483 | .min() |
| 484 | .unwrap_or(0) |
| 485 | ); |
| 486 | rows.push(row); |
| 487 | } |
| 488 | Err(error) => { |
| 489 | eprintln!("{error:#}"); |
| 490 | failures.push(format!("{error:#}")); |
| 491 | } |
| 492 | } |
| 493 | } |
| 494 | println!( |
| 495 | "{}", |
| 496 | serde_json::to_string_pretty( |
| 497 | &serde_json::json!({"experiment":"not a production wire format","zstd_level":3, |
| 498 | "comparison":"unsigned frozen schema-2/3/4 ATSC-v1 baseline; all candidate headers counted; projections retain other object bytes; independent column sizes are diagnostic, not additive", |
| 499 | "rows":rows,"failures":failures}) |
| 500 | )? |
| 501 | ); |
| 502 | ensure!( |
| 503 | failures.is_empty(), |
| 504 | "some inputs failed; results are partial" |
| 505 | ); |
| 506 | Ok(()) |
| 507 | } |
| 508 | |
| 509 | #[cfg(test)] |
| 510 | mod tests { |