How to calculate loss in a given time budget?

Just do time() inside of a callback and save the array of times, then do diff of the result. Do it all in the callback to cutoff compile time outliers.