Looking into how various operations perform as the size of the sheet increase provided some interesting data. The objective is to see whether the time to execute particular operations is directly proportional to the size of the sheet.
First of all, the test
A scheduled task ran every minute reading and writing, inserting and deleting data to a sheet, and gradually increasing the number of rows. It started at 1000 rows (20 columns), and each task removed 100 and added 250 rows - a net 150 row increase for each iteration. Since there is some kind of caching involved behind the scenes, the data was randomized to ensure that it actually got rewritten, and the test was repeated with and without a flush operation between each data manipulation.
Here's the first result, with no flushing.
The rewrite operation is by far the most expensive, and is not proportional to the number of records. The other operations are pretty good. There is a strange pattern of a spike followed by a gradual increase till the next spike. Further analysis - this time normalizing by dividing the time by the number of rows gives an operation time per row. If this was strictly linear, it would be a straight line. This highlights these spikes every 1000 rows, not just for the rewrite operation (although it is most pronounced), but for the others too.
Clearly there is some kind of housekeeping done every now and again - watch this space for more analysis.
Here are the tests, triggered every minute.
For more like this, see Performance. Why not join our forum, follow the blog or follow me on twitter to ensure you get updates when they are available.
Learning Apps Script, (and transitioning from VBA) are covered comprehensively in my my book, Going Gas - from VBA to Apps script, All formats are available from O'Reilly, Amazon and all good bookshops. You can also read a preview on O'Reilly
Services > Desktop Liberation - the definitive resource for Google Apps Script and Microsoft Office automation > Performance >