-
-
Notifications
You must be signed in to change notification settings - Fork 496
Expand file tree
/
Copy pathLabBenchmarks.cs
More file actions
74 lines (65 loc) · 2 KB
/
Copy pathLabBenchmarks.cs
File metadata and controls
74 lines (65 loc) · 2 KB
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Exporters;
using BenchmarkDotNet.Jobs;
using Magicodes.Benchmarks.Models;
using Magicodes.ExporterAndImporter.Excel;
using Magicodes.ExporterAndImporter.Excel.Utility;
using Magicodes.IE.IO;
using MiniExcelLibs;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Magicodes.Benchmarks
{
[MemoryDiagnoser]
[SimpleJob(launchCount: 1, warmupCount: 1, invocationCount: 5, runtimeMoniker: RuntimeMoniker.Net80)]
public class LabBenchmarks
{
[Params(100, 500, 1000, 2000, 3000, 5000, 10000, 100000)]
public int RowsCount;
private readonly List<ExportTestDataWithAttrs> _exportTestData = new List<ExportTestDataWithAttrs>();
private readonly IExporter _exporter;
public LabBenchmarks()
{
}
[GlobalSetup]
public void GlobalSetup()
{
for (var i = 1; i <= RowsCount; i++)
{
_exportTestData.Add(new ExportTestDataWithAttrs
{
Age = i,
Name = "Mr.A",
Text3 = "Text3"
});
}
}
[GlobalCleanup]
public void GlobalCleanup()
{
_exportTestData.Clear();
}
[Benchmark]
public async Task ExportExcelAsByteArrayAsyncTest()
{
var helper = new ExportHelper<ExportTestDataWithAttrs>();
using (helper.CurrentExcelPackage)
{
//helper.AddExcelWorksheet();
helper.Export(_exportTestData);
await helper.CurrentExcelPackage.GetAsByteArrayAsync();
}
}
[Benchmark]
public async Task ExportMioAsyncTest()
{
var memoryStream = new MemoryStream();
Xlsx.Write(memoryStream, _exportTestData);
memoryStream.Seek(0, SeekOrigin.Begin);
}
}
}