Last active
January 3, 2024 17:49
-
-
Save ttarchala/c09132761b12f10280603cc45d883750 to your computer and use it in GitHub Desktop.
Evaluation time of a function
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // based on this Microsoft Tech Community article by Kevin Dean: | |
| // https://techcommunity.microsoft.com/t5/excel/timing-function-execution-using-lambda/m-p/3920420 | |
| // Measures the evaluation time of a lambda function call passed as argument. | |
| // To use with builtin functions, or with your own user-defined functions, wrap them in a LAMBDA(). | |
| // =EvaluationTime(LAMBDA(<yourFunction>(<yourArguments>)) | |
| EvaluationTime=LAMBDA(F, | |
| LET( | |
| startTime, NOW(), | |
| result, F(), | |
| stopTime, NOW(), | |
| reducedResult, REDUCE(, result, LAMBDA(accumulator, value, | |
| IF(ISERROR(accumulator), | |
| accumulator, | |
| value | |
| ) | |
| )), | |
| IF(ISERROR(reducedResult), | |
| reducedResult, | |
| TEXT(stopTime - startTime, "m:ss.000") | |
| ) | |
| ) | |
| ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment