-
Notifications
You must be signed in to change notification settings - Fork 35
/
Program.cs
56 lines (47 loc) · 1.41 KB
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Engines;
using BenchmarkDotNet.Jobs;
using BenchmarkDotNet.Running;
using GemBox.Document;
using System.Collections.Generic;
using System.IO;
[SimpleJob(RuntimeMoniker.Net80)]
[SimpleJob(RuntimeMoniker.Net48)]
public class Program
{
private DocumentModel document;
private readonly Consumer consumer = new Consumer();
public static void Main()
{
BenchmarkRunner.Run<Program>();
}
[GlobalSetup]
public void SetLicense()
{
// If using the Professional version, put your serial key below.
ComponentInfo.SetLicense("FREE-LIMITED-KEY");
// If using Free version and example exceeds its limitations, use Trial or Time Limited version:
// https://www.gemboxsoftware.com/document/examples/free-trial-professional/1301
this.document = DocumentModel.Load("RandomSections.docx");
}
[Benchmark]
public DocumentModel Reading()
{
return DocumentModel.Load("RandomSections.docx");
}
[Benchmark]
public void Writing()
{
using (var stream = new MemoryStream())
this.document.Save(stream, new DocxSaveOptions());
}
[Benchmark]
public void Iterating()
{
this.LoopThroughAllElements().Consume(this.consumer);
}
public IEnumerable<Element> LoopThroughAllElements()
{
return this.document.GetChildElements(true);
}
}