Forum Discussion
Timing function execution using LAMBDA
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.
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.