Skip to content
This repository has been archived by the owner on Nov 20, 2018. It is now read-only.

Adds PipeWriterAdapter #1065

Merged
merged 26 commits into from
Nov 17, 2018
Merged
Show file tree
Hide file tree
Changes from 22 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,3 +30,4 @@ project.lock.json
/.vs/
.vscode/
global.json
BenchmarkDotNet.Artifacts/
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;
}
}
}
}
1 change: 1 addition & 0 deletions build/dependencies.props
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
<MoqPackageVersion>4.9.0</MoqPackageVersion>
<NETStandardLibrary20PackageVersion>2.0.3</NETStandardLibrary20PackageVersion>
<SystemBuffersPackageVersion>4.6.0-preview1-26907-04</SystemBuffersPackageVersion>
<SystemIOPipelinesPackageVersion>4.6.0-preview1-26907-04</SystemIOPipelinesPackageVersion>
<SystemTextEncodingsWebPackageVersion>4.6.0-preview1-26907-04</SystemTextEncodingsWebPackageVersion>
<XunitAnalyzersPackageVersion>0.10.0</XunitAnalyzersPackageVersion>
<XunitPackageVersion>2.3.1</XunitPackageVersion>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<Description>ASP.NET Core default HTTP feature implementations.</Description>
<TargetFramework>netstandard2.0</TargetFramework>
<TargetFrameworks>netstandard2.0;netcoreapp2.2</TargetFrameworks>
jkotalik marked this conversation as resolved.
Show resolved Hide resolved
<NoWarn>$(NoWarn);CS1591</NoWarn>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
Expand All @@ -19,6 +19,7 @@
<PackageReference Include="Microsoft.Extensions.CopyOnWriteDictionary.Sources" PrivateAssets="All" Version="$(MicrosoftExtensionsCopyOnWriteDictionarySourcesPackageVersion)" />
<PackageReference Include="Microsoft.Extensions.ObjectPool" Version="$(MicrosoftExtensionsObjectPoolPackageVersion)" />
<PackageReference Include="Microsoft.Extensions.Options" Version="$(MicrosoftExtensionsOptionsPackageVersion)" />
<PackageReference Include="System.IO.Pipelines" Version="$(SystemIOPipelinesPackageVersion)" />
</ItemGroup>

</Project>
Loading