Forum Discussion
Timing function execution using LAMBDA
Didn't dig this solution. As a comment, CalcTime with lambdas is in samples for AFE on GitHub. It's bit specific but could be adjusted. The only the precision is 10ms since that's the limitation of the desktop app. VBA could give more precise result.
SergeiBaklan After a bit more digging, I found timer() in Lib.md, which I assume is the CalcTime() function you're referring to. It uses the same logic for timing, though it treats results differently by returning both the calculation time and the results in a two-element array.
I'll give some thought to enhancing my version per a previous suggestion (average of multiple iterations) and may post an update.
- mtarlerSep 07, 2023Silver Contributor
I like this as I have been doing something more basic for a while. That said I created another alternative LAMBDA function:
evalTime = Lambda(please_insert_now_function, insert_calc_here, let(endTime, now(), vstack(expand(text(endTime-please_insert_now_function, "m:ss.000"),,columns(insert_calc_here),""), insert_calc_here)));In this case the call is:
=evalTime(NOW(),MAP(SEQUENCE(5000, 5000), LAMBDA(value, value * value)))so I don't have to wrap my function with another LAMBDA
interestingly I consistently get a longer time than your version. presumably because it does the now() and the calculation and then the function call overhead and then the final now() time.