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