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
// Copyright (C) 2009-2010 ORMBattle.NET.
// All rights reserved.
// For conditions of distribution and use, see license.
// Created by: Alexis Kochetov
// Created: 2009.08.01

using System;
using System.Linq;
using System.Reflection;
using NUnit.Framework;
using SubSonic.DataProviders;
using OrmBattle.SubsonicModel.PerformanceTest;
using SubSonic.Query;

namespace OrmBattle.Tests.Performance
{
[Serializable]
public class SubsonicTest : PerformanceTestBase
{
private PerformanceTestDB db;
private SimplestRepository repo;
private SharedDbConnectionScope scope;

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

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

protected override void Setup()
{
db = new PerformanceTestDB();
repo = new SimplestRepository(db);
repo.DeleteMany(s => true);
}

protected override void TearDown()
{
repo.DeleteMany(s => true);
}

protected override void OpenSession()
{
scope = new SharedDbConnectionScope();
}

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

protected override void InsertMultipleTest(int count)
{
for (int i = 0; i < count; i++) {
var simplest = new Simplest {Id = i, Value = i};
repo.Add(simplest);
}
InstanceCount = count;
}

protected override void UpdateMultipleTest()
{
foreach (var simplest in db.Simplests) {
simplest.Value++;
repo.Update(simplest);
}
}

protected override void DeleteMultipleTest()
{
foreach (var simplest in db.Simplests) {
repo.Delete(simplest.Id);
}
}

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

protected override void UpdateSingleTest()
{
foreach (var simplest in db.Simplests) {
simplest.Value++;
repo.Update(simplest);
}
}

protected override void DeleteSingleTest()
{
foreach (var simplest in db.Simplests) {
repo.Delete(simplest.Id);
}
}

protected override void FetchTest(int count)
{
long sum = (long) count*(count - 1)/2;
for (int i = 0; i < count; i++) {
var id = (long) i%InstanceCount;
var simplest = repo.GetByKey(id);
sum -= simplest.Id;
}
if (count <= InstanceCount)
Assert.AreEqual(0, sum);
}

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

protected override void CompiledLinqQueryTest(int count)
{
throw new NotSupportedException();
}

protected override void NativeQueryTest(int count)
{
for (int i = 0; i < count; i++) {
var id = i % InstanceCount;
var query = new Select().From("Simplests").Where("Id").IsEqualTo(id);
foreach (var simplest in query.ExecuteTypedList<Simplest>()) {
// Doing nothing, just enumerate
}
}
}

protected override void NativeMaterializeTest(int count)
{
var query = new Select().From("Simplests");
int i = 0;
while (i < count)
foreach (var o in query.ExecuteTypedList<Simplest>())
if (++i >= count)
break;
}

protected override void LinqMaterializeTest(int count)
{
int i = 0;
while (i < count)
foreach (var o in db.Simplests)
if (++i >= count)
break;
}

protected override void LinqQueryPageTest(int count, int pageSize)
{
for (int i = 0; i < count; i++) {
var id = (i*pageSize) % InstanceCount;
var query = db.Simplests.Where(o => o.Id >= id).Take(pageSize);
foreach (var simplest in query) {
// Doing nothing, just enumerate
}
}
}
}
}

Change log

c6412f95a8d3 by Alex Yakunin on Jun 10, 2010   Diff
Project is upgraded to .NET 4.0.
Go to: 

Older revisions

1b64d6924dbc by igor.tkachev on Sep 9, 2009   Diff
Removed warnings.
7b91c0a5353e by alex.yakunin on Aug 31, 2009   Diff
- Open Access -> OpenAccess
- Copyright (C) Xtensive LLC ->
Copyright (C) ORMBattle.NET
- Minor fixes.
e48f2eff3ae2 by alex.yakunin on Aug 30, 2009   Diff
More paging tests are added.
Misc. improvements.
All revisions of this file

File info

Size: 4375 bytes, 171 lines
Powered by Google Project Hosting