| 166 | }) |
| 167 | } |
| 168 | fn main() -> Result<()> { |
| 169 | let source = std::env::args() |
| 170 | .nth(1) |
| 171 | .context("usage: graph_codec_lab <change-file-or-directory>")?; |
| 172 | let mut paths = vec![]; |
| 173 | collect(Path::new(&source), &mut paths)?; |
| 174 | paths.sort(); |
| 175 | ensure!(!paths.is_empty(), "no change files"); |
| 176 | let mut rows = vec![]; |
| 177 | let mut failures = vec![]; |
| 178 | for path in paths { |
| 179 | match measure(&path).with_context(|| path.display().to_string()) { |
| 180 | Ok(row) => { |
| 181 | eprintln!( |
| 182 | "{}: graph {} -> {} bytes", |
| 183 | path.display(), |
| 184 | row.graph_bytes, |
| 185 | row.candidate_graph_bytes |
| 186 | ); |
| 187 | rows.push(row); |
| 188 | } |
| 189 | Err(error) => { |
| 190 | eprintln!("{error:#}"); |
| 191 | failures.push(format!("{error:#}")); |
| 192 | } |
| 193 | } |
| 194 | } |
| 195 | println!( |
| 196 | "{}", |
| 197 | serde_json::to_string_pretty( |
| 198 | &serde_json::json!({"experiment":"graph field-context columns; NOT production","zstd_level":3, |
| 199 | "comparison":"unsigned frozen schema-2/3/4 ATSC-v1 baseline; full prototype headers counted; exact graph payload reconstruction; smaller-of-raw fallback; no operations coalesced", |
| 200 | "rows":rows,"failures":failures}) |
| 201 | )? |
| 202 | ); |
| 203 | ensure!(failures.is_empty(), "input failures; partial results only"); |
| 204 | Ok(()) |
| 205 | } |