Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
The time to run function for JS, Google Apps Script
// usage
function cars_importRef() {
var t = new Date();
// YOUR CODE
Browser.msgBox('Done! The time to run function is ' + getTimeEllapse_(t));
}
function getTimeEllapse_(t)
{
var dif = new Date() - t;
if (dif < 1000) { return dif + ' ms.'; }
var mm = parseInt(dif/1000), respo = '';
if (mm < 60)
{
respo = mm + ' sec.';
}
else
{
var min = parseInt(mm / 60);
var sec = mm - min *60;
respo = min + ' min. ' + sec + ' sec.';
}
return respo;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment