Skip to content

Commit f99b54d

Browse files
committed
add an async version of the WriteZipOutputStream benchmark
1 parent 232d690 commit f99b54d

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,3 +253,4 @@ paket-files/
253253
/test/ICSharpCode.SharpZipLib.TestBootstrapper/Properties/launchSettings.json
254254
_testRunner/
255255
docs/help/api/.manifest
256+
/benchmark/ICSharpCode.SharpZipLib.Benchmark/BenchmarkDotNet.Artifacts/results

benchmark/ICSharpCode.SharpZipLib.Benchmark/Zip/ZipOutputStream.cs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System;
22
using System.IO;
3+
using System.Threading.Tasks;
34
using BenchmarkDotNet.Attributes;
45

56
namespace ICSharpCode.SharpZipLib.Benchmark.Zip
@@ -37,5 +38,25 @@ public long WriteZipOutputStream()
3738
return memoryStream.Position;
3839
}
3940
}
41+
42+
[Benchmark]
43+
public async Task<long> WriteZipOutputStreamAsync()
44+
{
45+
using (var memoryStream = new MemoryStream(outputBuffer))
46+
{
47+
using (var zipOutputStream = new SharpZipLib.Zip.ZipOutputStream(memoryStream))
48+
{
49+
zipOutputStream.IsStreamOwner = false;
50+
zipOutputStream.PutNextEntry(new SharpZipLib.Zip.ZipEntry("0"));
51+
52+
for (int i = 0; i < ChunkCount; i++)
53+
{
54+
await zipOutputStream.WriteAsync(inputBuffer, 0, inputBuffer.Length);
55+
}
56+
}
57+
58+
return memoryStream.Position;
59+
}
60+
}
4061
}
4162
}

0 commit comments

Comments
 (0)