perf: hak-audit — spredte timere, fælles cache (markør->station, salgssteder, identify, Wait-punkter, lagre, positioner), bygningsliste 10 s, profiler, simulering (v1.28.0.0)
Audit (2 reviewere) + simulering bench/bench_hak.lua: værste frame 124,7 ms -> 0,9 ms. - Holdende vognes genplanlægning (5 s) spredes tilfældigt over hele intervallet (før: alle i samme frame). - ADCache: korttids-cache m. spredt udløb (+0-50 %), kun aktiv i spillet; stationsopslag 30 s. - Bygningsliste 10 s (før 1 s: bygninger x markører hvert sekund). Markarbejde-tick forskudt 0,5 s fra menuen. - ADProfiler: logger top-6 langsomste indgange pr. minut ved > 2 ms.
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
-- Kør: luajit tests/test_adCache.lua (fra repo-roden)
|
||||
local failures = 0
|
||||
local function check(name, actual, expected)
|
||||
if actual == expected then print("OK " .. name) else
|
||||
failures = failures + 1
|
||||
print(string.format("FAIL %s: forventede %s, fik %s", name, tostring(expected), tostring(actual)))
|
||||
end
|
||||
end
|
||||
g_currentMission = {time = 0}
|
||||
dofile("FS25_ADSmartPickup/adCache.lua")
|
||||
local calls = 0
|
||||
local function lookup() calls = calls + 1; return "station" end
|
||||
check("K1 slået fra: altid opslag", ADCacheGet("b", "k", 1000, lookup) .. ADCacheGet("b", "k", 1000, lookup), "stationstation")
|
||||
check("K1 to opslag", calls, 2)
|
||||
ADCache.enabled = true
|
||||
calls = 0
|
||||
ADCacheGet("b", "k", 1000, lookup); ADCacheGet("b", "k", 1000, lookup)
|
||||
check("K2 genbrugt", calls, 1)
|
||||
g_currentMission.time = 900
|
||||
ADCacheGet("b", "k", 1000, lookup)
|
||||
check("K2 inden for levetid", calls, 1)
|
||||
g_currentMission.time = 1600
|
||||
ADCacheGet("b", "k", 1000, lookup)
|
||||
check("K3 efter levetid + spredning (maks 1500) -> nyt opslag", calls, 2)
|
||||
local nothing = 0
|
||||
ADCacheGet("n", "x", 1000, function() nothing = nothing + 1; return nil end)
|
||||
check("K4 intet fundet huskes", ADCacheGet("n", "x", 1000, function() nothing = nothing + 1; return "ny" end), nil)
|
||||
check("K4 kun ét opslag", nothing, 1)
|
||||
-- spredt udløb: 200 poster lavet samtidig udløber ikke samtidig
|
||||
g_currentMission.time = 10000
|
||||
for i = 1, 200 do ADCacheGet("spread", i, 10000, function() return i end) end
|
||||
local expired = 0
|
||||
g_currentMission.time = 22000
|
||||
for i = 1, 200 do ADCacheGet("spread", i, 10000, function() expired = expired + 1; return i end) end
|
||||
check("K5 kun en del udløbet efter 12 s (spredt 10-15 s)", expired > 20 and expired < 180, true)
|
||||
ADCache.clear()
|
||||
check("K6 ryddet", next(ADCache.buckets), nil)
|
||||
|
||||
print(failures == 0 and "\nALLE TESTS OK" or ("\n" .. failures .. " FEJL"))
|
||||
os.exit(failures == 0 and 0 or 1)
|
||||
Reference in New Issue
Block a user