Hi,
I have noticed a decrease in performance from version 18.2 to 18.3 using method Range.replace(String, String, FindReplaceOptions).
The performance issue is still contained in version 18.8.
The performance issue is probably caused by ticket WORDSNET-14725.
This performance issue occurs when a content control contains CustomXml.
I have investigated the performance issue on two different documents. The first document contains a content control with CustomXml. The second document contains a content control without CustomXml.
There are always two identical paragraphs, because I have noticed a difference in performance between the first and second method call.
Test setup:
replace.zip (51.6 KB)
doc = new Document("replace_<option>.docx");
Range range1 = doc.getFirstSection().getBody().getChild(NodeType.PARAGRAPH, 0, true).getRange();
Range range2 = doc.getFirstSection().getBody().getChild(NodeType.PARAGRAPH, 1, true).getRange();
long timeFirstLineStart = System.nanoTime();
range1.replace("test", "test2", new FindReplaceOptions());
long timeFirstLineEnd = System.nanoTime();
System.err.println("Time to replace first line: " + (timeFirstLineEnd - timeFirstLineStart) + " nanoseconds");
long timeSecondLineStart = System.nanoTime();
range2.replace("test", "test2", new FindReplaceOptions());
long timeSecondLineEnd = System.nanoTime();
System.err.println("Time to replace second line: " + (timeSecondLineEnd - timeSecondLineStart) + " nanoseconds");
My test results:
document with CustomXml
first paragraph
version 18.2 = ~6ms
version 18.3 = ~90ms
second paragraph
version 18.2 = ~0,6ms
version 18.3 = ~2ms
document without CustomXml
first paragraph
version 18.2 = ~6ms
version 18.3 = ~6ms
second paragraph
version 18.2 = ~0,6ms
version 18.3 = ~0,6ms
If the content control contains CustomXml, the performance with version 18.3 is significantly slower.
Why has performance decreased so much between the versions?
Regards
Ingo Gutzeit