-
Notifications
You must be signed in to change notification settings - Fork 10k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
ladeak
committed
Sep 11, 2024
1 parent
8878dad
commit bfc2e12
Showing
4 changed files
with
74 additions
and
91 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
src/Servers/Kestrel/perf/Microbenchmarks/Http2/FlowControl/FlowControlBenchmark.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
using BenchmarkDotNet.Attributes; | ||
using Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http2.FlowControl; | ||
|
||
namespace Microsoft.AspNetCore.Server.Kestrel.Microbenchmarks.Http2.FlowControl; | ||
|
||
public class FlowControlBenchmark | ||
{ | ||
private readonly InputFlowControl _flowControl = new(1000, 10); | ||
private const int N = 100000; | ||
private const int Spin = 50; | ||
private const int ThreadsCount = 3; | ||
|
||
[IterationSetup] | ||
public void IterationSetup() | ||
{ | ||
_flowControl.Reset(); | ||
} | ||
|
||
[Benchmark] | ||
public async Task ThreadsAdvanceWithWindowUpdates() | ||
{ | ||
var parallelThreads = new Task[ThreadsCount + 1]; | ||
_flowControl.Reset(); | ||
for (var i = 0; i < ThreadsCount; i++) | ||
{ | ||
var advanceTask = Task.Factory.StartNew(() => | ||
{ | ||
for (int i = 0; i < N; i++) | ||
{ | ||
if (_flowControl.TryUpdateWindow(16, out _)) | ||
{ | ||
for (int j = 0; j < Spin; j++) | ||
{ | ||
} | ||
} | ||
} | ||
}, TaskCreationOptions.LongRunning); | ||
parallelThreads[i] = advanceTask; | ||
var tAdvance = Task.Factory.StartNew(() => | ||
{ | ||
for (var i = 0; i < N; i++) | ||
{ | ||
_flowControl.TryAdvance(1); | ||
} | ||
_flowControl.Abort(); | ||
}, TaskCreationOptions.LongRunning); | ||
parallelThreads[ThreadsCount] = tAdvance; | ||
} | ||
|
||
await Task.WhenAll(parallelThreads); | ||
} | ||
} |
74 changes: 0 additions & 74 deletions
74
src/Servers/Kestrel/perf/Microbenchmarks/Http2/FlowControl/InputFlowControl.cs
This file was deleted.
Oops, something went wrong.