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

Every used template gets referenced exactly once #87

Merged
merged 2 commits into from
Jul 23, 2024

Conversation

Kijewski
Copy link
Collaborator

Once per #[template], that is. Still multiple times per crate.

Do you think that is enough to resolve #72, @GuillaumeGomez?

Comment on lines +38 to +42
[dev-dependencies]
console = "0.15.8"
similar = "2.6.0"
prettyplease = "0.2.20"
syn = { version = "2.0.3", features = ["extra-traits", "full"] }
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Feel free to tell me if you think this is overkill. I thought "lets make it pretty", but maybe I overdid it a bit :)

Copy link
Contributor

Choose a reason for hiding this comment

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

It's dev dependencies, so I definitely don't care. :)

@GuillaumeGomez
Copy link
Contributor

I think it's definitely not worth it for "by template" approach. I also wondered about it myself but it really only makes sense for multiple templates. But as you underlined, the only solution for that would be tracked_file. I'll see what's missing for it to be done.

Once per `#[template]`, that is. Still multiple times per crate.
@Kijewski
Copy link
Collaborator Author

I think this diff might still make it worthwhile. Doesn't it?

Comment on lines +155 to +158
writer.write_str("3")?;
writer.write_str("3")?;
writer.write_str("3")?;
writer.write_str("3")?;"#
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Will be joined into one call with 3c08d0b.

@GuillaumeGomez
Copy link
Contributor

Can you just provide a bench comparison in addition to the improved output please?

@Kijewski
Copy link
Collaborator Author

rinja_derive_standalone benchmark
hello_world             time:   [48.183 µs 48.253 µs 48.314 µs]
                        change: [-6.5054% -5.3650% -4.2704%] (p = 0.00 < 0.05)
                        Performance has improved.

item_info.html          time:   [58.699 µs 59.057 µs 59.467 µs]
                        change: [-1.5808% -0.9997% -0.4222%] (p = 0.00 < 0.05)
                        Change within noise threshold.

item_union.html         time:   [152.77 µs 152.92 µs 153.11 µs]
                        change: [-3.7432% -3.4421% -3.1460%] (p = 0.00 < 0.05)
                        Performance has improved.

page.html               time:   [651.01 µs 651.83 µs 652.81 µs]
                        change: [-3.8608% -3.5279% -3.1711%] (p = 0.00 < 0.05)
                        Performance has improved.

print_item.html         time:   [141.53 µs 142.07 µs 142.73 µs]
                        change: [-1.4684% -0.6647% +0.4653%] (p = 0.24 > 0.05)
                        No change in performance detected.

short_item_info.html    time:   [122.21 µs 122.49 µs 122.86 µs]
                        change: [-2.3561% -1.9451% -1.5023%] (p = 0.00 < 0.05)
                        Performance has improved.

sidebar.html            time:   [193.36 µs 195.57 µs 197.54 µs]
                        change: [+0.4147% +1.2141% +2.0348%] (p = 0.00 < 0.05)
                        Change within noise threshold.

source.html             time:   [105.18 µs 105.75 µs 106.48 µs]
                        change: [+1.3040% +2.5061% +3.6714%] (p = 0.00 < 0.05)
                        Performance has regressed.

type_layout.html        time:   [176.73 µs 176.98 µs 177.27 µs]
                        change: [-1.6070% -1.1707% -0.7469%] (p = 0.00 < 0.05)
                        Change within noise threshold.

type_layout_size.html   time:   [64.969 µs 65.371 µs 65.771 µs]
                        change: [-3.4571% -2.7019% -1.8661%] (p = 0.00 < 0.05)
                        Performance has improved.

IMO the results are spurious. We don't have a benchmark that uses included files, so the PR should not affect the results in one way or another, except that I replaced one call to quote! with format_args!.

@Kijewski Kijewski mentioned this pull request Jul 23, 2024
3 tasks
@GuillaumeGomez
Copy link
Contributor

What I was interested about was whether or not we had a perf regression. Since it's not the case, all good, thanks!

@GuillaumeGomez GuillaumeGomez merged commit 7eddf9d into rinja-rs:master Jul 23, 2024
17 checks passed
@Kijewski Kijewski deleted the pr-include-once branch July 23, 2024 11:50
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.

Only use include_byte! on a file once across templates
2 participants