Performance metrics with large Word files in C# and VB.NET

GemBox.Document is a Word component that follows .NET design guidelines and best practices. It represents Word files in-memory through its rich content model that contains sections, blocks, inlines, drawings, etc. It has optimized memory consumption, allocation, while not jeopardizing the efficiency and speed of the execution.

You can create stress tests to measure the component's processing capabilities using BenchmarkDotNet.

The following example shows how you can track the performance of GemBox.Document using the provided input Word file with 15 sections of various content. The file should cover any typical Word requirements; it includes different kinds of elements (like images, shapes, and tables) and Word features (like bookmarks, comments, and footnotes).

Measuring performance of reading, writing, and iterating through Word files in C# and VB.NET
Screenshot of GemBox.Document performance measurements
using System;
using System.Collections.Generic;
using System.IO;
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Engines;
using BenchmarkDotNet.Jobs;
using BenchmarkDotNet.Running;
using GemBox.Document;

public class Program
    private DocumentModel document;
    private readonly Consumer consumer = new Consumer();

    public static void Main()

    public void SetLicense()
        // If using Professional version, put your serial key below.

        // If using Free version and example exceeds its limitations, use Trial or Time Limited version:

        this.document = DocumentModel.Load("%#RandomSections.docx%");

    public DocumentModel Reading()
        return DocumentModel.Load("%#RandomSections.docx%");

    public void Writing()
        using (var stream = new MemoryStream())
            this.document.Save(stream, new DocxSaveOptions());

    public void Iterating()

    public IEnumerable<Element> LoopThroughAllElements()
        return this.document.GetChildElements(true);
Imports System
Imports System.Collections.Generic
Imports System.IO
Imports BenchmarkDotNet.Attributes
Imports BenchmarkDotNet.Engines
Imports BenchmarkDotNet.Jobs
Imports BenchmarkDotNet.Running
Imports GemBox.Document

Public Class Program

    Private document As DocumentModel
    Private ReadOnly consumer As Consumer = New Consumer()

    Public Shared Sub Main()
        BenchmarkRunner.Run(Of Program)()
    End Sub

    Public Sub SetLicense()
        ' If using Professional version, put your serial key below.

        ' If using Free version and example exceeds its limitations, use Trial or Time Limited version:

        Me.document = DocumentModel.Load("%#RandomSections.docx%")
    End Sub

    Public Function Reading() As DocumentModel
        Return DocumentModel.Load("%#RandomSections.docx%")
    End Function

    Public Sub Writing()
        Using stream = New MemoryStream()
            Me.document.Save(stream, New DocxSaveOptions())
        End Using
    End Sub

    Public Sub Iterating()
    End Sub

    Public Function LoopThroughAllElements() As IEnumerable(Of Element)
        Return Me.document.GetChildElements(True)
    End Function

End Class

Benchmarks for 10,000 Word pages

The more content you have, the more memory you'll need. The amount of content you can handle depends on a few factors, like the machine's available memory, the application's architecture (32-bit or 64-bit), the targeted .NET platform (.NET Framework or .NET Core), etc.

The following benchmark charts provide the results of working with Word files with up to 10 thousand pages. They show a steady and linear increase in both time and memory with an increased number of pages. For more information, see the resulting performance measurements in the 10_Thousand_Pages_Performance.xlsx file.

Benchmark chart of time that's required for reading and writing Word files with up to 10 thousand pages
Benchmark chart of elapsed time for 10 thousand pages
Benchmark chart of memory that's required for creating Word files with up to 10 thousand pages
Benchmark chart of allocated memory for 10 thousand pages

Tips for improving performance

The following are some recommendations for improving performance while developing with GemBox.Document:

See also

Next steps

GemBox.Document is a .NET component that enables you to read, write, edit, convert, and print document files from your .NET applications using one simple API. How about testing it today?

Download Buy