This repository was archived by the owner on Nov 20, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 191
Adds PipeWriterAdapter #1065
Merged
Merged
Adds PipeWriterAdapter #1065
Changes from 21 commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
37c509f
Implement PipeWriterAdapter
jkotalik 27ee6b6
Feedback:
jkotalik d67777e
Feedback:
jkotalik 3be99d5
tests and profile
jkotalik e4fa58d
Good amount of feedback
jkotalik 3db542d
More changes and realizing my writing was incorrect
jkotalik e41863b
Feedback:
jkotalik 1f1f418
Consolidate tests into single file
jkotalik 6b90c5e
Ended up not needing the obob case
jkotalik f9a23ce
More tests and renaming test/benchmark files
jkotalik 07551b7
Update to use MemoryPool
jkotalik 658ff2b
Revert Memory Changes
jkotalik 263504f
Use MemoryPool
jkotalik 8455dcb
remove nullable check for now
jkotalik 6f77267
Update cts logic
jkotalik ac0d576
Fb
jkotalik 878bec2
fix data race
jkotalik b5e2c65
cleanup
jkotalik 7bf5f2c
Make memory pool plugable
jkotalik 00b6325
Feedback:
jkotalik 92d02dc
Remove async
jkotalik 6d21200
Feedback
jkotalik e0eabec
Feedback
jkotalik 4305011
Add test memory pool, call Complete from Dispose
jkotalik 7d1bef1
nits
jkotalik 28fd0d1
fix test
jkotalik File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 |
---|---|---|
|
@@ -30,3 +30,4 @@ project.lock.json | |
/.vs/ | ||
.vscode/ | ||
global.json | ||
BenchmarkDotNet.Artifacts/ |
89 changes: 89 additions & 0 deletions
89
benchmarks/Microsoft.AspNetCore.Http.Performance/StreamPipeWriterBenchmark.cs
This file contains hidden or 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,89 @@ | ||
// 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; | ||
using System.Threading.Tasks; | ||
using BenchmarkDotNet.Attributes; | ||
|
||
namespace Microsoft.AspNetCore.Http | ||
{ | ||
public class StreamPipeWriterBenchmark | ||
{ | ||
private Stream _memoryStream; | ||
private StreamPipeWriter _pipeWriter; | ||
private static byte[] _helloWorldBytes = Encoding.ASCII.GetBytes("Hello World"); | ||
private static byte[] _largeWrite = Encoding.ASCII.GetBytes(new string('a', 50000)); | ||
|
||
[IterationSetup] | ||
public void Setup() | ||
{ | ||
_memoryStream = new NoopStream(); | ||
_pipeWriter = new StreamPipeWriter(_memoryStream); | ||
} | ||
|
||
[Benchmark] | ||
public async Task WriteHelloWorld() | ||
{ | ||
await _pipeWriter.WriteAsync(_helloWorldBytes); | ||
} | ||
|
||
[Benchmark] | ||
public async Task WriteHelloWorldLargeWrite() | ||
{ | ||
await _pipeWriter.WriteAsync(_largeWrite); | ||
} | ||
|
||
public class NoopStream : Stream | ||
{ | ||
public override bool CanRead => false; | ||
|
||
public override bool CanSeek => throw new System.NotImplementedException(); | ||
|
||
public override bool CanWrite => true; | ||
|
||
public override long Length => throw new System.NotImplementedException(); | ||
|
||
public override long Position { get => throw new System.NotImplementedException(); set => throw new System.NotImplementedException(); } | ||
|
||
public override void Flush() | ||
{ | ||
} | ||
|
||
public override int Read(byte[] buffer, int offset, int count) | ||
{ | ||
throw new System.NotImplementedException(); | ||
} | ||
|
||
public override long Seek(long offset, SeekOrigin origin) | ||
{ | ||
throw new System.NotImplementedException(); | ||
} | ||
|
||
public override void SetLength(long value) | ||
{ | ||
} | ||
|
||
public override void Write(byte[] buffer, int offset, int count) | ||
{ | ||
} | ||
|
||
public override Task WriteAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken) | ||
{ | ||
return Task.CompletedTask; | ||
} | ||
|
||
public override ValueTask WriteAsync(ReadOnlyMemory<byte> buffer, CancellationToken cancellationToken = default(CancellationToken)) | ||
{ | ||
return default(ValueTask); | ||
} | ||
|
||
public override Task FlushAsync(CancellationToken cancellationToken) | ||
{ | ||
return Task.CompletedTask; | ||
} | ||
} | ||
} | ||
} |
This file contains hidden or 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 hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.