Free Support Forum - aspose.com

Performance downgraded while generating PDF Document using AsposeWordsForJava 11.11 when compared to 11.3

Hello Team,

Currently we’re using AsposeWordsForJava11.3 (jdk1.5) version for generating PDF and Word documents. When upgraded to
AsposeWordsForJava11.11 (jdk1.6), the PDF document performance has gone down upto 35%.

Good part is that the performance has improved for Word documents.

With Aspose 11.11 (jdk1.6) version, the PDF document generation time is 10-35% more when compared to 11.3 (jdk1.5). The memory consumption is around 2-4% more with new version.
With
Aspose 11.11 (jdk1.5) version, the PDF document generation time is 5-15%
more when compared to 11.3 (jdk1.5). The memory consumption is around
2-3% more with new version.

Thanks,
Kumar

The below statistics is for a 2000 page PDF document generation with 6000 paragraphs, 30 tables, each table containing 30 rows and 6 columns. The generated PDF size is around 2.9 MB.

The tests were run on
Windows 7 64-bit
Intel Core i5-250M CPU 2.6 GHz
8GB RAM

-------------- Aspose.Words for Java : 11.3.0.0 - JDK1.5 ---------------

##### Before: Heap utilization statistics [MB] #####
Used Memory:7
Free Memory:11
Total Memory:18
Max Memory:1638

Number of Paragraphs: 6000
Number of Tables: 30
Number of Rows: 30
Number of Colums: 6

Table (model) Generation time: 0 seconds.
Model Generation time: 1 seconds.
PDF doc Save time: 227 seconds.
Complete Document generation time (excluding license): 229 seconds.

##### After: Heap utilization statistics [MB] #####
Used Memory:736
Free Memory:901
Total Memory:1638
Max Memory:1638

Document generation used memory (approx) 729 MB.

-------------- Aspose.Words for Java : 11.11.0.0 - JDK1.6 ---------------

##### Before: Heap utilization statistics [MB] #####
Used Memory:12
Free Memory:12
Total Memory:24
Max Memory:1638

Number of Paragraphs: 6000
Number of Tables: 30
Number of Rows: 30
Number of Colums: 6

Table (model) Generation time: 0 seconds.
Model Generation time: 1 seconds.
PDF doc Save time: 286 seconds.
Complete Document generation time (excluding license): 288 seconds.

##### After: Heap utilization statistics [MB] #####
Used Memory:761
Free Memory:876
Total Memory:1638
Max Memory:1638

RPE Document used memory (approx) 749 MB.

-------------- Aspose.Words for Java : 11.11.0.0 - JDK1.5 ---------------

##### Before: Heap utilization statistics [MB] #####
Used Memory:15
Free Memory:15
Total Memory:30
Max Memory:1638

Number of Paragraphs: 6000
Number of Tables: 30
Number of Rows: 30
Number of Colums: 6

Table (model) Generation time: 0 seconds.
Model Generation time: 1 seconds.
PDF doc Save time: 250 seconds.
Complete Document generation time (excluding license): 251 seconds.

##### After: Heap utilization statistics [MB] #####
Used Memory:762
Free Memory:876
Total Memory:1638
Max Memory:1638

RPE Document used memory (approx) 747 MB.

----------------------- Another scenario --------------------------------------------------------------
For 12000 paragraphs, 50 tables, each table with 50 rows and 6 columns, the time taken in
11.3 (jdk 1.5) = 843 sec, memory consumed = 1493 MB
11.11 (jdk 1.6) = 1158 sec, memory consumed = 1544 MB
11.11 (jdk 1.5) = 956 sec, memory consumed = 1539 MB

Hi Kumar,

Thanks for your inquiry. Could you please attach your input Word document along with complete source code here for testing? I will investigate the issue on my side and provide you more information.

Best regards,

Hi Awais,

Just to confirm, the performance issue is with PDF document generatioin.

I did not know/find how to attach a file. Hence copied the complete source code below. You’ll have to change line #29 for attaching a license.

The inputs are in the below junit itself. You could change the number of paragraphs, table, etc in the testScalability() method.

int numOfParagraph = 1000;
int numOfTables = 40;
int numOfRows = 40;
int numOfColumns = 6;

Thanks,
Kumar

import java.io.InputStream;
import java.util.UUID;

import org.junit.Test;

import com.aspose.words.AutoFitBehavior;
import com.aspose.words.BuildVersionInfo;
import com.aspose.words.CellVerticalAlignment;
import com.aspose.words.Document;
import com.aspose.words.DocumentBuilder;
import com.aspose.words.License;
import com.aspose.words.Shape;
import com.aspose.words.StyleIdentifier;
import com.aspose.words.Table;

