Skip to content

Commit be3d4b7

Browse files
committed
Performance tests reworked to use Tests.Framework APIs
- One DoCrudTest instead of many per-storage tests. - SqlClientCrudTest is not bound to one hard-coded connection but uses current storage and ignores everything except MS SQL server storages
1 parent 766835d commit be3d4b7

7 files changed

Lines changed: 88 additions & 158 deletions

File tree

Orm/Xtensive.Orm.Tests/Storage/Performance/DoCrudTest.cs

Lines changed: 33 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -10,28 +10,45 @@
1010

1111
namespace Xtensive.Orm.Tests.Storage.Performance
1212
{
13-
public abstract class DoCrudTest : AutoBuildTest
13+
[Explicit]
14+
public sealed class DoCrudTest : AutoBuildTest
1415
{
1516
private const int BaseCount = 50000;
1617
private const int InsertCount = BaseCount;
1718
private const int EntitySetItemCount = 10;
1819

1920
private bool warmup;
21+
private bool firstTestRun = true;
2022
private int instanceCount;
2123
private int collectionCount;
2224

23-
protected abstract DomainConfiguration CreateConfiguration();
2425

2526
protected override sealed DomainConfiguration BuildConfiguration()
2627
{
27-
var config = CreateConfiguration();
28+
var config = DomainConfigurationFactory.CreateForCrudTest(TestConfiguration.Instance.Storage);
2829
config.Sessions.Add(new SessionConfiguration("Default"));
2930
// config.Sessions.Default.CacheSize = BaseCount;
3031
config.Sessions.Default.CacheType = SessionCacheType.Infinite;
3132
config.Types.Register(typeof (Simplest).Assembly, typeof (Simplest).Namespace);
3233
return config;
3334
}
3435

36+
public override void TestFixtureSetUp()
37+
{
38+
firstTestRun = true;
39+
base.TestFixtureSetUp();
40+
}
41+
42+
[SetUp]
43+
public void TestSetup()
44+
{
45+
if (!firstTestRun) {
46+
firstTestRun = false;
47+
return;
48+
}
49+
RebuildDomain();
50+
}
51+
3552
[Test]
3653
public void RegularTest()
3754
{
@@ -42,7 +59,6 @@ public void RegularTest()
4259
}
4360

4461
[Test]
45-
[Explicit]
4662
[Category("Profile")]
4763
public void ProfileTest()
4864
{
@@ -62,7 +78,6 @@ public void ProfileTest()
6278
}
6379

6480
[Test]
65-
[Explicit]
6681
[Category("Profile")]
6782
public void UpdatePerformanceTest()
6883
{
@@ -424,23 +439,22 @@ private void RseQueryTest(int count)
424439
private void CachedRseQueryTest(int count)
425440
{
426441
using (var session = Domain.OpenSession())
427-
using (session.Activate()) {
428-
using (var ts = session.OpenTransaction()) {
429-
TestHelper.CollectGarbage();
430-
var pKey = new Parameter<Tuple>();
431-
var rs = Domain.Model.Types[typeof (Simplest)].Indexes.PrimaryIndex.GetQuery().Seek(() => pKey.Value);
432-
using (new ParameterContext().Activate()) {
433-
using (warmup ? null : new Measurement("Cached RSE query", count)) {
434-
for (int i = 0; i < count; i++) {
435-
pKey.Value = Tuple.Create((long) (i%instanceCount));
436-
var es = rs.GetRecordSet(session).ToEntities<Simplest>(0);
437-
foreach (var o in es) {
438-
// Doing nothing, just enumerate
439-
}
442+
using (session.Activate())
443+
using (var ts = session.OpenTransaction()) {
444+
TestHelper.CollectGarbage();
445+
var pKey = new Parameter<Tuple>();
446+
var rs = Domain.Model.Types[typeof (Simplest)].Indexes.PrimaryIndex.GetQuery().Seek(() => pKey.Value);
447+
using (new ParameterContext().Activate()) {
448+
using (warmup ? null : new Measurement("Cached RSE query", count)) {
449+
for (int i = 0; i < count; i++) {
450+
pKey.Value = Tuple.Create((long) (i%instanceCount));
451+
var es = rs.GetRecordSet(session).ToEntities<Simplest>(0);
452+
foreach (var o in es) {
453+
// Doing nothing, just enumerate
440454
}
441455
}
442-
ts.Complete();
443456
}
457+
ts.Complete();
444458
}
445459
}
446460
}

Orm/Xtensive.Orm.Tests/Storage/Performance/DoMemoryCrudTest.cs

Lines changed: 0 additions & 21 deletions
This file was deleted.

Orm/Xtensive.Orm.Tests/Storage/Performance/DoOracleCrudTest.cs

Lines changed: 0 additions & 26 deletions
This file was deleted.

Orm/Xtensive.Orm.Tests/Storage/Performance/DoPostgreSqlCrudTest.cs

Lines changed: 0 additions & 26 deletions
This file was deleted.

Orm/Xtensive.Orm.Tests/Storage/Performance/DoSqlServerCrudTest.cs

Lines changed: 0 additions & 26 deletions
This file was deleted.

0 commit comments

Comments
 (0)