Skip to content

Commit 166ea04

Browse files
committed
Update
1 parent 39b2fe8 commit 166ea04

File tree

3 files changed

+19
-4
lines changed

3 files changed

+19
-4
lines changed

src/Servers/Kestrel/perf/Kestrel.Performance/Http2ConnectionBenchmarkBase.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ public abstract class Http2ConnectionBenchmarkBase
4040

4141
protected abstract Task ProcessRequest(HttpContext httpContext);
4242

43-
[GlobalSetup]
4443
public virtual void GlobalSetup()
4544
{
4645
_memoryPool = SlabMemoryPoolFactory.Create();

src/Servers/Kestrel/perf/Kestrel.Performance/Http2ConnectionEmptyBenchmark.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,10 @@ public class Http2ConnectionBenchmark : Http2ConnectionBenchmarkBase
1414

1515
private string _responseData;
1616

17+
[GlobalSetup]
1718
public override void GlobalSetup()
1819
{
20+
base.GlobalSetup();
1921
_responseData = new string('!', ResponseDataLength);
2022
}
2123

src/Servers/Kestrel/perf/Kestrel.Performance/Http2ConnectionHeadersBenchmark.cs

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,32 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Performance
1010
public class Http2ConnectionHeadersBenchmark : Http2ConnectionBenchmarkBase
1111
{
1212
[Params(1, 4, 32)]
13-
public int CustomHeaders { get; set; }
13+
public int HeadersCount { get; set; }
1414

1515
[Params(true, false)]
1616
public bool HeadersChange { get; set; }
1717

1818
private int _headerIndex;
19+
private string[] _headerNames;
20+
21+
[GlobalSetup]
22+
public override void GlobalSetup()
23+
{
24+
base.GlobalSetup();
25+
26+
_headerNames = new string[HeadersCount * (HeadersChange ? 1000 : 1)];
27+
for (var i = 0; i < _headerNames.Length; i++)
28+
{
29+
_headerNames[i] = "CustomHeader" + i;
30+
}
31+
}
1932

2033
protected override Task ProcessRequest(HttpContext httpContext)
2134
{
22-
for (var i = 0; i < CustomHeaders; i++)
35+
for (var i = 0; i < HeadersCount; i++)
2336
{
24-
httpContext.Response.Headers["CustomHeader" + _headerIndex] = "The quick brown fox jumps over the lazy dog.";
37+
var headerName = _headerNames[_headerIndex % HeadersCount];
38+
httpContext.Response.Headers[headerName] = "The quick brown fox jumps over the lazy dog.";
2539
if (HeadersChange)
2640
{
2741
_headerIndex++;

0 commit comments

Comments
 (0)