Performance of updateFields

Hi,

I have noticed that updating fields is very slow.
Using updateFields() at an empty document only containing one page field takes nearly 700ms, testet with Aspose.Words 18.7. With Aspose.Words 17.12 it was still about 500ms - also feels very slowly.

Document doc = new Document("...\\test.docx");
long startTime = System.currentTimeMillis();
doc.updateFields();
long resultTime = System.currentTimeMillis() - startTime;

test.zip (13.1 KB)

This is a very simple example. I have other cases where updating 14 fields in 7 pages takes over 3 seconds.

Why is updateFields() so slow? Is there anything I can do? Modify the document or use other methods to update fields?
Why has performance decreased so much in the last versions?

Regards
Ingo Gutzeit

@gutzeit,

Thanks for your inquiry. If your document has PAGE or NUMPAGES fields and you call UpdateFields, in this case UpdateFields method will internally call UpdatePageLayout method. And Document.UpdatePageLayout method rebuilds the page layout of the document.

P.S. Generally, Aspose.Words layouts 10 pages per second; so, the extra amount of time Aspose.Words takes to format a document into pages depends on the number of pages your Word document has. Also, the process of building layout model is not linear; it may take a minute to render one page and may take a few seconds to render 100 pages (depending on the complexity).

Thanks for your feedback.
I understand the procedure, but to me 700ms for an empty document still seems quite long.
And how do you explain the performance loss from version 17.12 to 18.7?

Regards
Ingo Gutzeit

@gutzeit,

For the sake of any correction, we have logged this problem in our issue tracking system. The ID of this issue is WORDSNET-17315. We will further look into the details of this problem and will keep you updated on the status of this issue. We apologize for any inconvenience.