I did a quick couple of tests using my custom profiler that I developed originally for testing my AI, and found that in normal conditions the % of time spend in the two veterancy functions in question did not exceed ~0.2% of total sim compute time. This test was done in a 4v4 between my AIs, which are currently very land focussed.
In ASF vs ASF tests I was able to get it up to at most ~2% of total sim compute time, but during the periods of negative sim speed it was at most ~0.7%.
==
Overall my conclusion is that the rest of the sim scales worse than these veterancy functions, and they have a negligible effect most of the time. By all means feel free to change the vet system, but it probably doesn't need to be for performance reasons.
==
Cautionary note: this method for profiling may not give completely accurate results for many calls of a low cost function due to the error associated with getting system time and the precision of system time provided. If anyone wants to jump in and check how these errors might have affected it go right ahead
For completeness, a link to my profiling code and my hook of the Unit class for testing:
YeOldeUnitThingy = Unit
local PROFILER = import('/mods/DilliDalli/lua/AI/DilliDalli/Profiler.lua').GetProfiler()
Unit = Class(YeOldeUnitThingy) {
VeterancyDispersal = function(self, suicide)
local start = PROFILER:Now()
YeOldeUnitThingy.VeterancyDispersal(self, suicide)
PROFILER:Add("VeterancyDispersal",PROFILER:Now()-start)
end,
DoTakeDamage = function(self, instigator, amount, vector, damageType)
local start = PROFILER:Now()
YeOldeUnitThingy.DoTakeDamage(self, instigator, amount, vector, damageType)
PROFILER:Add("DoTakeDamage",PROFILER:Now()-start)
end,
}
Some output from tests:
4v4 AI match, ~15 mins ~1k units on the map:
info: Time per game second:0.32s, Top Costs: DoTakeDamage-0.16%, VeterancyDispersal-0.01%,
info: Time per game second:0.34s, Top Costs: DoTakeDamage-0.14%, VeterancyDispersal-0.02%,
info: Time per game second:0.31s, Top Costs: DoTakeDamage-0.15%, VeterancyDispersal-0.01%,
100 vs 100 ASF:
INFO: Time per game second:0.17s, Top Costs: DoTakeDamage-0.65%, VeterancyDispersal-0.09%,
INFO: Time per game second:0.17s, Top Costs: DoTakeDamage-0.97%, VeterancyDispersal-0.11%,
INFO: Time per game second:0.17s, Top Costs: DoTakeDamage-0.75%, VeterancyDispersal-0.11%,
INFO: Time per game second:0.17s, Top Costs: DoTakeDamage-0.58%, VeterancyDispersal-0.11%,
1000 vs 1000 ASF:
INFO: Time per game second:17.49s, Top Costs: DoTakeDamage-0.14%, VeterancyDispersal-0.00%,
INFO: Time per game second:4.23s, Top Costs: DoTakeDamage-0.24%, VeterancyDispersal-0.02%,
INFO: Time per game second:2.60s, Top Costs: DoTakeDamage-0.47%, VeterancyDispersal-0.06%,
INFO: Time per game second:1.98s, Top Costs: DoTakeDamage-0.71%, VeterancyDispersal-0.09%,
INFO: Time per game second:1.26s, Top Costs: DoTakeDamage-1.17%, VeterancyDispersal-0.14%,
INFO: Time per game second:0.92s, Top Costs: DoTakeDamage-1.07%, VeterancyDispersal-0.16%,
INFO: Time per game second:0.59s, Top Costs: DoTakeDamage-2.25%, VeterancyDispersal-0.15%,
INFO: Time per game second:0.44s, Top Costs: DoTakeDamage-1.25%, VeterancyDispersal-0.18%,