Replies: 3 comments
-
A nice hack to optimize iterations in a binary search is to have the client provide a guess. You'd still implement BS for worst case scenarios when the guess is wrong/lacking but for 99% of cases your while loop will last for 1 iteration, thus saving a ton of gas. I proposed this same system for Pods and it has been working pretty well for the implied volatility calculator. |
Beta Was this translation helpful? Give feedback.
-
Brilliant. In effect, this would mean that the client (frontend app) runs the binary search algo (or the iterative one) in advance so that the user avoids paying gas for this computation. |
Beta Was this translation helpful? Give feedback.
-
Marking this as |
Beta Was this translation helpful? Give feedback.
-
Discussed in #15
Originally posted by paulrberg June 3, 2022
The current approach to find the current segment time is to loop through the segments iteratively. When the segment array has a big length, this is gas inefficient.
We could make the implementation faster by using a binary search algorithm. OpenZeppelin offers a Solidity v0.8 implementation for it.
Beta Was this translation helpful? Give feedback.
All reactions