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

Conversation

armansito
Copy link
Collaborator

The examples logged the total processing time for an SVG including both parse and GPU buffer encoding times. Times for these two operations are now logged separately.

The examples logged the total processing time for an SVG including both
parse and GPU buffer encoding times. Times for these two operations are
now logged separately.
@armansito armansito requested a review from DJMcNab April 22, 2023 01:31
Copy link
Member

@DJMcNab DJMcNab left a comment

Choose a reason for hiding this comment

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

Looks good to me.

To give a flavour of the results, encoding takes approximately 1 order of magnitude less time than parsing.

@@ -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.

@armansito armansito merged commit fa02797 into linebender:main Apr 23, 2023
@armansito armansito deleted the svg-timing branch April 23, 2023 18:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants