MusicalNinjaDad / FizzBuzz

Combining rust & python with pyo3
https://musicalninjadad.github.io/FizzBuzz/
2 stars 1 forks source link

Performance improvements - new return types in rust #57

Closed MusicalNinjaDad closed 3 months ago

MusicalNinjaDad commented 3 months ago

Rust 4.0.0 & Python 3.0.1

Summary by Sourcery

This pull request introduces significant performance improvements by updating the return types for FizzBuzz and MultiFizzBuzz. The FizzBuzzAnswer enum has been refactored to directly represent valid FizzBuzz answers. The Python implementation has been updated to work with Rust v4.0.0, bringing slight performance improvements. Documentation and tests have been updated accordingly.

sourcery-ai[bot] commented 3 months ago

Reviewer's Guide by Sourcery

This pull request introduces significant performance improvements by changing the return types in the Rust implementation of the FizzBuzz library. The MultiFizzBuzz trait now returns a lazy rayon::iter::IndexedParallelIterator, and the FizzBuzz function returns a FizzBuzzAnswer enum, which can be converted into a String or Cow<str>. The Python implementation has also been updated to work with Rust v4.0.0, resulting in slight performance improvements (approximately 10-20%).

File-Level Changes

Files Changes
rust/fizzbuzz/src/lib.rs
rust/fizzbuzz/tests/test_numbertypes.rs
rust/fizzbuzz/tests/test_multifizzbuzz.rs
Updated Rust implementation to use new return types for performance improvements and updated corresponding tests.
rust/fizzbuzzo3/src/lib.rs
tests/perf_results.md
Updated Python wrapper and added performance results for new return types.
rust/fizzbuzz/benches/bench_fizzbuzz.rs
rust/fizzbuzz/benches/bench_sizes.rs
Updated benchmarks to reflect new return types and added new benchmarks for Cow<str>.

Tips - Trigger a new Sourcery review by commenting `@sourcery-ai review` on the pull request. - You can change your review settings at any time by accessing your [dashboard](https://sourcery.ai/dashboard): - Enable or disable the Sourcery-generated pull request summary or reviewer's guide; - Change the review language; - You can always [contact us](mailto:support@sourcery.ai) if you have any questions or feedback.
codecov[bot] commented 3 months ago

Codecov Report

Attention: Patch coverage is 94.33962% with 3 lines in your changes missing coverage. Please review.

Files Patch % Lines
rust/fizzbuzz/src/lib.rs 90.62% 3 Missing :warning:
Additional details and impacted files | [Flag](https://app.codecov.io/gh/MusicalNinjaDad/FizzBuzz/pull/57/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None) | Coverage Δ | | |---|---|---| | [fizzbuzz](https://app.codecov.io/gh/MusicalNinjaDad/FizzBuzz/pull/57/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None) | `94.64% <90.62%> (+0.79%)` | :arrow_up: | | [fizzbuzzo3](https://app.codecov.io/gh/MusicalNinjaDad/FizzBuzz/pull/57/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None) | `90.52% <81.25%> (+3.02%)` | :arrow_up: | | [python](https://app.codecov.io/gh/MusicalNinjaDad/FizzBuzz/pull/57/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None) | `100.00% <ø> (ø)` | | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None#carryforward-flags-in-the-pull-request-comment) to find out more.

:loudspeaker: Thoughts on this report? Let us know!