We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

MailMerge performance

Hallo Roman!



There ist still some slight performance issue in MailMerge. It is not
easy reproduced, but i have some test code to show it to you.

I have also a workaound. The template is attached.



Here ist the code (i use log4net for logging statements):


log.Debug("Bookmark Count = " +

doc.Range.Bookmarks.Count);

int i = 0;

foreach (Aspose.Word.Bookmark bookmark in

doc.Range.Bookmarks)

{

if ((i / 10) % 2 == 0)

{

        bookmark.Text

= string.Empty;

}

i++;

}

log.Debug(“MailMerge Start”);

doc.MailMerge.Execute(new string[] {}, new object[]

{});

log.Debug(“MailMerge Stop”);



And here is the output:



2005-11-24 15:32:27,012 [2000] DEBUG Tests.Class1 - Bookmark Count = 486

2005-11-24 15:32:27,343 [2000] DEBUG Tests.Class1 - MailMerge Start

2005-11-24 15:32:29,206 [2000] DEBUG Tests.Class1 - MailMerge Stop



Now you see, that there are almost 2 seconds between MailMerge Start
and MailMerge Stop. In production with real data MailMerge needs even 4
seconds.



And now here the source code with a workaround - i simply reload the document using a memory stream before i do MailMerge:


log.Debug("Bookmark Count = " +

doc.Range.Bookmarks.Count);

int i = 0;

foreach (Aspose.Word.Bookmark bookmark in

doc.Range.Bookmarks)

{

if ((i / 10) % 2 == 0)

{

        bookmark.Text

= string.Empty;

}

i++;

}

log.Debug(“Bookmarks processed”);

using (MemoryStream ms = new MemoryStream())

{

doc.Save(ms,SaveFormat.FormatDocument);

ms.Position = 0;

doc = new Document(ms);

}

log.Debug(“MailMerge Start”);

doc.MailMerge.Execute(new string[] {}, new object[]

{});

log.Debug(“MailMerge Stop”);



Here os the output:



2005-11-24 15:36:36,361 [2396] DEBUG Tests.Class1 - Bookmark Count = 486

2005-11-24 15:36:36,691 [2396] DEBUG Tests.Class1 - Bookmarks processed

2005-11-24 15:36:37,192 [2396] DEBUG Tests.Class1 - MailMerge Start

2005-11-24 15:36:37,232 [2396] DEBUG Tests.Class1 - MailMerge Stop



Now you see the MailMerge ist much faster.



I hope this helps.



Cheers



Robert

i also found, that whe deleting bookmarks, the performance degrades…
this could be the same issue wich also has impact on MailMerge.



sample code:


log.Debug("Bookmark Count = " +

doc.Range.Bookmarks.Count);

i = 0;

foreach (Aspose.Word.Bookmark bookmark in

doc.Range.Bookmarks)

{

bookmark.Text = string.Empty;

if (i % 50 == 0)

{

log.Debug(“Deleting Bookmark”);

}

i++;

}

log.Debug(“Bookmarks processed”);



output:



2005-11-24 16:16:56,511 [2576] DEBUG Tests.Class1 - Bookmark Count = 486

2005-11-24 16:16:56,511 [2576] DEBUG Tests.Class1 - Deleting Bookmark

2005-11-24 16:16:56,511 [2576] DEBUG Tests.Class1 - Deleting Bookmark

2005-11-24 16:16:56,531 [2576] DEBUG Tests.Class1 - Deleting Bookmark

2005-11-24 16:16:56,551 [2576] DEBUG Tests.Class1 - Deleting Bookmark

2005-11-24 16:16:56,591 [2576] DEBUG Tests.Class1 - Deleting Bookmark

2005-11-24 16:16:56,801 [2576] DEBUG Tests.Class1 - Deleting Bookmark

2005-11-24 16:16:57,182 [2576] DEBUG Tests.Class1 - Deleting Bookmark

2005-11-24 16:16:57,492 [2576] DEBUG Tests.Class1 - Deleting Bookmark

2005-11-24 16:16:58,093 [2576] DEBUG Tests.Class1 - Deleting Bookmark

2005-11-24 16:16:58,984 [2576] DEBUG Tests.Class1 - Deleting Bookmark

2005-11-24 16:16:59,816 [2576] DEBUG Tests.Class1 - Bookmarks processed



You see that in the beginnig the bookmark.Text = string.Empty;
statement is pretty fast, but then the performance goes rapidly down.

Hope this helps too :slight_smile:



Cheers



Robert

Thanks for your extensive research. I will certainly look at this over the next week or so.

Hi Roman!



Any news regarding this issue?



Thank you.



Robert

I need another week. Sorry for the delay.

I've made a good performance improvement for this scenario. Will be released in Aspose.Word 3.3.5.

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


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