Ir para o conteúdo principal
Version: bleeding-edge 🩸

NanosUtils

A table containing useful and aux functions


🎒 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​

IsEntityValid: booleanReturns if an entity is valid
Benchmark: numberBenchmarks a function performance

IsEntityValidOptimal​

Returns if an entity is valid

local ret = NanosUtils.IsEntityValid(entity)
Parameters
NameTypeDescrição
entityanyEntity to verify
Returns
TypeDescrição
booleanif the entity is valid

BenchmarkSlow​

Benchmarks a function performance

It outputs the elapsed time in the console

local ret = NanosUtils.Benchmark(name, amount, func, args...)
Parameters
NameTypeDescrição
namestringBenchmark name to output
amountnumberAmount of times to loop
funcfunctionThe function to call
args...anyThe arguments of the function to call
Returns
TypeDescrição
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"