-
Notifications
You must be signed in to change notification settings - Fork 222
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
improve parser performance #623
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hi, interesting find. I think it may have been already a cached property in the past, but the for some reason I must have removed it.
Could you change the implementation by using functools.cached_property
instead? It should result in a way neater implementation.
Also, make sure to invalidate the cached attribute when self.lines
or self._name
are modified.
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## master #623 +/- ##
==========================================
+ Coverage 95.40% 95.45% +0.05%
==========================================
Files 49 49
Lines 1763 1783 +20
Branches 160 195 +35
==========================================
+ Hits 1682 1702 +20
Misses 53 53
Partials 28 28
☔ View full report in Codecov by Sentry. |
thanks for the review, I have modified the code to use Performance is the same Let me know what you think |
Hi @youtux , Actually you were right we can Anyway that showed my modifications were lacking proper testing so I added a unit test as well to validate the cache behavior. Changing values directly on the step object to show the cache value is still returned (which should never happen in production code). Cheers |
Hi,
Using py-spy to check where to improve the performance of my tests, I noticed a lot of time was spent in the Step name property.
Just by caching the value instead of recalculating it every time I gain ~15%.
Same gain when I run the tests in parallel
Sequence:
Parallel:
It is a very minor change, hope it can be merged.
Thanks