TimeManyDocs.cs
//
// This code is part of Document Solutions for Word demos.
// Copyright (c) MESCIUS inc. All rights reserved.
//
using System;
using System.IO;
using System.Drawing;
using System.Collections.Generic;
using System.Linq;
using GrapeCity.Documents.Word;

namespace DsWordWeb.Demos
{
    // 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 = Util.TimeNow();
            for (int i = 0; i < N; ++i)
                new GcWordDocument();
            // Delta:
            var delta = Util.TimeNow() - 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;
        }
    }
}