Skip to content

Commit

Permalink
PR #634: add an async version of the WriteZipOutputStream benchmark
Browse files Browse the repository at this point in the history
  • Loading branch information
Numpsy committed May 13, 2021
1 parent 08c40e8 commit 8e4d144
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -253,3 +253,4 @@ paket-files/
/test/ICSharpCode.SharpZipLib.TestBootstrapper/Properties/launchSettings.json
_testRunner/
docs/help/api/.manifest
/benchmark/ICSharpCode.SharpZipLib.Benchmark/BenchmarkDotNet.Artifacts/results
21 changes: 21 additions & 0 deletions benchmark/ICSharpCode.SharpZipLib.Benchmark/Zip/ZipOutputStream.cs
@@ -1,5 +1,6 @@
using System;
using System.IO;
using System.Threading.Tasks;
using BenchmarkDotNet.Attributes;

namespace ICSharpCode.SharpZipLib.Benchmark.Zip
Expand Down Expand Up @@ -37,5 +38,25 @@ public long WriteZipOutputStream()
return memoryStream.Position;
}
}

[Benchmark]
public async Task<long> WriteZipOutputStreamAsync()
{
using (var memoryStream = new MemoryStream(outputBuffer))
{
using (var zipOutputStream = new SharpZipLib.Zip.ZipOutputStream(memoryStream))
{
zipOutputStream.IsStreamOwner = false;
zipOutputStream.PutNextEntry(new SharpZipLib.Zip.ZipEntry("0"));

for (int i = 0; i < ChunkCount; i++)
{
await zipOutputStream.WriteAsync(inputBuffer, 0, inputBuffer.Length);
}
}

return memoryStream.Position;
}
}
}
}

0 comments on commit 8e4d144

Please sign in to comment.