Skip to content

Commit

Permalink
Test code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
AndriySvyryd committed Aug 27, 2019
1 parent 676730a commit 24b9aa1
Show file tree
Hide file tree
Showing 435 changed files with 10,162 additions and 27,833 deletions.
16 changes: 8 additions & 8 deletions benchmark/EF.Benchmarks.Shared/EFCoreBenchmarkRunner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,14 @@ public static void Run(string[] args, Assembly assembly, IConfig config = null)
.With(StatisticColumn.OperationsPerSecond, new ParamsSummaryColumn())
.With(
MarkdownExporter.GitHub, new CsvExporter(
CsvSeparator.Comma,
new SummaryStyle
{
PrintUnitsInHeader = true,
PrintUnitsInContent = false,
TimeUnit = TimeUnit.Microsecond,
SizeUnit = SizeUnit.KB
}));
CsvSeparator.Comma,
new SummaryStyle
{
PrintUnitsInHeader = true,
PrintUnitsInContent = false,
TimeUnit = TimeUnit.Microsecond,
SizeUnit = SizeUnit.KB
}));
}

BenchmarkSwitcher.FromAssembly(assembly).Run(args, config);
Expand Down
2 changes: 1 addition & 1 deletion benchmark/EF.Benchmarks.Shared/ParamsSummaryColumn.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@ public class ParamsSummaryColumn : IColumn
public bool IsNumeric => false;
public UnitType UnitType => UnitType.Dimensionless;
public string GetValue(Summary summary, BenchmarkCase benchmark, ISummaryStyle style) => GetValue(summary, benchmark);
public string Legend => $"Summary of all parameter values";
public string Legend => "Summary of all parameter values";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -116,13 +116,15 @@ public virtual void Update()
// API for bulk update in EF6.x
}

[SingleRunJob, Description("AutoDetectChanges=True")]
[SingleRunJob]
[Description("AutoDetectChanges=True")]
public class AddDataVariationsWithAutoDetectChangesOn : AddDataVariations
{
protected override bool AutoDetectChanges => true;
}

[SingleRunJob, Description("AutoDetectChanges=True")]
[SingleRunJob]
[Description("AutoDetectChanges=True")]
public class ExistingDataVariationsWithAutoDetectChangesOn : ExistingDataVariations
{
protected override bool AutoDetectChanges => true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,13 +122,15 @@ public virtual void QueryChildren()
}
}

[SingleRunJob, Description("AutoDetectChanges=True")]
[SingleRunJob]
[Description("AutoDetectChanges=True")]
public class ChildVariationsWithAutoDetectChangesOn : ChildVariations
{
protected override bool AutoDetectChanges => true;
}

[SingleRunJob, Description("AutoDetectChanges=True")]
[SingleRunJob]
[Description("AutoDetectChanges=True")]
public class ParentVariationsWithAutoDetectChangesOn : ParentVariations
{
protected override bool AutoDetectChanges => true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@ public class SingleRunJobAttribute : Attribute, IConfigSource
{
public SingleRunJobAttribute()
{
Config = ManualConfig.CreateEmpty().With(new Job()
.WithWarmupCount(1)
.WithIterationCount(1)
.With(RunStrategy.Monitoring));
Config = ManualConfig.CreateEmpty().With(
new Job()
.WithWarmupCount(1)
.WithIterationCount(1)
.With(RunStrategy.Monitoring));
}

public IConfig Config { get; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,7 @@ public virtual void InitializeAndSaveChanges_AdventureWorks(int count)
using (var context = AdventureWorksFixture.CreateContext())
{
context.Currency.Add(
new Currency
{
CurrencyCode = "TMP",
Name = "Temporary"
});
new Currency { CurrencyCode = "TMP", Name = "Temporary" });

using (context.Database.BeginTransaction())
{
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

using Microsoft.EntityFrameworkCore.Benchmarks;

namespace Microsoft.EntityFrameworkCore.Benchmarks.Models.AdventureWorks
{
public static class AdventureWorksFixture
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ public class OrdersFixture : OrdersFixtureSeedBase
private readonly int _ordersPerCustomer;
private readonly int _linesPerOrder;

public OrdersFixture(string databaseName, int productCount, int customerCount,
public OrdersFixture(
string databaseName, int productCount, int customerCount,
int ordersPerCustomer, int linesPerOrder, Action<DbContext> seedAction = null)
{
_connectionString = SqlServerBenchmarkEnvironment.CreateConnectionString(databaseName);
Expand Down Expand Up @@ -58,10 +59,10 @@ private void EnsureDatabaseCreated(Action<DbContext> seedAction)
private bool IsDatabaseCorrect(OrdersContext context)
{
return context.Database.CompatibleWithModel(throwIfNoMetadata: true)
&& _productCount == context.Products.Count()
&& _customerCount == context.Customers.Count()
&& (_customerCount * _ordersPerCustomer == context.Orders.Count())
&& (_customerCount * _ordersPerCustomer * _linesPerOrder == context.OrderLines.Count());
&& _productCount == context.Products.Count()
&& _customerCount == context.Customers.Count()
&& (_customerCount * _ordersPerCustomer == context.Orders.Count())
&& (_customerCount * _ordersPerCustomer * _linesPerOrder == context.OrderLines.Count());
}

private void InsertSeedData()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public class FuncletizationTests
{
private static readonly OrdersFixture _fixture
= new OrdersFixture("Perf_Query_Funcletization_EF6", 100, 0, 0, 0);

private const int _funcletizationIterationCount = 100;

private OrdersContext _context;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public class QueryCompilationTests
{
private static readonly OrdersFixture _fixture
= new OrdersFixture("Perf_Query_Compilation_EF6", 0, 0, 0, 0);

private OrdersContext _context;
private IQueryable<Product> _simpleQuery;
private IQueryable<DTO> _complexQuery;
Expand Down
5 changes: 3 additions & 2 deletions benchmark/EF6.SqlServer.Benchmarks/Query/RawSqlQueryTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ namespace Microsoft.EntityFrameworkCore.Benchmarks.Query
public class RawSqlQueryTests
{
private static readonly OrdersFixture _fixture
= new OrdersFixture("Perf_Query_RawSql_EF6", 1000, 1000, 2, 2,
= new OrdersFixture(
"Perf_Query_RawSql_EF6", 1000, 1000, 2, 2,
ctx => ctx.Database.ExecuteSqlCommand(
@"CREATE PROCEDURE dbo.SearchProducts
@minPrice decimal(18, 2),
Expand All @@ -23,6 +24,7 @@ @maxPrice decimal(18, 2)
BEGIN
SELECT * FROM dbo.Products WHERE CurrentPrice >= @minPrice AND CurrentPrice <= @maxPrice
END"));

private OrdersContext _context;

[Params(true, false)]
Expand All @@ -34,7 +36,6 @@ @maxPrice decimal(18, 2)
[GlobalSetup]
public virtual void CreateContext()
{

_context = _fixture.CreateContext();

Assert.Equal(1000, _context.Products.Count());
Expand Down
7 changes: 2 additions & 5 deletions benchmark/EF6.SqlServer.Benchmarks/Query/SimpleQueryTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public class SimpleQueryTests
{
private static readonly OrdersFixture _fixture
= new OrdersFixture("Perf_Query_Simple_EF6", 1000, 1000, 2, 2);

private OrdersContext _context;

[Params(true, false)]
Expand Down Expand Up @@ -130,11 +131,7 @@ public virtual async Task GroupBy()
var query = _context.Products
.GroupBy(p => p.Retail)
.Select(
g => new
{
Retail = g.Key,
Products = g
});
g => new { Retail = g.Key, Products = g });

if (Async)
{
Expand Down
3 changes: 2 additions & 1 deletion benchmark/EF6.SqlServer.Benchmarks/Support/Extensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ public static IQueryable<TEntity> DisableQueryCache<TEntity>(this IQueryable<TEn
where TEntity : class
{
var internalQuery = typeof(DbQuery<TEntity>)
.GetProperty("System.Data.Entity.Internal.Linq.IInternalQueryAdapter.InternalQuery", BindingFlags.NonPublic | BindingFlags.Instance)
.GetProperty(
"System.Data.Entity.Internal.Linq.IInternalQueryAdapter.InternalQuery", BindingFlags.NonPublic | BindingFlags.Instance)
.GetMethod
.Invoke(query, Array.Empty<object>());

Expand Down
12 changes: 1 addition & 11 deletions benchmark/EF6.SqlServer.Benchmarks/Support/Program.cs
Original file line number Diff line number Diff line change
@@ -1,17 +1,7 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

using System;
using System.Linq;
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Columns;
using BenchmarkDotNet.Configs;
using BenchmarkDotNet.Diagnosers;
using BenchmarkDotNet.Exporters;
using BenchmarkDotNet.Exporters.Csv;
using BenchmarkDotNet.Horology;
using BenchmarkDotNet.Reports;
using BenchmarkDotNet.Running;


// ReSharper disable once CheckNamespace
namespace Microsoft.EntityFrameworkCore.Benchmarks
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

using System.IO;
using System.Data.SqlClient;
using System.IO;
using Microsoft.Extensions.Configuration;

// ReSharper disable once CheckNamespace
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public abstract class UpdatePipelineBase
{
protected static readonly OrdersFixture _fixture
= new OrdersFixture("Perf_UpdatePipeline_Simple_EF6", 0, 1000, 0, 0);

protected OrdersContext _context;
private DbContextTransaction _transaction;
private int _recordsAffected = -1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,7 @@ public void InitializeAndSaveChanges_AdventureWorks(int count)
using (var context = CreateContext())
{
context.Currency.Add(
new Currency
{
CurrencyCode = "TMP",
Name = "Temporary"
});
new Currency { CurrencyCode = "TMP", Name = "Temporary" });

using (context.Database.BeginTransaction())
{
Expand Down
Loading

0 comments on commit 24b9aa1

Please sign in to comment.