I am having trouble to understand why this takes so long to execute and whether there is a solution to this. It requires 20 seconds to execute the .setValues() line. The grid is about 2000 (row) by 100 (col) cells.
Here is a link to the test speed sheet for testing material, that is like my data-set.
function test() {
var active = SpreadsheetApp.getActiveSpreadsheet();
var logs_sheet = active.getSheetByName("Logs");
logs_sheet.appendRow([new Date(), "", "", "STARTING EXECUTION"]);
var test_sheet = active.getSheetByName("Test");
var test_data = test_sheet.getRange(1, 1, test_sheet.getLastRow(), test_sheet.getLastColumn()).getValues();
var combine = test_data.slice();
combine[1].splice(3, 1, new Date());
combine.splice(2017, 1);
combine.splice(0, 0, combine[1]);
logs_sheet.appendRow([new Date(), "", "", "finished combine"]);
test_sheet.getRange(1, 1, combine.length, combine[0].length).setValues(combine);
logs_sheet.appendRow([new Date(), "", "", "FINISHED EXECUTION"]);
}
What's more is that setValues() appears to update the sheet quite fast, but then it continues running something invisible before moving on.