Skip to content

Instantly share code, notes, and snippets.

@Max-Makhrov
Created March 26, 2020 12:26
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Max-Makhrov/bebfee0af168f844e574290569691754 to your computer and use it in GitHub Desktop.
Save Max-Makhrov/bebfee0af168f844e574290569691754 to your computer and use it in GitHub Desktop.
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