forked from DevExpress/XPO
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPerformanceTestSet.cs
167 lines (141 loc) · 4.81 KB
/
PerformanceTestSet.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
using System.Collections.Generic;
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Exporters;
namespace ORMBenchmark.PerformanceTests {
public class PerformanceTestSet {
[ParamsSource(nameof(RowCounts))]
public int RowCount;
[ParamsSource(nameof(TestProviders))]
public TestProviderBase TestProvider;
public IEnumerable<int> RowCounts() {
return TestSetConfig.RowCounts;
}
public IEnumerable<TestProviderBase> TestProviders() {
yield return new XPOPerfTestProvider();
yield return new EF6TestProvider();
yield return new EFCoreTestProvider();
yield return new DirectSQLTestProvider();
}
[IterationSetup(Target = nameof(InsertMany) + "," + nameof(InsertOne))]
public void IterationSetupForInsert() {
TestProvider.CleanupTestDataSet();
TestProvider.InitSession();
}
[IterationSetup(Target = nameof(DeleteMany) + "," + nameof(DeleteOne))]
public void IterationSetupForDelete() {
TestProvider.CreateTestDataSet(RowCount);
TestProvider.InitSession();
System.GC.Collect();
}
[IterationSetup(Target = nameof(UpdateMany)
+ "," + nameof(UpdateOne)
+ "," + nameof(Fetch)
+ "," + nameof(LinqQuery)
+ "," + nameof(InstantiationLinq)
+ "," + nameof(InstantiationNative)
+ "," + nameof(LinqTakeRecords10)
+ "," + nameof(LinqTakeRecords20)
+ "," + nameof(LinqTakeRecords50)
+ "," + nameof(LinqTakeRecords100)
+ "," + nameof(ProjectionLinq)
)]
public void IterationSetupForUpdateAndSelect() {
TestProvider.InitSession();
System.GC.Collect();
}
[GlobalSetup(Target = nameof(UpdateMany)
+"," + nameof(UpdateOne)
+ "," + nameof(Fetch)
+ "," + nameof(LinqQuery)
+ "," + nameof(InstantiationLinq)
+ "," + nameof(InstantiationNative)
+ "," + nameof(LinqTakeRecords10)
+ "," + nameof(LinqTakeRecords20)
+ "," + nameof(LinqTakeRecords50)
+ "," + nameof(LinqTakeRecords100)
+ "," + nameof(ProjectionLinq)
)]
public void GlobalSetupForUpdateAndSelect() {
TestProvider.CreateTestDataSet(RowCount);
System.GC.Collect();
}
[IterationCleanup]
public void IterationCleanup() {
TestProvider.TearDownSession();
}
[Benchmark]
public void InsertOne() {
TestProvider.InsertOne(RowCount);
}
[Benchmark]
public void InsertMany() {
TestProvider.InsertMany(RowCount);
}
[Benchmark]
public void UpdateOne() {
TestProvider.UpdateOne();
}
[Benchmark]
public void UpdateMany() {
TestProvider.UpdateMany();
}
[Benchmark]
public void DeleteOne() {
TestProvider.DeleteOne();
}
[Benchmark]
public void DeleteMany() {
TestProvider.DeleteMany();
}
[Benchmark]
public void Fetch() {
TestProvider.Fetch();
}
[Benchmark]
public void LinqQuery() {
TestProvider.LinqQuery();
}
[Benchmark(OperationsPerInvoke = 1000)]
public void InstantiationNative() {
for(int i = 0; i < 1000; i++) {
TestProvider.InstantiationNative();
}
}
[Benchmark(OperationsPerInvoke = 1000)]
public void InstantiationLinq() {
for(int i = 0; i < 1000; i++) {
TestProvider.InstantiationLinq();
}
}
[Benchmark(OperationsPerInvoke = 10)]
public void LinqTakeRecords10() {
for(int i = 0; i < 10; i++) {
TestProvider.LinqTakeRecords10();
}
}
[Benchmark(OperationsPerInvoke = 50)]
public void LinqTakeRecords20() {
for(int i = 0; i < 50; i++) {
TestProvider.LinqTakeRecords20();
}
}
[Benchmark(OperationsPerInvoke = 100)]
public void LinqTakeRecords50() {
for(int i = 0; i < 100; i++) {
TestProvider.LinqTakeRecords50();
}
}
[Benchmark(OperationsPerInvoke = 100)]
public void LinqTakeRecords100() {
for(int i = 0; i < 100; i++) {
TestProvider.LinqTakeRecords100();
}
}
[Benchmark(OperationsPerInvoke = 1000)]
public void ProjectionLinq() {
for(int i = 0; i < 1000; i++) {
TestProvider.ProjectionLinq();
}
}
}
}