Skip to content

Instantly share code, notes, and snippets.

@ttarchala
Last active January 3, 2024 17:49
Show Gist options
  • Select an option

  • Save ttarchala/c09132761b12f10280603cc45d883750 to your computer and use it in GitHub Desktop.

Select an option

Save ttarchala/c09132761b12f10280603cc45d883750 to your computer and use it in GitHub Desktop.
Evaluation time of a function
// 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