Closed Antizombie closed 1 year ago
If you check and there will be no improvements. You can cancel this Commit.
I think I will also try to use "goto" to immediately bypass part of the code. For example, when checking
local blockedForward = (linkParams.Direction == "Forward" and link.Nodes[2] == node)
it's possible to jump directly to the next node (node.LinkByLinkedNode) without going through the rest of the code.
I couldn't find any improvements with the new code, it actually got worse:
Old | New | Difference as percentage |
---|---|---|
3.918 ms | 4.108 ms | +5% |
The values above are the average of about 100 tests, switching back and forth between the old and new code several times.
Also, i don't think moving the variables from the function scope into the file scope does help in any way. At best both have similar performance. But it makes the code much harder to read and more cluttered.
Regarding the peaks: I haven't encountered enough to really tell if it got better or worse in either version.
I think I will also try to use "goto"
I would stay away from any goto. If anything put the blockedForward
and blockedBackward
expressions back into the if statement.
But actually, i would just leave it as it is. I expect the performance gain to be minimal (if not unmeasurable), as most links are bidirectional, which means the vast majority of links have to check both cases anyways.
Thank you for checked.
Seems like this usage reduced the number of "peaks".
With the old code: It showed an average of 3.2-2.1ms per call And there were occasional "peaks" up to 4.5
With the new code: It shows an average of 2.9-2.1ms per call And very rare "peaks" up to ~3.5.