Skip to main content
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
NameTypeDescription
entityanyEntity to verify
Returns
TypeDescription
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
NameTypeDescription
namestringBenchmark name to output
amountnumberAmount of times to loop
funcfunctionThe function to call
args...anyThe arguments of the function to call
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"