I did a quick stress test of npoi 2.0 beta and I simply wrote a string in the first cell of each row up to 100k. The output was as follows:
Start time: 5/14/2013 5:05:39 PM
[00:00:00.0170017] 0 rows written
[00:00:02.7792779] 10000 rows written
[00:00:11.1951194] 20000 rows written
[00:00:27.7817779] 30000 rows written
[00:00:53.5283523] 40000 rows written
[00:01:30.1910182] 50000 rows written
[00:02:16.2836270] 60000 rows written
[00:03:14.6894670] 70000 rows written
[00:04:21.9641938] 80000 rows written
[00:05:38.7868753] 90000 rows written
[00:07:05.4055363] 100000 rows written
As you can see the curve here will be exponential and this is really terrible performance. After using the performance wizard in VS 2012, I found that 88% of the time was spent in GetLastKey. This means that the majority of the time was spent seeking in the sheet to the appropriate row (my theory is supported by the above data, each incremental set is longer to write). I am hoping to improve this by updating the active cell with each cell set, but I get a not implemented error when I call SetActiveCell. Is there a work around here?
My code:
Start time: 5/14/2013 5:05:39 PM
[00:00:00.0170017] 0 rows written
[00:00:02.7792779] 10000 rows written
[00:00:11.1951194] 20000 rows written
[00:00:27.7817779] 30000 rows written
[00:00:53.5283523] 40000 rows written
[00:01:30.1910182] 50000 rows written
[00:02:16.2836270] 60000 rows written
[00:03:14.6894670] 70000 rows written
[00:04:21.9641938] 80000 rows written
[00:05:38.7868753] 90000 rows written
[00:07:05.4055363] 100000 rows written
As you can see the curve here will be exponential and this is really terrible performance. After using the performance wizard in VS 2012, I found that 88% of the time was spent in GetLastKey. This means that the majority of the time was spent seeking in the sheet to the appropriate row (my theory is supported by the above data, each incremental set is longer to write). I am hoping to improve this by updating the active cell with each cell set, but I get a not implemented error when I call SetActiveCell. Is there a work around here?
My code:
class Program
{
static void Main(string[] args)
{
IWorkbook workbook = new XSSFWorkbook();
ICell cell;
ISheet sheet = workbook.CreateSheet("StressTest");
int i = 0;
int rowLimit = 100000;
DateTime originalTime = DateTime.Now;
System.Console.WriteLine("Start time: " + originalTime);
for (i = 0; i <= rowLimit; i++)
{
cell = sheet.CreateRow(i).CreateCell(0);
//sheet.SetActiveCell(i, 0);
cell.SetCellValue("ZOMG PLEASE SURVIVE THIS STRESS TEST");
if(i % 10000 == 0)
{
System.Console.WriteLine("[" + (DateTime.Now - originalTime) + "]" + " " + i + " rows written");
}
}
FileStream sw = File.Create("test.xlsx");
workbook.Write(sw);
sw.Close();
//prompt user so we do not close the window with our data :)
System.Console.Read();
}
}