Passer au contenu principal
Version: latest - a1.148.0 ⚖️

NanosUtils

Une table contenant des fonctions utiles et auxiliaires.


🎒 Examples

(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

ReturnsNameDescription
booleanIsEntityValidReturns if an entity is valid
numberBenchmarkAnalyse comparative des performances d'une fonction

IsEntityValid

Returns if an entity is valid
local ret = NanosUtils.IsEntityValid(entity)

Parameters

TypeParameterDefaultDescription
anyentity Required parameter Entity to verify

Returns

TypeDescription
booleanif the entity is valid

Benchmark

Analyse comparative des performances d'une fonction et affichage dans la console du temps écoulé
local ret = NanosUtils.Benchmark(name, amount, func, args...)

Parameters

TypeParameterDefaultDescription
stringname Required parameter Établir le nom à la sortie
numberamount Required parameter Nombre de fois à boucler sur la fonction
functionfunc Required parameter La fonction à appeler
anyargs... Required parameter Les arguments de la fonction à appeler

Returns

TypeDescription
numberthe elapsed time in milliseconds
NanosUtils.Benchmark Examples
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"