Passer au contenu principal
Version: bleeding-edge 🩸

NanosUtils

Une table contenant des fonctions utiles et auxiliaires


🎒 Exemples​

(NanosUtils.Benchmark) Benchmarks a function
local arg1 = math.random()
local arg2 = math.random()

NanosUtils.Benchmark("My Heavy Operation", 1000, function(param1, param2)
-- Do some heavy operations here
local result = param1 * param2
end, arg1, arg2)

-- Outputs "Benchmark 'My Heavy Operation' (x1000) took 1.5ms"

🗿 Static Functions​

IsEntityValid: booleanReturns if an entity is valid
Benchmark: numberAnalyse comparative des performances d'une fonction

IsEntityValidOptimal​

Returns if an entity is valid

local ret = NanosUtils.IsEntityValid(entity)
Paramètres
NameTypeDescription
entityanyEntity to verify
Returns
TypeDescription
booleanif the entity is valid

BenchmarkSlow​

Analyse comparative des performances d'une fonction

It outputs the elapsed time in the console

local ret = NanosUtils.Benchmark(name, amount, func, args...)
Paramètres
NameTypeDescription
namestringÉtablir le nom à la sortie
amountnumberNombre de fois à boucler sur la fonction
funcfunctionLa fonction à appeler
args...anyLes arguments de la fonction à appeler
Returns
TypeDescription
numberthe elapsed time in milliseconds
Examples (1)
Benchmarks a function
local arg1 = math.random()
local arg2 = math.random()

NanosUtils.Benchmark("My Heavy Operation", 1000, function(param1, param2)
-- Do some heavy operations here
local result = param1 * param2
end, arg1, arg2)

-- Outputs "Benchmark 'My Heavy Operation' (x1000) took 1.5ms"