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

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.

The results

Here’s the first result, with no flushing.

Description

operation  what it does
 open  opens the workbook and sheet
 read  reads all the data in one go
 insert  inserts 250 rows
 write  writes data to 250 rows
 deleterows  deletes 100 rows
 reread  reads all the data again
 rewrite  writes all the data

Findings

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.

Now with flushing – the same pattern of spikes every 1000 records.

Clearly there is some kind of housekeeping done every now and again – watch this space for more analysis.

The Code

Here are the tests, triggered every minute.
If you want to try these for yourself, you’ll need the cUseful library.

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.