-
Notifications
You must be signed in to change notification settings - Fork 0
/
client.lua
69 lines (62 loc) · 2.17 KB
/
client.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
local constVec = vec3(0.0, 0.0, 0.0)
local GetEntityCoords = GetEntityCoords
local PlayerPedId = PlayerPedId
local GetDistanceBetweenCoords = GetDistanceBetweenCoords
local Vdist = Vdist
local Vdist2 = Vdist2
local n = 10000000 -- 10 million
RegisterNetEvent("perf:test1", function(i)
if i == nil then error() end
local pos = GetEntityCoords(PlayerPedId())
CreateThread(function()
for i = 1, n do local D = #(pos - constVec) end
TriggerServerEvent("perf:test1", i, n)
end)
end)
RegisterNetEvent("perf:test2", function(i)
if i == nil then error() end
local pos = GetEntityCoords(PlayerPedId())
CreateThread(function()
for i = 1, n do
local v = pos - constVec
local D = v.x ^ 2 + v.y ^ 2 + v.z ^ 2
end
TriggerServerEvent("perf:test2", i, n)
end)
end)
RegisterNetEvent("perf:test3", function(i)
if i == nil then error() end
local pos = GetEntityCoords(PlayerPedId())
CreateThread(function()
for i = 1, n do local D = Vdist(pos[1], pos[2], pos[3], constVec[1], constVec[2], constVec[3]) end
TriggerServerEvent("perf:test3", i, n)
end)
end)
RegisterNetEvent("perf:test4", function(i)
if i == nil then error() end
local pos = GetEntityCoords(PlayerPedId())
CreateThread(function()
for i = 1, n do local D = Vdist2(pos[1], pos[2], pos[3], constVec[1], constVec[2], constVec[3]) end
TriggerServerEvent("perf:test4", i, n)
end)
end)
RegisterNetEvent("perf:test5", function(i)
if i == nil then error() end
local pos = GetEntityCoords(PlayerPedId())
CreateThread(function()
for i = 1, n do
local D = GetDistanceBetweenCoords(pos[1], pos[2], pos[3], constVec[1], constVec[2], constVec[3], false)
end
TriggerServerEvent("perf:test5", i, n)
end)
end)
RegisterNetEvent("perf:test6", function(i)
if i == nil then error() end
local pos = GetEntityCoords(PlayerPedId())
CreateThread(function()
for i = 1, n do
local D = GetDistanceBetweenCoords(pos[1], pos[2], pos[3], constVec[1], constVec[2], constVec[3], true)
end
TriggerServerEvent("perf:test6", i, n)
end)
end)