nanos world API Reference Unofficial documentation
Static function Shared

NanosUtils.Benchmark

Benchmarks a function performance, outputs in the console the elapsed time

Syntax

Lua
NanosUtils.Benchmark(name, amount, func, args...)

Parameters

Name Type Default 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

  • number the elapsed time in milliseconds

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),