mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-10-24 09:46:59 -06:00
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 <noreply@anthropic.com>
This commit is contained in:
committed by
bflatastic
co-authored by
Claude Opus 5.5
parent
5b919c0529
commit
a7ee168efe
@@ -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#"<svg xmlns="http://www.w3.org/2000/svg" width="{w}" height="{h}"><image width="{w}" height="{h}" href="data:image/png;base64,{data}"/><rect width="100" height="100" style="display:none"/></svg>"#
|
||||
);
|
||||
// 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));
|
||||
|
||||
Reference in New Issue
Block a user