TimeManyDocs.cs
//
// This code is part of GrapeCity Documents for Word samples.
// Copyright (c) GrapeCity, Inc. All rights reserved.
//
using System;
using System.IO;
using System.Drawing;
using System.Collections.Generic;
using System.Linq;
using GrapeCity.Documents.Word;

namespace GcWordWeb.Samples
{
    // This sample creates a 100 instances of GcWordDocument
    // and prints the time that it took.
    public class TimeManyDocs
    {
        public GcWordDocument CreateDocx()
        {
            const int N = 100;

            // The document to show the resulting time:
            GcWordDocument doc = new GcWordDocument();
            // Starting time:
            var start = DateTime.Now;
            for (int i = 0; i < N; ++i)
                new GcWordDocument();
            // Delta:
            var delta = DateTime.Now - start;
            // Print out the result:
            var message = $"Time used to create {N} instances of GcWordDocument: {delta}.";
            doc.Body.Sections.First.GetRange().Paragraphs.Add(message);
            // Done:
            return doc;
        }
    }
}