To correct Serge's answer, where call to Date function has a problem, you can use this solution.
function myFunction() {
var start_time = new Date().getTime();
/*
your code goes here
*/
Logger.log('Total execution time is :' + (new Date().getTime()-start_time) + ' ms');
}
you can replace the comment lines with your code. After execution press Ctrl + Enter or Command ⌘ + Enter on Mac to see the logs. You will get something like following:
[17-01-18 12:25:58:932 UTC] Total execution time is :16586 ms
So here total execution time is 16586 ms or in other words 16.586 Seconds.
In addition to above you can add the following snippet in between your code to measure execution time from different parts.
Logger.log('Execution time till checkpoint 1:' + (new Date().getTime()-start_time) + ' ms');