Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[svg] Log parse and render times separately #310

Merged
merged 1 commit into from
Apr 23, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion examples/scenes/src/svg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,13 @@ pub fn svg_function_of<R: AsRef<str>>(
let start = Instant::now();
let svg = usvg::Tree::from_str(&contents, &usvg::Options::default())
.expect("failed to parse svg file");
eprintln!("Parsed svg {name} in {:?}", start.elapsed());
let start = Instant::now();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This has the same concern as #288 - that is, this excludes the time taken to perform the printing (as elapsed creates a new ephemeral Instant).

However, I think that's fine, because this isn't trying to determine complete time - it's just to give a flavour of performance.

Copy link
Collaborator Author

@armansito armansito Apr 23, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, I don't think including the time to print the message itself is interesting (and I doubt it will show up even when parsing a modest SVG). As it stands this should print out a fine-grained measurement of parse and encoding times as opposed to a thoroughly inclusive total time.

let mut new_scene = SceneFragment::new();
let mut builder = SceneBuilder::for_fragment(&mut new_scene);
vello_svg::render_tree(&mut builder, &svg);
let resolution = Vec2::new(svg.size.width(), svg.size.height());
eprintln!("Rendered svg {name} in {:?}", start.elapsed());
eprintln!("Encoded svg {name} in {:?}", start.elapsed());
(new_scene, resolution)
}
let mut cached_scene = None;
Expand Down