My favorites | Sign in
Project Home Downloads Issues Source
Repository:
Checkout   Browse   Changes   Clones    
 
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
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
// Copyright (C) 2009-2010 ORMBattle.NET.
// All rights reserved.
// For conditions of distribution and use, see license.
// Created by: Alexis Kochetov
// Created: 2009.07.31

using System;
using System.Diagnostics;
using System.Linq;
using System.Transactions;
using NUnit.Framework;
using Telerik.OpenAccess;
using Telerik.OpenAccess.Query;
using OrmBattle.TelerikModel.PerformanceTest;

namespace OrmBattle.Tests.Performance
{
[Serializable]
public class OpenAccessTest : PerformanceTestBase
{
private PerformanceTest context;

public override string ToolName {
get { return "OpenAccess"; }
}

public override string ShortToolName {
get { return "OA"; }
}

protected override void Setup()
{
var db = new PerformanceTest();
using (var ts = new TransactionScope()) {
db.Delete(db.Simplests);
db.SaveChanges();
ts.Complete();
}
}

protected override void TearDown()
{
var db = new PerformanceTest();
using (var ts = new TransactionScope()) {
db.Delete(db.Simplests);
db.SaveChanges();
ts.Complete();
}
}

[Test]
public void SomeTest()
{
Execute();
}

protected override void OpenSession()
{
context = new PerformanceTest();
}

protected override void CloseSession()
{
context.Dispose();
}

protected override void InsertMultipleTest(int count)
{
using (var ts = new TransactionScope()) {
for (int i = 0; i < count; i++) {
var s = new Simplest {Id = i, Value = i};
context.Add(s);
}
context.SaveChanges();
ts.Complete();
}
InstanceCount = count;
}

protected override void UpdateMultipleTest()
{
using (var ts = new TransactionScope()) {
var query = context.Simplests;
foreach (var o in query)
o.Value++;
context.SaveChanges();
ts.Complete();
}
}

protected override void DeleteMultipleTest()
{
using (var ts = new TransactionScope()) {
var query = context.Simplests;
foreach (var s in query)
context.Delete(s);
context.SaveChanges();
ts.Complete();
}
}

protected override void InsertSingleTest(int count)
{
for (int i = 0; i < count; i++) {
var s = new Simplest {Id = i, Value = i};
context.Add(s);
context.SaveChanges();
}
InstanceCount = count;
}

protected override void UpdateSingleTest()
{
var query = context.Simplests;
foreach (var o in query) {
o.Value++;
context.SaveChanges();
}
}

protected override void DeleteSingleTest()
{
var query = context.Simplests;
foreach (var s in query) {
context.Delete(s);
context.SaveChanges();
}
}

protected override void FetchTest(int count)
{
long sum = (long)count * (count - 1) / 2;
var scope = context.GetScope();
var classId = scope.PersistentMetaData.GetPersistentTypeDescriptor(typeof(Simplest)).ClassId;
using (var ts = new TransactionScope()) {
for (int i = 0; i < count; i++) {
var id = (long) i%InstanceCount;
var objectId = Database.OID.ParseObjectId(null, classId + "-" + id);
var s = (Simplest) scope.GetObjectById(objectId);
sum -= s.Id;
}
ts.Complete();
}
if (count <= InstanceCount)
Assert.AreEqual(0, sum);
}

protected override void LinqQueryTest(int count)
{
using (var ts = new TransactionScope()) {
for (int i = 0; i < count; i++) {
var id = i%InstanceCount;
var query = context.Simplests.Where(o => o.Id == id);
foreach (var simplest in query) {
// Doing nothing, just enumerate
}
}
ts.Complete();
}
}

protected override void CompiledLinqQueryTest(int count)
{
using (var ts = new TransactionScope()) {
for (int i = 0; i < count; i++) {
var id = i%InstanceCount;
var query = GetSimplest(context, id);
foreach (var simplest in query) {
// Doing nothing, just enumerate
}
}
ts.Complete();
}
}

protected override void NativeQueryTest(int count)
{
using (var ts = new TransactionScope()) {
for (int i = 0; i < count; i++) {
var id = i%InstanceCount;
var query = context.GetScope().GetOqlQuery<Simplest>("select * from SimplestExtent AS s where s.Id == $1");
foreach (var simplest in query.ExecuteEnumerable(id)) {
// Doing nothing, just enumerate
}
}
ts.Complete();
}
}

protected override void LinqMaterializeTest(int count)
{
using (var ts = new TransactionScope()) {
int i = 0;
while (i < count)
foreach (var o in GetAllSimplest(context))
if (++i >= count)
break;
ts.Complete();
}
}

protected override void NativeMaterializeTest(int count)
{
using (var ts = new TransactionScope()) {
var scope = context.GetScope();
int i = 0;
while (i < count)
foreach (var o in scope.GetOqlQuery<Simplest>().ExecuteEnumerable())
if (++i >= count)
break;
ts.Complete();
}
}

protected override void LinqQueryPageTest(int count, int pageSize)
{
using (var ts = new TransactionScope()) {
for (int i = 0; i < count; i++) {
var id = (i*pageSize)%InstanceCount;
var query = GetSimplestPage(context, id, pageSize);
foreach (var simplest in query) {
// Doing nothing, just enumerate
}
}
ts.Complete();
}
}

static IQueryable GetSimplest(PerformanceTest context, long id)
{
var query =
from e in context.Simplests
where e.Id == id
select e;
return query;
}

static IQueryable GetSimplestPage(PerformanceTest context, long idFrom, int pageSize)
{
var query =
from e in context.Simplests
where e.Id >= idFrom
select e;
return query.Take(pageSize);
}

static IQueryable GetAllSimplest(PerformanceTest context)
{
return context.Simplests.Where(s => s.Id > 0);
}
}
}

Change log

871813742969 by Alexis Kochetov on Mar 11, 2011   Diff
- Products are updated to latest versions
Go to: 

Older revisions

f74dc303ceb9 by Alexis Kochetov on Mar 10, 2011   Diff
- Products are updated to latest
versions
c6412f95a8d3 by Alex Yakunin on Jun 10, 2010   Diff
Project is upgraded to .NET 4.0.
7b91c0a5353e by alex.yakunin on Aug 31, 2009   Diff
- Open Access -> OpenAccess
- Copyright (C) Xtensive LLC ->
Copyright (C) ORMBattle.NET
- Minor fixes.
All revisions of this file

File info

Size: 6742 bytes, 252 lines
Powered by Google Project Hosting