Bug 45373 - Huge performance problems
Huge performance problems
Status: RESOLVED FIXED
Product: POI
Classification: Unclassified
Component: HSSF
3.0-FINAL
PC Windows XP
: P2 normal (vote)
: ---
Assigned To: POI Developers List
:
Depends on:
Blocks:
  Show dependency tree
 
Reported: 2008-07-10 05:11 UTC by Jens Klinker
Modified: 2008-07-10 10:52 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jens Klinker 2008-07-10 05:11:03 UTC
I´m using jxl, jx:if-tags, inside jx:for. This (jx:if) is calling very often the following function and so I have huge performance problems!

Used poi-version:
poi-3.0.2-FINAL

Class:
org.apache.poi.hssf.usermodel.HSSFSheet

Method:
	public void shiftRows(int startRow, int endRow, int n, boolean copyRowHeight, boolean resetOriginalRowHeight) {


Ist improvement:
----------------

line-number 1199: problem is call of row2Replace.getLastCellNum() on each iteration:

for ( short col = row2Replace.getFirstCellNum(); col <= row2Replace.getLastCellNum(); col++ )


why you don´t use following code instead? I save 30 % time!

short col=row.getFirstCellNum();
short lastCol=row.getLastCellNum();
while (true){
if(col > lastCol){
break;
}


IInd improvement:
----------------

line-number 1228: I removed the following code because I never work with comments, and most other people also. And I save again about 30 %. Perhaps you should make this optional by using boolean parameter?

HSSFComment comment = getCellComment(rowNum, col);
if (comment != null) {
comment.setRow(rowNum + n);
}


With this 2 changes now I need 20 secs instead of 1 min!
Comment 1 Jens Klinker 2008-07-10 06:52:37 UTC
I´ve changed this:
short lastCol=row.getLastCellNum();

to this:
int lastCol = row.getPhysicalNumberOfCells();

now, I need 2 secs! instead of 1 min!
Comment 2 Nick Burch 2008-07-10 10:52:41 UTC
Your proposed fix using physical number of cells won't work for cases where there are gaps in the row, with not all cells being defined.

I've made some changes to HSSFSheet.shiftRows, committed to svn trunk. These should hopefully speed the method up, whilst ensuring that everything that needs to be moved is. Hopefully this does what you need?