-
Notifications
You must be signed in to change notification settings - Fork 6
/
nwvar_vs_darkrpvar.lua
70 lines (61 loc) · 2.37 KB
/
nwvar_vs_darkrpvar.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
--Requires luctus_benchmark.lua to be loaded
--10 times, with a 0.2s delay inbetween, run the following functions 10.000 times each
LuctusCompareOften(10,0.2,10000,{
{"darkrpvar",function() local a = Entity(1):getDarkRPVar("job") end},
{"gmodnwvar",function() local a = Entity(1):GetNWString("job") end},
})
--Older code, without lib:
--[[
--Tests: nw=10000 / rp=10000
--NW: 2.3140229998944e-05
--RP: 2.494706000125e-05
--First type "nw" and wait for the squares to vanish, then type "rp" and wait again - after they vanish too type "result"
--Im lazy and this is an easy test setup (same as hudpaint_3call_cache.lua)
hook.Add("OnPlayerChat","luctus_fps_test",function(ply,text,team,dead)
if text == "nw" then
timer.Simple(2,triggerNWTest)
end
if text == "rp" then
timer.Simple(2,triggerRPTest)
end
if text == "result" then
local lRes = 0
local nRes = 0
for k,v in pairs(nw_frametimes) do
lRes = lRes + v
end
for k,v in pairs(rp_frametimes) do
nRes = nRes + v
end
chat.AddText("Tests: nw="..#nw_frametimes.." / rp="..#rp_frametimes)
chat.AddText("NW: "..(lRes/#nw_frametimes))
chat.AddText("RP: "..(nRes/#rp_frametimes))
end
end)
rp_frametimes = {}
nw_frametimes = {}
function triggerRPTest()
local i = 0
hook.Add("HUDPaint","luctus_fps_test_rp",function()
local ss = SysTime()
draw.DrawText(LocalPlayer():getDarkRPVar("job"), "DermaDefault",500, 500, color_white, TEXT_ALIGN_LEFT)
draw.DrawText(LocalPlayer():getDarkRPVar("job"), "DermaDefault",200, 200, color_white, TEXT_ALIGN_LEFT)
draw.DrawText(LocalPlayer():getDarkRPVar("job"), "DermaDefault",100, 100, color_white, TEXT_ALIGN_LEFT)
table.insert(rp_frametimes,SysTime()-ss)
i = i + 1
if i == 10000 then hook.Remove("HUDPaint", "luctus_fps_test_rp") end
end)
end
function triggerNWTest()
local i = 0
hook.Add("HUDPaint","luctus_fps_test_nw",function()
local ss = SysTime()
draw.DrawText(LocalPlayer():GetNWString("job"), "DermaDefault",500, 500, color_white, TEXT_ALIGN_LEFT)
draw.DrawText(LocalPlayer():GetNWString("job"), "DermaDefault",200, 200, color_white, TEXT_ALIGN_LEFT)
draw.DrawText(LocalPlayer():GetNWString("job"), "DermaDefault",10, 10, color_white, TEXT_ALIGN_LEFT)
table.insert(nw_frametimes,SysTime()-ss)
i = i + 1
if i == 10000 then hook.Remove("HUDPaint", "luctus_fps_test_nw") end
end)
end
--]]