Closed QGarchery closed 1 year ago
Generated at commit: 9728cd25a6f1a075c7cdaa21b25da2a2d5109309, compared to commit: 70b8eec7a2c7a3f8bf07a2e99c459ca86263057e
Contract | Method | Avg (+/-) | % |
---|---|---|---|
MathMock contract | log2 | +95 โ | +15.22% |
I'm not a big fan tbh (always the same debate). I must admit that it simplifies the tests quite a bit, but the fact that we add a useless return in the code for this reason looks also very weird.
Agreed, it looks weird. Adding the return actually saves some gas somehow
It seems that the changes are motivated by tests, is it correct? What is the impact on gas? I'm not sure to understand your comment below. On this PR I'm seeing 734 as gas cost for the log2.
If you look at the PR linked you see that the impact on gas is 645 gas, whereas before it was 624. The linked PR does not change the library, but only how it is used. Even then, nothing is changed if we run only the CompareLog2
tests. So I'm assuming the compilation is different because the compiler sees that the functions _roundDownToPowerOf2
and _lookupDeBruijn
are used and cannot be inlined. This is why I said they those 2 functions should really be private (but then we couldn't test them)
Seen with @MerlinEgalite: we are closing this for now as we feel it makes it less efficient while not providing enough clarity.
Gas report seems off when you use the internal functions which should really be private.
See https://github.com/morpho-dao/morpho-utils/pull/89 that shows a 645 gas usage for the new log2 (vs 624 before)