[Performance Question] Loading a workbook for the first time

Dear Aspose,


I have been using Aspose.Cells to create a software for my clients.

I am now required to tune the performance to its best.

It is found that loading workbook for the first time
takes far more time than the second time, i.e. Doing it twice consecutively.

Long boring codes:
For example // Code attached
for (int i = 1; i < 3; i++)
{
Workbook wb = new Workbook(“Blank.xlsx”)
wb.DoSomething();
wb.Save(“Result.xlsx”);
}

Time used
1st time: 630ms
2nd time: 11ms

=========================Separator=======================

As a workaround, I preload the workbook once before actually doing work

// Code also attached
Workbook preLoadWB = new Workbook(“Blank.xlsx”)
for (int i = 1; i < 3; i++)
{
Workbook wb = new Workbook(“Blank.xlsx”)
wb.DoSomething();
wb.Save(“Result.xlsx”);
}

Time used
1st time: 178ms
2nd time: 6ms
=========================Separator=======================

Potential?
The performance is getting better after preloading the workbook
But the performance for the first time really is what we are looking to improve.
(as my clients are mostly doing work once only and 178ms is not very ideal while comparing to the second attempt 6ms)

Question
Is there a way that I can workaround and make the “first” attempt as fast as the “second”?

Testing machine:
i5 - 4460 3.2GHz
8GB Ram
64 bit
Win 10
Aspose.Cells 17.01.12

Remark:
Memory is not my concern
.Net 4.5 is acceptable (3.5 would be better)

I really hope that I can make my software as fast as possible.

Many many many thanks,
Jonathan Lau

Hi,


Thanks for the sample code, performance output (stats) and details.

After an initial test, I observed the issue as you mentioned by using your sample code with a simple blank template XLSX file. Well, we need to investigate your issue thoroughly. But, we are not sure whether we can improve it further or not. For your information, there are some static data in the workbook that must be prepared at the first time and this data will be cached and reused for later processing of the workbook(s). Anyways, I have logged a ticket with an id “CELLSNET-45295” for your issue. We will look into it soon.

Once we have an update on it, we will let you know here.

Thank you.

Hi,


Well, it should be the behaviour of C# project that it will compile the codes when first running. Please open and save the file to call more codes when pre-loading the workbook. See following codes:
e.g
Sample code:

Workbook preLoadWB = new Workbook(“Blank.xlsx”);
preLoadWB.Save(“Result.xlsx”);

Thank you.