Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use PooledContextFactory #34

Closed
wants to merge 16 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ nuget.exe
debugSettings.json
project.lock.json
version.h
.build/

# Profiler result files, just in case they are left lying around :)
/.vs/
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Benchmarks for ASP.NET 5 including (but not limited to) scenarios from the [Tech

The benchmark repo is set up to work against the latest sources (i.e. not packages from nuget.org) for ASP.NET 5 so make sure you read through the following details to help you get started.

The ASP.NET 5 benchmarks server application itself is in the `./src/Benchmarks` folder. The `./expiremental` folder contains various experimental projects that aren't themselves part of the benchmarks.
The ASP.NET 5 benchmarks server application itself is in the `./src/Benchmarks` folder. The `./experimental` folder contains various experimental projects that aren't themselves part of the benchmarks.

## The scenarios
Following are the details of each of the scenarios the server application contains implementations for and thus can be benchmarked:
Expand Down
40 changes: 40 additions & 0 deletions build.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
@ECHO off
SETLOCAL

SET REPO_FOLDER=%~dp0
CD %REPO_FOLDER%

SET BUILD_FOLDER=.build
SET KOREBUILD_FOLDER=%BUILD_FOLDER%\KoreBuild-dotnet
SET KOREBUILD_VERSION=

SET NUGET_PATH=%BUILD_FOLDER%\NuGet.exe
SET NUGET_VERSION=latest
SET CACHED_NUGET=%LocalAppData%\NuGet\nuget.%NUGET_VERSION%.exe

IF NOT EXIST %BUILD_FOLDER% (
md %BUILD_FOLDER%
)

IF NOT EXIST %NUGET_PATH% (
IF NOT EXIST %CACHED_NUGET% (
echo Downloading latest version of NuGet.exe...
IF NOT EXIST %LocalAppData%\NuGet (
md %LocalAppData%\NuGet
)
@powershell -NoProfile -ExecutionPolicy unrestricted -Command "$ProgressPreference = 'SilentlyContinue'; Invoke-WebRequest 'https://dist.nuget.org/win-x86-commandline/%NUGET_VERSION%/nuget.exe' -OutFile '%CACHED_NUGET%'"
)

copy %CACHED_NUGET% %NUGET_PATH% > nul
)

IF NOT EXIST %KOREBUILD_FOLDER% (
SET KOREBUILD_DOWNLOAD_ARGS=
IF NOT "%KOREBUILD_VERSION%"=="" (
SET KOREBUILD_DOWNLOAD_ARGS=-version %KOREBUILD_VERSION%
)

%BUILD_FOLDER%\nuget.exe install KoreBuild-dotnet -ExcludeVersion -o %BUILD_FOLDER% -nocache -pre %KOREBUILD_DOWNLOAD_ARGS%
)

"%KOREBUILD_FOLDER%\build\KoreBuild.cmd" %*
14 changes: 14 additions & 0 deletions makefile.shade
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
var AUTHORS='Microsoft Open Technologies, Inc.'

use-standard-lifecycle
k-standard-goals

#build-compile target='compile'
@{
var projectFiles = Files
.Include("src/**/project.json")
.Include("experimental/**/project.json")
.ToList();

projectFiles.ForEach(projectFile => DotnetBuild(projectFile, E("Configuration")));
}
6 changes: 3 additions & 3 deletions src/Benchmarks/Controllers/HomeController.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// Copyright (c) .NET Foundation. All rights reserved.
// 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.Text;
using System.Threading.Tasks;
using Microsoft.AspNet.Http;
using Microsoft.AspNet.Mvc;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace Benchmarks.Controllers
{
Expand Down
4 changes: 2 additions & 2 deletions src/Benchmarks/Data/ApplicationDbContext.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) .NET Foundation. All rights reserved.
// 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.Data.Entity;
using Microsoft.EntityFrameworkCore;

namespace Benchmarks.Data
{
Expand Down
14 changes: 6 additions & 8 deletions src/Benchmarks/DebugInfoPageMiddleware.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
// Copyright (c) .NET Foundation. All rights reserved.
// 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.Threading.Tasks;
using Microsoft.AspNet.Builder;
using Microsoft.AspNet.Hosting;
using Microsoft.AspNet.Http;
using Microsoft.AspNet.Http.Features;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.Features;
using Microsoft.Extensions.PlatformAbstractions;

namespace Benchmarks
Expand Down Expand Up @@ -35,9 +35,7 @@ public DebugInfoPageMiddleware(RequestDelegate next, IHostingEnvironment hosting

public async Task Invoke(HttpContext httpContext)
{
// We check Ordinal explicitly first because it's faster than OrdinalIgnoreCase
if (httpContext.Request.Path.StartsWithSegments(_path, StringComparison.Ordinal) ||
httpContext.Request.Path.StartsWithSegments(_path, StringComparison.OrdinalIgnoreCase))
if (httpContext.Request.Path.StartsWithSegments(_path, StringComparison.Ordinal))
{
httpContext.Response.ContentType = "text/html";

Expand Down
6 changes: 3 additions & 3 deletions src/Benchmarks/ErrorHandlerMiddleware.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// Copyright (c) .NET Foundation. All rights reserved.
// 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.Threading.Tasks;
using Microsoft.AspNet.Builder;
using Microsoft.AspNet.Http;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Http;

namespace Benchmarks
{
Expand Down
10 changes: 4 additions & 6 deletions src/Benchmarks/FortunesDapperMiddleware.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) .NET Foundation. All rights reserved.
// 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;
Expand All @@ -8,8 +8,8 @@
using System.Threading.Tasks;
using Benchmarks.Data;
using Dapper;
using Microsoft.AspNet.Builder;
using Microsoft.AspNet.Http;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Http;

namespace Benchmarks
{
Expand All @@ -30,9 +30,7 @@ public FortunesDapperMiddleware(RequestDelegate next, string connectionString, D

public async Task Invoke(HttpContext httpContext, HtmlEncoder htmlEncoder)
{
// We check Ordinal explicitly first because it's faster than OrdinalIgnoreCase
if (httpContext.Request.Path.StartsWithSegments(_path, StringComparison.Ordinal) ||
httpContext.Request.Path.StartsWithSegments(_path, StringComparison.OrdinalIgnoreCase))
if (httpContext.Request.Path.StartsWithSegments(_path, StringComparison.Ordinal))
{
var rows = await LoadRows(_connectionString, _dbProviderFactory);

Expand Down
12 changes: 5 additions & 7 deletions src/Benchmarks/FortunesEfMiddleware.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
// Copyright (c) .NET Foundation. All rights reserved.
// 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.Collections.Generic;
using System.Text.Encodings.Web;
using System.Threading.Tasks;
using Benchmarks.Data;
using Microsoft.AspNet.Builder;
using Microsoft.AspNet.Http;
using Microsoft.Data.Entity;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Http;
using Microsoft.EntityFrameworkCore;

namespace Benchmarks
{
Expand All @@ -25,9 +25,7 @@ public FortunesEfMiddleware(RequestDelegate next)

public async Task Invoke(HttpContext httpContext, HtmlEncoder htmlEncoder)
{
// We check Ordinal explicitly first because it's faster than OrdinalIgnoreCase
if (httpContext.Request.Path.StartsWithSegments(_path, StringComparison.Ordinal) ||
httpContext.Request.Path.StartsWithSegments(_path, StringComparison.OrdinalIgnoreCase))
if (httpContext.Request.Path.StartsWithSegments(_path, StringComparison.Ordinal))
{
var db = (ApplicationDbContext)httpContext.RequestServices.GetService(typeof(ApplicationDbContext));
db.ChangeTracker.QueryTrackingBehavior = QueryTrackingBehavior.NoTracking;
Expand Down
10 changes: 4 additions & 6 deletions src/Benchmarks/FortunesRawMiddleware.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) .NET Foundation. All rights reserved.
// 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;
Expand All @@ -8,8 +8,8 @@
using System.Text.Encodings.Web;
using System.Threading.Tasks;
using Benchmarks.Data;
using Microsoft.AspNet.Builder;
using Microsoft.AspNet.Http;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Http;

namespace Benchmarks
{
Expand All @@ -30,9 +30,7 @@ public FortunesRawMiddleware(RequestDelegate next, string connectionString, DbPr

public async Task Invoke(HttpContext httpContext, HtmlEncoder htmlEncoder)
{
// We check Ordinal explicitly first because it's faster than OrdinalIgnoreCase
if (httpContext.Request.Path.StartsWithSegments(_path, StringComparison.Ordinal) ||
httpContext.Request.Path.StartsWithSegments(_path, StringComparison.OrdinalIgnoreCase))
if (httpContext.Request.Path.StartsWithSegments(_path, StringComparison.Ordinal))
{
var rows = await LoadRows(_connectionString, _dbProviderFactory);

Expand Down
10 changes: 4 additions & 6 deletions src/Benchmarks/JsonMiddleware.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
// Copyright (c) .NET Foundation. All rights reserved.
// 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.IO;
using System.Text;
using System.Threading.Tasks;
using Microsoft.AspNet.Builder;
using Microsoft.AspNet.Http;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Http;
using Newtonsoft.Json;

namespace Benchmarks
Expand All @@ -26,9 +26,7 @@ public JsonMiddleware(RequestDelegate next)

public Task Invoke(HttpContext httpContext)
{
// We check Ordinal explicitly first because it's faster than OrdinalIgnoreCase
if (httpContext.Request.Path.StartsWithSegments(_path, StringComparison.Ordinal) ||
httpContext.Request.Path.StartsWithSegments(_path, StringComparison.OrdinalIgnoreCase))
if (httpContext.Request.Path.StartsWithSegments(_path, StringComparison.Ordinal))
{
httpContext.Response.StatusCode = 200;
httpContext.Response.ContentType = "application/json";
Expand Down
8 changes: 4 additions & 4 deletions src/Benchmarks/Migrations/20151113004227_Initial.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions src/Benchmarks/Migrations/20151113004227_Initial.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System;
using System.Collections.Generic;
using Microsoft.Data.Entity.Migrations;
using Microsoft.Data.Entity.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Metadata;
using System.Text;

namespace Benchmarks.Migrations
Expand Down
8 changes: 4 additions & 4 deletions src/Benchmarks/Migrations/20151124205054_Fortune.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions src/Benchmarks/Migrations/20151124205054_Fortune.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System;
using System.Collections.Generic;
using Microsoft.Data.Entity.Migrations;
using Microsoft.Data.Entity.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Metadata;

namespace Benchmarks.Migrations
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
using System;
using Microsoft.Data.Entity;
using Microsoft.Data.Entity.Infrastructure;
using Microsoft.Data.Entity.Metadata;
using Microsoft.Data.Entity.Migrations;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
using Benchmarks.Data;

namespace Benchmarks.Migrations
Expand Down
11 changes: 4 additions & 7 deletions src/Benchmarks/MultipleQueriesDapperMiddleware.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
// Copyright (c) .NET Foundation. All rights reserved.
// 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.Data.Common;
using System.Linq;
using System.Threading.Tasks;
using Benchmarks.Data;
using Dapper;
using Microsoft.AspNet.Builder;
using Microsoft.AspNet.Http;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Http;
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;

Expand Down Expand Up @@ -36,9 +35,7 @@ public MultipleQueriesDapperMiddleware(RequestDelegate next, string connectionSt

public async Task Invoke(HttpContext httpContext)
{
// We check Ordinal explicitly first because it's faster than OrdinalIgnoreCase
if (httpContext.Request.Path.StartsWithSegments(_path, StringComparison.Ordinal) ||
httpContext.Request.Path.StartsWithSegments(_path, StringComparison.OrdinalIgnoreCase))
if (httpContext.Request.Path.StartsWithSegments(_path, StringComparison.Ordinal))
{
var count = GetQueryCount(httpContext);
var rows = await LoadRows(count, _connectionString, _dbProviderFactory);
Expand Down
12 changes: 5 additions & 7 deletions src/Benchmarks/MultipleQueriesEfMiddleware.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
// Copyright (c) .NET Foundation. All rights reserved.
// 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.Threading.Tasks;
using Benchmarks.Data;
using Microsoft.AspNet.Builder;
using Microsoft.AspNet.Http;
using Microsoft.Data.Entity;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Http;
using Microsoft.EntityFrameworkCore;
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;

Expand All @@ -29,9 +29,7 @@ public MultipleQueriesEfMiddleware(RequestDelegate next)

public async Task Invoke(HttpContext httpContext)
{
// We check Ordinal explicitly first because it's faster than OrdinalIgnoreCase
if (httpContext.Request.Path.StartsWithSegments(_path, StringComparison.Ordinal) ||
httpContext.Request.Path.StartsWithSegments(_path, StringComparison.OrdinalIgnoreCase))
if (httpContext.Request.Path.StartsWithSegments(_path, StringComparison.Ordinal))
{
var db = (ApplicationDbContext)httpContext.RequestServices.GetService(typeof(ApplicationDbContext));
db.ChangeTracker.QueryTrackingBehavior = QueryTrackingBehavior.NoTracking;
Expand Down
10 changes: 4 additions & 6 deletions src/Benchmarks/MultipleQueriesRawMiddleware.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
// Copyright (c) .NET Foundation. All rights reserved.
// 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.Data;
using System.Data.Common;
using System.Threading.Tasks;
using Benchmarks.Data;
using Microsoft.AspNet.Builder;
using Microsoft.AspNet.Http;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Http;
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;

Expand Down Expand Up @@ -35,9 +35,7 @@ public MultipleQueriesRawMiddleware(RequestDelegate next, string connectionStrin

public async Task Invoke(HttpContext httpContext)
{
// We check Ordinal explicitly first because it's faster than OrdinalIgnoreCase
if (httpContext.Request.Path.StartsWithSegments(_path, StringComparison.Ordinal) ||
httpContext.Request.Path.StartsWithSegments(_path, StringComparison.OrdinalIgnoreCase))
if (httpContext.Request.Path.StartsWithSegments(_path, StringComparison.Ordinal))
{
var count = GetQueryCount(httpContext);
var rows = await LoadRows(count, _connectionString, _dbProviderFactory);
Expand Down
Loading