TEST 1: Localize
Code:
local min = math.minResults:
Non-local: 0.719 (158%)
Localized: 0.453 (100%)Conclusion:
Yes, we should localize all standard lua and Spring API functions.
Source: https://springrts.com/wiki/Lua_Performance
What is the reason for that performance boost?
math.minmeans double looking into hash-part of table (searchingmathin globals table and searchingminin tablemath) using CPU-intensive calculations of hash-function values of stringsmathandmin. - Egor Skriptunofflocal math = mathinstead oflocal min = math.min. - lhf