perf: improve code generation performance #161
Merged
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.
Use
BufWriter
and avoid formatting generated code for faster build times.BEFORE
![rust_mavlink_master_comptime](https://user-images.githubusercontent.com/13651052/226373854-aa6fbf8c-d155-48eb-8ea8-8a6ca42d9bc8.png)
AFTER
![rust_mavlink_better_comptime](https://user-images.githubusercontent.com/13651052/226373974-eaffdeee-8b44-4c6a-846b-d7a1f13f1964.png)
This PR still doesn't address the main issue which is the compilation time of the
mavlink
crate itself. But for a 14 line change I don't see a reason not to do this. It makes code generation 3x faster.PS: The measurements were taken with
cargo clean
followed bycargo b --test encode_decode_tests --timings
on a Ryzen 5 5600X processor.