From a7ee168efe278dec14f1baa67d4bb618bd8ffc9d Mon Sep 17 00:00:00 2001 From: Drew Dibble Date: Thu, 22 Oct 2026 11:58:35 -0600 Subject: [PATCH] perf --deep: the embedded-picture import row reports a failed import instead of timing it One import is checked first and its document kept through the memory reading after the row, so a failure stops the run with its error rather than being timed as an import (CodeRabbit). The row's comment now gives the picture's real size, about 2 MB as a PNG. Co-Authored-By: Claude Opus 5.5 --- apps/vectorcraft-cli/src/perf.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/apps/vectorcraft-cli/src/perf.rs b/apps/vectorcraft-cli/src/perf.rs index ad7eab161..ef6f299f3 100644 --- a/apps/vectorcraft-cli/src/perf.rs +++ b/apps/vectorcraft-cli/src/perf.rs @@ -301,9 +301,9 @@ fn deep(n: usize) -> Result<(), String> { } // An SVG with one embedded picture opened from its text, as picture-heavy SVGs come: the // importer's passes over the text before usvg reads it, most of which is the data URL. The - // picture is the synthetic page drawn at 1.25x (about a megabyte as a PNG, the size at which - // the passes were measured); the hidden rectangle is a marker, so the prepass walks the tree - // as it does for a file that has one, instead of returning at its first check. + // picture is the synthetic page drawn at 1.25x (about 2 MB as a PNG; the row names its size); + // the hidden rectangle is a marker, so the prepass walks the tree as it does for a file that + // has one, instead of returning at its first check. { let k = 1.25; let (w, h) = ((SYNTHETIC_PAGE.0 * k).round() as u32, (SYNTHETIC_PAGE.1 * k).round() as u32); @@ -312,9 +312,13 @@ fn deep(n: usize) -> Result<(), String> { let svg = format!( r#""# ); + // One import checked first, so a failure is reported rather than timed; the same text + // imports the same way each time. Its document is kept for the memory reading. + let imported = vectorcraft_svg::import_with_report(&svg).map_err(|e| e.to_string())?; let ms = median_ms(5, || drop(vectorcraft_svg::import_with_report(&svg))); rows.push((format!("import SVG, one embedded {} KB PNG", photo.len() / 1024), ms)); note("after the import of an embedded picture"); + drop(imported); } // Output hashes, to compare builds: the SVG export and a save → open → save round trip. let fnv = |b: &[u8]| b.iter().fold(0xcbf2_9ce4_8422_2325u64, |h, &x| (h ^ u64::from(x)).wrapping_mul(0x100_0000_01b3));