How to time any function