@SuppressWarnings(“nls”)
public class TestAsposeScalability {
private static final String LONG_TEXT = “This year, the CDL Performance Engineering Community will share a series of good articles we’ve found useful to you each month. Every articles we shared has been carefully selected and studied. For the following two months, we will start from DB2 and Agile Performance Engineering topics. We have also created a forum topic for each article for you to share your impressions and questions, so feel free to click on the relevant forum link and join the discussion! Wish you all Happy reading!”;
private static final String TEXT_FOR_TABLE_CELL = “ISL Team began working on RPE since Dec 2012. “;
private static final java.awt.geom.Rectangle2D.Float IMAGE_BOUNDS = new java.awt.geom.Rectangle2D.Float(
0, 0, 300, 300);
private static long USED_MEMORY_BEFORE;
private static long USED_MEMORY_AFTER;

private void setupLicense() throws Exception {

InputStream licstream = null;
try {
licstream = ;
License license = new License();
license.setLicense(licstream);
} finally {
if (licstream != null) {
licstream.close();
}
}
}

private void writeDocument(int recordsCount, boolean withImages,
String baseFolder, int tableCount, int rowCount, int columnCount,
String extn) throws Exception {
long t1 = System.currentTimeMillis();
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

writeParagraph(builder, recordsCount, withImages);
long t2 = 0;
if (tableCount > 0) {
long t3 = System.currentTimeMillis();
writeTable(builder, tableCount, rowCount, columnCount);
t2 = System.currentTimeMillis();

System.out.println(“Table (model) Generation time: " + (t2 - t3)
/ 1000 + " seconds.”);
} else
t2 = System.currentTimeMillis();

System.out.println(“Model Generation time: " + (t2 - t1) / 1000
+ " seconds.”);

save(doc, baseFolder, extn);

}

private void save(Document doc, String baseFolder, String extn)
throws Exception {
String unique = UUID.randomUUID().toString().replaceAll(” “, “");
String docpath = null;

long t1 = 0;
long t2 = 0;
if (“all”.equals(extn) || “doc”.equals(extn)) {
t1 = System.currentTimeMillis();
docpath = baseFolder + "test
” + unique + “.doc”;
// System.out.println(”>>> Writing " + docpath + " …”);
doc.save(docpath);
t2 = System.currentTimeMillis();
System.out.println(“Word doc Save time: " + (t2 - t1) / 1000
+ " seconds.”);
}
if (“all”.equals(extn) || “pdf”.equals(extn)) {
docpath = baseFolder + “test_” + unique + “.pdf”;
// System.out.println(">>> Writing " + docpath + " …");
t1 = System.currentTimeMillis();
doc.save(docpath);
t2 = System.currentTimeMillis();
System.out.println(“PDF doc Save time: " + (t2 - t1) / 1000
+ " seconds.”);
}
}

private void writeParagraph(DocumentBuilder builder, int numOfParagraphs,
boolean withImages) throws Exception {
builder.getParagraphFormat().setStyleIdentifier(StyleIdentifier.TITLE);
builder.writeln(“Test Scalability”);

builder.getParagraphFormat().setStyleIdentifier(StyleIdentifier.NORMAL);
builder.insertParagraph();

builder.insertTableOfContents("\o “1-3” \h \z \u");
builder.insertParagraph();

int imageCount = 0;

for (int i = 0; i < numOfParagraphs; ++i) {
if (i % 200 == 0) {
// System.out.println(“Written " + i + " records …”);

builder.getParagraphFormat().setStyleIdentifier(
StyleIdentifier.HEADING_1);
builder.writeln("Heading " + i);
} else {
builder.getParagraphFormat().setStyleIdentifier(
StyleIdentifier.NORMAL);
builder.writeln("Paragraph " + i);

}

builder.getParagraphFormat().setStyleIdentifier(
StyleIdentifier.NORMAL);
builder.writeln(LONG_TEXT);

if (withImages && (i % 50 == 0)) {
String imagePath = this.getClass().getResource(“jazz.jpg”)
.toExternalForm();
Shape shape = builder.insertImage(imagePath);
shape.setBounds(IMAGE_BOUNDS);
builder.insertParagraph();
++imageCount;

imagePath = this.getClass().getResource(“rose.png”)
.toExternalForm();
shape = builder.insertImage(imagePath);
shape.setBounds(IMAGE_BOUNDS);
builder.insertParagraph();
++imageCount;
}

builder.getParagraphFormat().setStyleIdentifier(
StyleIdentifier.NORMAL);
builder.writeln(LONG_TEXT);

builder.insertParagraph();
}

// System.out.println("Image count: " + imageCount);
}

private void writeTable(DocumentBuilder builder, int tableCount,
int rowCount, int columnCount) throws Exception {
builder.writeln();

for (int i = 0; i < tableCount; i++) {
// System.out.println("Writing table " + (i + 1)
// + "with number of rows " + rowCount
// + " and column count is " + columnCount);
builder.writeln("Writing table " + (i + 1) + "with number of rows "
+ rowCount + " and column count is " + columnCount);
builder.writeln();
Table table = builder.startTable();

for (int j = 0; j < rowCount; j++) {

for (int k = 0; k < columnCount; k++) {
// Insert a cell
builder.insertCell();
// Use fixed column widths.
table.autoFit(AutoFitBehavior.FIXED_COLUMN_WIDTHS);

builder.getCellFormat().setVerticalAlignment(
CellVerticalAlignment.CENTER);
builder.write(TEXT_FOR_TABLE_CELL + "This is table "
+ (i + 1) + " row " + (j + 1) + " cell " + (k + 1));
}

builder.endRow();
}
builder.endTable();
builder.insertBreak(1);
}

}

@Test
public void testScalability() throws Exception {
setupLicense();
printAsposeVersion();
System.out.println();

printHeapUtilizationStats(“Before”);
System.out.println();

long t1 = System.currentTimeMillis();
int numOfParagraph = 6000;
int numOfTables = 30;
int numOfRows = 30;
int numOfColumns = 6;

System.out.println("Number of Paragraphs: " + numOfParagraph);
System.out.println("Number of Tables: " + numOfTables);
System.out.println(“Number of Rows: " + numOfRows);
System.out.println(“Number of Colums: " + numOfColumns);

System.out.println();
// To save only pdf, the last parameter (extn) should be “pdf”
// for word=“doc” and to generate both, “all”
writeDocument(numOfParagraph, true,
System.getProperty(“java.io.tmpdir”), numOfTables, numOfRows,
numOfColumns, “pdf”);
long t2 = System.currentTimeMillis();
System.out
.println(“Complete Document generation time (excluding license): "
+ (t2 - t1) / 1000 + " seconds.”);
System.out.println();
printHeapUtilizationStats(“After”);
System.out.println();
System.out.println(“RPE Document used memory (approx) "
+ (USED_MEMORY_AFTER - USED_MEMORY_BEFORE) + " MB.”);
System.out.println();

System.out
.println(”#################### END ##########################”);
System.out.println();
}

private void printAsposeVersion() {
System.out.println(“Aspose product and version is: "
+ BuildVersionInfo.getProduct() + " : "
+ BuildVersionInfo.getVersion());
}

private void printHeapUtilizationStats(String message) {
int mb = 1024 * 1024;

// Getting the runtime reference from system
Runtime runtime = Runtime.getRuntime();
System.out.println(”##### " + message
+ “: Heap utilization statistics [MB] #####”);

// Print used memory
System.out.println(“Used Memory:”
+ (runtime.totalMemory() - runtime.freeMemory()) / mb);
if (“Before”.equals(message))
USED_MEMORY_BEFORE = (runtime.totalMemory() - runtime.freeMemory())
/ mb;
else
USED_MEMORY_AFTER = (runtime.totalMemory() - runtime.freeMemory())
/ mb;

// Print free memory
System.out.println(“Free Memory:” + runtime.freeMemory() / mb);

// Print total available memory
System.out.println(“Total Memory:” + runtime.totalMemory() / mb);

// Print Maximum available memory
System.out.println(“Max Memory:” + runtime.maxMemory() / mb);
}
}

Hi Kumar,

Thanks for the additional information. I have tested the scenario and have managed to reproduce the same problem on my side. For the sake of correction, I have logged this problem as WORDSJAVA-669 in our issue tracking system. We will further look into the details of this problem and will keep you updated on the status of correction. We apologize for your inconvenience.

Best regards,

Thanks Awais. When would the fix for this be available? It’s urgent since we’re planning to upgrade to version 11.11 asap.

Hi Kumar,


Thanks for your inquiry. Unfortunately, this issue is not resolved yet. Currently, this issue is pending for analysis and is in the queue. Unfortunately, at the moment I cannot provide you any reliable estimate. You will be notified as soon as it is resolved. Sorry for the inconvenience.

Best regards,

Hi Awais,

Any update on this?

Thanks,
Kumar

Hi Kumar,


Thanks for your inquiry.Yes, we have a good news for you that is WORDSJAVA-669 has now been resolved and its fix will be included in the next version of Aspose.Words (13.4.0) which is due out in next couple of days. We will inform you via this forum thread as soon as the new release of Aspose.Words is published.

Best regards,

Hi Awais,

I don’t see Aspose.Words.For.Java 13.4 yet. When will it be available for download?

Thanks,
Kumar

Hi Kumar,


Thanks for your patience. It is unfortunate that the new version of Aspose.Words is not yet released. Please expect the new release of Aspose.Words will come out within next 24 hours. We apologize for any inconvenience.

Best regards,

Thanks Awais. Aspose.Words for Java v 13.4 is available now.

The issues you have found earlier (filed as WORDSJAVA-669) have been fixed in this .NET update and this Java update.


This message was posted using Notification2Forum from Downloads module by aspose.notifier.

The issues you have found earlier (filed as ) have been fixed in this update. This message was posted using BugNotificationTool from Downloads module by MuzammilKhan