Reputation: 225
The following script below used to be faster but is now much slower. Are Google's servers just overloaded today?
Is there a way I can make this script run faster?
function main() //ACTIVE
{
var ss = SpreadsheetApp.getActiveSpreadsheet();
var s = ss.getActiveSheet();
var headerCellEntryRow = ss.getRangeByName("headerRow").getRow() + 1;
var dateRangePostedCol = ss.getRangeByName("serviceDatesPosted").getColumn();
var datePostedRange = s.getRange(headerCellEntryRow, dateRangePostedCol);
datePostedRange.setValue(new Date()).setNumberFormat("MM/dd/yyyy");;
s.insertRowBefore(headerCellEntryRow);
s.setFrozenRows(headerCellEntryRow);
}
Upvotes: 0
Views: 224
Reputation: 2140
There are many factors to consider here on the performance of the script. Here are some best practices you can do to make your script faster: https://developers.google.com/apps-script/guides/support/best-practices#:~:text=Use%20batch%20operations,-Scripts%20commonly%20need&text=Alternating%20read%20and%20write%20commands,should%20not%20follow%20or%20use.
Looking at your script, for such a short script it should not take that long unless you are working with very big data in your spreadsheet.
Upon checking, all Google services are working fine as of today:
Reference Link: https://www.google.com/appsstatus/dashboard/
Also for such a huge difference from 7 sec to over a minute that alone cannot be caused by a minor change in your script or your data, if you are sure there were no changes made and the script just suddenly increased the runtime I suggest you post your issue/concern here: https://issuetracker.google.com/issues
Upvotes: 1