You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
Updating a word document operation has degraded significantly in the latest version. In v2.5.0, updating a word document (SampleDocument.docx) takes on an average ~310ms but same operation takes around ~1610ms (5x) in v2.20.0 and ~1370ms (4x) in v3.1.0.
To Reproduce
Use below sample code with attached document (SampleDocument.docx)
string filePath = @"SampleDocument.docx";
string outPath = $@"UpdatedSampleDocument.docx";
Stopwatch stopwatch = new Stopwatch();
var bytes = File.ReadAllBytes(filePath);
MemoryStream stream = new MemoryStream();
stream.Position = 0;
stream.Write(bytes, 0, bytes.Length);
stopwatch.Start();
// Open the document
using (WordprocessingDocument wordDocument = WordprocessingDocument.Open(stream, true))
{
wordDocument.MainDocumentPart.Document.Body.PrependChild(new Paragraph(new ParagraphProperties(), new Run(new Text(DateTime.Now.ToString()))));
wordDocument.MainDocumentPart.Document.Body.PrependChild(new Paragraph(new ParagraphProperties(), new Run(new Text(DateTime.Now.ToString()))));
wordDocument.MainDocumentPart.Document.Body.PrependChild(new Paragraph(new ParagraphProperties(), new Run(new Text(DateTime.Now.ToString()))));
wordDocument.MainDocumentPart.Document.Body.PrependChild(new Paragraph(new ParagraphProperties(), new Run(new Text(DateTime.Now.ToString()))));
wordDocument.MainDocumentPart.Document.Body.PrependChild(new Paragraph(new ParagraphProperties(), new Run(new Text(DateTime.Now.ToString()))));
//// Save the document
//// for v2.20.0
wordDocument.MainDocumentPart.Document.Save();
wordDocument.Package.Flush();
//// for v3.1.0 & v2.20.0
wordDocument.Save();
}
stopwatch.Stop();
File.WriteAllBytes(outPath, stream.ToArray());
stream.Close();
stream.Dispose();
Console.WriteLine($"Time taken to save the document: {stopwatch.ElapsedMilliseconds} ms");
Observed behavior
Upgrading to the latest version has significant performance degradation for mentioned operation.
Expected behavior
Upgrading to the latest version should not degrade performance.
Desktop (please complete the following information):
I took a look with a profiler, and it appears that a large amount of the time is spent with JIT here, probably due to the generic builder pattern I put in 2.11. The perf testing I had done had always warmed things up and removed the JIT stage, but in a single one off, it's quite a large impact. I'm going to explore removing it.... it causes other issues such as #753
Describe the bug
Updating a word document operation has degraded significantly in the latest version. In v2.5.0, updating a word document (SampleDocument.docx) takes on an average ~310ms but same operation takes around ~1610ms (5x) in v2.20.0 and ~1370ms (4x) in v3.1.0.
To Reproduce
Use below sample code with attached document (SampleDocument.docx)
Observed behavior
Upgrading to the latest version has significant performance degradation for mentioned operation.
Expected behavior
Upgrading to the latest version should not degrade performance.
Desktop (please complete the following information):
The text was updated successfully, but these errors were encountered: