What Is the Performance Impact of Using a Safe Math Library?
The performance impact of using a safe math library is a slight increase in gas consumption for every arithmetic operation. The library adds extra opcodes for the checks (e.g. a require statement and a comparison) before performing the actual calculation.
While this overhead is minimal, it is a trade-off for significantly increased security. In Solidity 0.8.0+, the built-in compiler checks also add a slight overhead compared to completely unchecked arithmetic, but it is optimized.