Skip to content

feat: add utility function for benchmarking#398

Merged
LordMidas merged 4 commits into
developmentfrom
feat-benchmark-utility-function
Aug 5, 2024
Merged

feat: add utility function for benchmarking#398
LordMidas merged 4 commits into
developmentfrom
feat-benchmark-utility-function

Conversation

@LordMidas

@LordMidas LordMidas commented Jul 16, 2024

Copy link
Copy Markdown
Member

This is a useful function for benchmarking a single function or comparing the benchmarks of several functions. Usage:

// Let's say we have 3 functions called foo, bar, baz
// we pass them as references in an array and assign them an id that will be printed in log
::MSU.Utils.benchmark([
	["Endy",  foo],
	["Midas", bar],
	["Taro", baz]
]);

This will print to log the performance of the 3 functions as well as their relative performance to the first function i.e. in this case Endy.

In case your functions need parameters you can manually call them via passing lambdas to the utility function and using local variables as the args:

::MSU.Utils.benchmark([
	["Endy",  @() foo(pass args here)],
	["Midas", @() bar(pass args here)],
	["Taro", @() baz(pass args here)]
]);

Sample:
image

@LordMidas LordMidas requested review from Enduriel and TaroEld July 16, 2024 03:49
Comment thread msu/utils/utils.nut
Comment thread msu/utils/utils.nut Outdated
Comment thread msu/utils/utils.nut Outdated
@LordMidas LordMidas requested a review from Enduriel August 3, 2024 22:42
@LordMidas LordMidas merged commit 0988862 into development Aug 5, 2024
@LordMidas LordMidas deleted the feat-benchmark-utility-function branch August 5, 2024 22:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants