Created
March 26, 2020 12:26
-
-
Save Max-Makhrov/bebfee0af168f844e574290569691754 to your computer and use it in GitHub Desktop.
The time to run function for JS, Google Apps Script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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