How to calculate total execution time of a Javascript Function