Skip to content

Instantly share code, notes, and snippets.

@SergeiStPete
Created April 23, 2022 12:18
Show Gist options
  • Save SergeiStPete/1a52bdcc39e5e891d4aa6ab83eeebe40 to your computer and use it in GitHub Desktop.
Save SergeiStPete/1a52bdcc39e5e891d4aa6ab83eeebe40 to your computer and use it in GitHub Desktop.
Excel Lambda basic functions
/*
Partly taken from samples to AFE
https://github.com/microsoft/advanced-formula-environment
more exactly from
https://github.com/microsoft/advanced-formula-environment/blob/main/examples/Lib.md
*/
// ======================================================================================================
// Timing a computation wrapped in a thunk
calculationTime = LAMBDA(thunk,
LET( start, NOW()
, value, thunk()
, end, NOW()
, days, end - start
, ms, days * 24 * 60 * 60 * 1000 // milliseconds (resolution 10ms on desktop)
, ms_round, round(ms,0)
, "Calc time: " & ms_round & " ms"
)
);
// ======================================================================================================
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment