Merged
Conversation
I also realized that the label benchmark wasn't testing the painting, since the buttons at some point will be placed outside the screen_rect, meaning it won't be painted. This fixes it by benching the label in a child ui. The label &str benchmark went from 483 ns to 535 ns with these changes.
5f9ec9a to
bf13ce9
Compare
|
Preview available at https://egui-pr-preview.github.io/pr/6854-lucasadd-button-benchmark |
emilk
approved these changes
Apr 25, 2025
Comment on lines
+63
to
+67
| || ui.new_child(UiBuilder::new()), | ||
| |ui| { | ||
| ui.label("the quick brown fox jumps over the lazy dog"); | ||
| }, | ||
| BatchSize::LargeInput, |
Owner
There was a problem hiding this comment.
It would be good to explain why we create a child ui. The best way to explain it would be to test it (i.e. make sure there are more shapes after the call to ui.label then before it
Collaborator
Author
There was a problem hiding this comment.
Done, I explain it in the create_benchmark_ui doc comment
cb0fe47 to
7d37bc2
Compare
darkwater
pushed a commit
to darkwater/egui
that referenced
this pull request
Aug 24, 2025
This helped me benchmark the atomic layout (emilk#5830) changes. I also realized that the label benchmark wasn't testing the painting, since the buttons at some point will be placed outside the screen_rect, meaning it won't be painted. This fixes it by benching the label in a child ui. The `label &str` benchmark went from 483 ns to 535 ns with these changes. EDIT: I fixed another benchmark problem, since the benchmark would show the same widget millions of times for a single frame, the WidgetRects hashmap would get huge, causing each iteration to slow down a bit more and causing the benchmark to have unreliable results. With this the `label &str` benchmark went from 535ns to 298ns. Also the `label format!` benchmark now takes almost the same time (302 ns). Before, it was a lot slower since it reused the same Context which already had millions of widget ids.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This helped me benchmark the atomic layout (#5830) changes.
I also realized that the label benchmark wasn't testing the painting, since the buttons at some point will be placed outside the screen_rect, meaning it won't be painted.
This fixes it by benching the label in a child ui.
The
label &strbenchmark went from 483 ns to 535 ns with these changes.EDIT:
I fixed another benchmark problem, since the benchmark would show the same widget millions of times for a single frame, the WidgetRects hashmap would get huge, causing each iteration to slow down a bit more and causing the benchmark to have unreliable results.
With this the
label &strbenchmark went from 535ns to 298ns. Also thelabel format!benchmark now takes almost the same time (302 ns). Before, it was a lot slower since it reused the same Context which already had millions of widget ids.