-
Notifications
You must be signed in to change notification settings - Fork 185
function next(eit::EdgeIter, state) now does not modify state #423
Conversation
Current coverage is 98.14% (diff: 100%)
|
Can you run a quick benchmark before and after?
ought to test things. |
There are more allocations as expected. Maybe we should keep it as it is without my modifications: after patch: 0.087874 seconds (1.02 M allocations: 23.315 MB, 19.94% gc time) before patch 0.079939 seconds (16.54 k allocations: 8.038 MB, 4.63% gc time) |
Oh, yeah, look at those allocations. Not sure this is a great idea right now, though I understand why we'd want to consider it. Thanks for pulling it together though. |
I don t see surprising info in the amount of allocations. Returning a separate state when iterating 1M times requires 1M allocations. the time doubles in average which is less than what I expected from the allocations. But yes if the package aims to reach the performance edge, this is definitely not a good idea, so feel free to close both the issue and the PR. |
using immutable 0.085918 seconds (15.47 k allocations: 8.019 MB, 4.61% gc time) EDIT: The results are even better than before... I m surprised. |
Now those speeds are compelling :) |
These numbers look close enough to existing performance. |
Where's the code, though? Edit: ah, there we go. |
Haha #WheresTheresTheCode |
s = state.s | ||
di = state.di + 1 | ||
di = state.di | ||
first || (di += 1) |
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.
Please rewrite this without short-circuiting (per our guidelines):
Style point: prefer the short circuiting conditional over if/else when convenient, and where state is not explicitly being mutated (e.g., condition && error("message") is good; condition && i += 1 is not).
@IssamT - thanks for your help with this! |
My thanks to you @sbromberger for helping make the fix better that my first suggestion |
Fixing #419
It seems that there are some exceptions in julia Base where next modified its arguments, but I don't think it is needed here. Maybe if you have some benchmarks I can run them and see the impact of such modification.