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: boolean | Returns if an entity is valid | |
Benchmark: number | Benchmarks a function performance |
IsEntityValidOptimalโ
Returns if an entity is valid
local ret = NanosUtils.IsEntityValid(entity)
Parameters
| Name | Type | Description |
|---|---|---|
entity | any | Entity to verify |
Returns
| Type | Description |
|---|---|
| boolean | if 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
| Name | Type | Description |
|---|---|---|
name | string | Benchmark name to output |
amount | number | Amount of times to loop |
func | function | The function to call |
args... | any | The arguments of the function to call |
Returns
| Type | Description |
|---|---|
| number | the 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"

