TimeManyDocs.cs
C# VB
//// This code is part of Document Solutions for Word demos.// Copyright (c) MESCIUS inc. All rights reserved.//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; } }}