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: boolean | Returns if an entity is valid | |
Benchmark: number | Analyse comparative des performances d'une fonction |
IsEntityValidOptimal
Returns if an entity is valid
local ret = NanosUtils.IsEntityValid(entity)
Paramètres
| Name | Type | Description |
|---|---|---|
entity | any | Entity to verify |
Returns
| Type | Description |
|---|---|
| boolean | if 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
| Name | Type | Description |
|---|---|---|
name | string | Établir le nom à la sortie |
amount | number | Nombre de fois à boucler sur la fonction |
func | function | La fonction à appeler |
args... | any | Les arguments de la fonction à appeler |
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"

