Skip to content

Commit 478c6db

Browse files
committed
intro benchmark
1 parent a5f8264 commit 478c6db

File tree

5 files changed

+90
-0
lines changed

5 files changed

+90
-0
lines changed

AspNetCore.sln

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1818,6 +1818,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.AspNetCore.App.So
18181818
EndProject
18191819
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MinimalSampleOwin", "src\Http\samples\MinimalSampleOwin\MinimalSampleOwin.csproj", "{95032BC4-8BE5-4703-8075-93CB9DFF93EF}"
18201820
EndProject
1821+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.AspNetCore.Owin.Microbenchmarks", "src\Http\Owin\benchmarks\Microsoft.AspNetCore.Owin.Microbenchmarks\Microsoft.AspNetCore.Owin.Microbenchmarks.csproj", "{E0FBCBF6-030C-4F15-A58A-F0F33DCC26E9}"
1822+
EndProject
18211823
Global
18221824
GlobalSection(SolutionConfigurationPlatforms) = preSolution
18231825
Debug|Any CPU = Debug|Any CPU
@@ -10995,6 +10997,22 @@ Global
1099510997
{95032BC4-8BE5-4703-8075-93CB9DFF93EF}.Release|x64.Build.0 = Release|Any CPU
1099610998
{95032BC4-8BE5-4703-8075-93CB9DFF93EF}.Release|x86.ActiveCfg = Release|Any CPU
1099710999
{95032BC4-8BE5-4703-8075-93CB9DFF93EF}.Release|x86.Build.0 = Release|Any CPU
11000+
{E0FBCBF6-030C-4F15-A58A-F0F33DCC26E9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
11001+
{E0FBCBF6-030C-4F15-A58A-F0F33DCC26E9}.Debug|Any CPU.Build.0 = Debug|Any CPU
11002+
{E0FBCBF6-030C-4F15-A58A-F0F33DCC26E9}.Debug|arm64.ActiveCfg = Debug|Any CPU
11003+
{E0FBCBF6-030C-4F15-A58A-F0F33DCC26E9}.Debug|arm64.Build.0 = Debug|Any CPU
11004+
{E0FBCBF6-030C-4F15-A58A-F0F33DCC26E9}.Debug|x64.ActiveCfg = Debug|Any CPU
11005+
{E0FBCBF6-030C-4F15-A58A-F0F33DCC26E9}.Debug|x64.Build.0 = Debug|Any CPU
11006+
{E0FBCBF6-030C-4F15-A58A-F0F33DCC26E9}.Debug|x86.ActiveCfg = Debug|Any CPU
11007+
{E0FBCBF6-030C-4F15-A58A-F0F33DCC26E9}.Debug|x86.Build.0 = Debug|Any CPU
11008+
{E0FBCBF6-030C-4F15-A58A-F0F33DCC26E9}.Release|Any CPU.ActiveCfg = Release|Any CPU
11009+
{E0FBCBF6-030C-4F15-A58A-F0F33DCC26E9}.Release|Any CPU.Build.0 = Release|Any CPU
11010+
{E0FBCBF6-030C-4F15-A58A-F0F33DCC26E9}.Release|arm64.ActiveCfg = Release|Any CPU
11011+
{E0FBCBF6-030C-4F15-A58A-F0F33DCC26E9}.Release|arm64.Build.0 = Release|Any CPU
11012+
{E0FBCBF6-030C-4F15-A58A-F0F33DCC26E9}.Release|x64.ActiveCfg = Release|Any CPU
11013+
{E0FBCBF6-030C-4F15-A58A-F0F33DCC26E9}.Release|x64.Build.0 = Release|Any CPU
11014+
{E0FBCBF6-030C-4F15-A58A-F0F33DCC26E9}.Release|x86.ActiveCfg = Release|Any CPU
11015+
{E0FBCBF6-030C-4F15-A58A-F0F33DCC26E9}.Release|x86.Build.0 = Release|Any CPU
1099811016
EndGlobalSection
1099911017
GlobalSection(SolutionProperties) = preSolution
1100011018
HideSolutionNode = FALSE
@@ -11893,6 +11911,7 @@ Global
1189311911
{B9BBC1A8-7F58-4F43-94C3-5F3CB125CEF7} = {B32FF7A7-9CB3-4DCD-AE97-3B2594DB9DAC}
1189411912
{C3928C15-1836-46DB-A09D-9EFBCCA33E08} = {B5D98AEB-9409-4280-8225-9C1EC6A791B2}
1189511913
{95032BC4-8BE5-4703-8075-93CB9DFF93EF} = {EB5E294B-9ED5-43BF-AFA9-1CD2327F3DC1}
11914+
{E0FBCBF6-030C-4F15-A58A-F0F33DCC26E9} = {AA465A56-D9D0-4684-95B0-192F4436C582}
1189611915
EndGlobalSection
1189711916
GlobalSection(ExtensibilityGlobals) = postSolution
1189811917
SolutionGuid = {3E8720B3-DBDD-498C-B383-2CC32A054E8F}

src/Http/HttpAbstractions.slnf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
"src\\Http\\Http\\src\\Microsoft.AspNetCore.Http.csproj",
3232
"src\\Http\\Http\\test\\Microsoft.AspNetCore.Http.Tests.csproj",
3333
"src\\Http\\Metadata\\src\\Microsoft.AspNetCore.Metadata.csproj",
34+
"src\\Http\\Owin\\benchmarks\\Microsoft.AspNetCore.Owin.Microbenchmarks\\Microsoft.AspNetCore.Owin.Microbenchmarks.csproj",
3435
"src\\Http\\Owin\\src\\Microsoft.AspNetCore.Owin.csproj",
3536
"src\\Http\\Owin\\test\\Microsoft.AspNetCore.Owin.Tests.csproj",
3637
"src\\Http\\Routing.Abstractions\\src\\Microsoft.AspNetCore.Routing.Abstractions.csproj",
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
4+
using BenchmarkDotNet.Attributes;
5+
using Microsoft.AspNetCore.Builder;
6+
using Microsoft.AspNetCore.Http;
7+
using Microsoft.Extensions.DependencyInjection;
8+
9+
namespace Microsoft.AspNetCore.Owin.Microbenchmarks.Benchmarks;
10+
11+
[MemoryDiagnoser]
12+
public class OwinEnvironmentBenchmark
13+
{
14+
private RequestDelegate _requestDelegate;
15+
private readonly HttpContext _httpContext = new DefaultHttpContext();
16+
17+
[GlobalSetup]
18+
public void GlobalSetup()
19+
{
20+
var serviceProvider = new ServiceCollection().BuildServiceProvider();
21+
var builder = new ApplicationBuilder(serviceProvider);
22+
IDictionary<string, object> environment = null;
23+
24+
builder.UseOwin(addToPipeline =>
25+
{
26+
addToPipeline(next =>
27+
{
28+
return async env =>
29+
{
30+
environment = env;
31+
await next(env);
32+
};
33+
});
34+
});
35+
36+
_requestDelegate = builder.Build();
37+
}
38+
39+
[Benchmark]
40+
public async Task ProcessMultipleRequests()
41+
{
42+
foreach (var i in Enumerable.Range(0, 10000))
43+
{
44+
await _requestDelegate(_httpContext);
45+
}
46+
}
47+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>$(DefaultNetCoreTargetFramework)</TargetFramework>
6+
</PropertyGroup>
7+
8+
<ItemGroup>
9+
<Reference Include="BenchmarkDotNet" />
10+
<Reference Include="Microsoft.AspNetCore.Http" />
11+
<Reference Include="Microsoft.AspNetCore.Owin" />
12+
<Reference Include="Microsoft.Extensions.DependencyInjection" />
13+
14+
<Compile Include="$(SharedSourceRoot)BenchmarkRunner\*.cs" />
15+
</ItemGroup>
16+
17+
</Project>
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
4+
using BenchmarkDotNet.Running;
5+
6+
BenchmarkSwitcher.FromAssembly(typeof(Program).Assembly).Run();

0 commit comments

Comments
 (0)