This repository was archived by the owner on Aug 2, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 343
Api brotli changes #1621
Merged
Merged
Api brotli changes #1621
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
f2da3ba
CaterburyPerf
Vedin da92380
flush/compress
Vedin 790191c
huge changes
Vedin f3b3e58
space
Vedin c87498f
small
Vedin e152fd1
flush/compress
Vedin d06e4b4
huge changes
Vedin fb317f5
space
Vedin 8fef201
small
Vedin d31a1c6
Merge branch 'APIBrotliChanges2' of https://github.com/Vedin/corefxla…
Vedin 78a1a75
resolve merge conflicts
Vedin d9b7587
unsaved chagnes
Vedin 5a6f037
test fix depends on APIchanges
Vedin fb51724
resolve issues
Vedin 1972d8b
Less alocation, change State
Vedin 6739e69
issue
Vedin 59f3981
remove unnecessary
Vedin 959a119
resolve
Vedin 7f8b3d4
clean up changes, change state
Vedin d4ddd1f
merge conflicts
Vedin 38ef5ec
resolve
Vedin 649f42c
guidelines
Vedin 516f4c6
fix bug
Vedin e1aa814
resolve issues
Vedin 1120e4f
change access
2f71a9b
small issues
Vedin 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
Next
Next commit
CaterburyPerf
- Loading branch information
commit f2da3baee55e108680874391a41b34df213f8502
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
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
98 changes: 98 additions & 0 deletions
98
tests/System.IO.Compression.Tests/BrotliPerformanceCanterburyCorpus.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,98 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information. | ||
using Microsoft.Xunit.Performance; | ||
using System.Collections.Generic; | ||
using System.IO.Compression; | ||
using System.Runtime.CompilerServices; | ||
using System.Security.Cryptography; | ||
using System.Threading.Tasks; | ||
using Xunit; | ||
|
||
namespace System.IO.Compression.Tests | ||
{ | ||
public class BrotliPerformanceCanterburyCorpus | ||
{ | ||
public static IEnumerable<object[]> CanterburyCorpus() | ||
{ | ||
foreach (CompressionLevel compressionLevel in Enum.GetValues(typeof(CompressionLevel))) | ||
{ | ||
foreach (int innerIterations in new int[] { 1, 10 }) | ||
{ | ||
yield return new object[] { innerIterations, "alice29.txt", compressionLevel }; | ||
yield return new object[] { innerIterations, "asyoulik.txt", compressionLevel }; | ||
yield return new object[] { innerIterations, "cp.html", compressionLevel }; | ||
yield return new object[] { innerIterations, "fields.c", compressionLevel }; | ||
yield return new object[] { innerIterations, "grammar.lsp", compressionLevel }; | ||
yield return new object[] { innerIterations, "kennedy.xls", compressionLevel }; | ||
yield return new object[] { innerIterations, "lcet10.txt", compressionLevel }; | ||
yield return new object[] { innerIterations, "plrabn12.txt", compressionLevel }; | ||
yield return new object[] { innerIterations, "ptt5", compressionLevel }; | ||
yield return new object[] { innerIterations, "sum", compressionLevel }; | ||
yield return new object[] { innerIterations, "xargs.1", compressionLevel }; | ||
} | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// Benchmark tests to measure the performance of individually compressing each file in the | ||
/// Canterbury Corpus | ||
/// </summary> | ||
[Benchmark] | ||
[MemberData(nameof(CanterburyCorpus))] | ||
public void Compress_Canterbury(int innerIterations, string fileName, CompressionLevel compressLevel) | ||
{ | ||
byte[] bytes = File.ReadAllBytes(Path.Combine("BrotliTestData", "Canterbury", fileName)); | ||
int bufferSize = 8096; | ||
FileStream[] fileStreams = new FileStream[innerIterations]; | ||
BrotliStream[] brotliStream = new BrotliStream[innerIterations]; | ||
string[] paths = new string[innerIterations]; | ||
foreach (var iteration in Benchmark.Iterations) | ||
{ | ||
for (int i = 0; i < innerIterations; i++) | ||
{ | ||
paths[i] = Util.GetTestFilePath(); | ||
fileStreams[i] = File.Create(paths[i]); | ||
} | ||
using (iteration.StartMeasurement()) | ||
for (int i = 0; i < innerIterations; i++) | ||
{ | ||
brotliStream[i] = new BrotliStream(fileStreams[i], CompressionMode.Compress, true, bufferSize, compressLevel); | ||
brotliStream[i].Write(bytes, 0, bytes.Length); | ||
brotliStream[i].Flush(); | ||
brotliStream[i].Dispose(); | ||
fileStreams[i].Dispose(); | ||
} | ||
for (int i = 0; i < innerIterations; i++) | ||
File.Delete(paths[i]); | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// Benchmark tests to measure the performance of individually decompressing each file in the | ||
/// Canterbury Corpus | ||
/// </summary> | ||
[Benchmark] | ||
[MemberData(nameof(CanterburyCorpus))] | ||
public void Decompress_Canterbury(int innerIterations, string fileName, CompressionLevel level) | ||
{ | ||
string zipFilePath = Path.Combine("BrotliTestData", "Canterbury", "BrotliCompressed", fileName + level.ToString() + ".br"); | ||
string sourceFilePath = Path.Combine("BrotliTestData", "Canterbury", fileName); | ||
byte[] outputRead = new byte[new FileInfo(sourceFilePath).Length]; | ||
MemoryStream[] memories = new MemoryStream[innerIterations]; | ||
foreach (var iteration in Benchmark.Iterations) | ||
{ | ||
for (int i = 0; i < innerIterations; i++) | ||
memories[i] = new MemoryStream(File.ReadAllBytes(zipFilePath)); | ||
|
||
using (iteration.StartMeasurement()) | ||
for (int i = 0; i < innerIterations; i++) | ||
using (BrotliStream decompressBrotli = new BrotliStream(memories[i], CompressionMode.Decompress)) | ||
decompressBrotli.Read(outputRead, 0, outputRead.Length); | ||
|
||
for (int i = 0; i < innerIterations; i++) | ||
memories[i].Dispose(); | ||
} | ||
} | ||
} | ||
} |
Binary file added
BIN
+62.3 KB
...tem.IO.Compression.Tests/BrotliTestData/Canterbury/BrotliCompressed/alice29.txtFastest.br
Binary file not shown.
Binary file added
BIN
+56 KB
....Compression.Tests/BrotliTestData/Canterbury/BrotliCompressed/alice29.txtNoCompression.br
Binary file not shown.
Binary file added
BIN
+46.4 KB
...tem.IO.Compression.Tests/BrotliTestData/Canterbury/BrotliCompressed/alice29.txtOptimal.br
Binary file not shown.
Binary file added
BIN
+54.1 KB
...em.IO.Compression.Tests/BrotliTestData/Canterbury/BrotliCompressed/asyoulik.txtFastest.br
Binary file not shown.
Binary file added
BIN
+49.3 KB
...Compression.Tests/BrotliTestData/Canterbury/BrotliCompressed/asyoulik.txtNoCompression.br
Binary file not shown.
Binary file added
BIN
+42.5 KB
...em.IO.Compression.Tests/BrotliTestData/Canterbury/BrotliCompressed/asyoulik.txtOptimal.br
Binary file not shown.
Binary file added
BIN
+8.76 KB
.../System.IO.Compression.Tests/BrotliTestData/Canterbury/BrotliCompressed/cp.htmlFastest.br
Binary file not shown.
Binary file added
BIN
+8.26 KB
...m.IO.Compression.Tests/BrotliTestData/Canterbury/BrotliCompressed/cp.htmlNoCompression.br
Binary file not shown.
Binary file added
BIN
+6.84 KB
.../System.IO.Compression.Tests/BrotliTestData/Canterbury/BrotliCompressed/cp.htmlOptimal.br
Binary file not shown.
Binary file added
BIN
+3.68 KB
...System.IO.Compression.Tests/BrotliTestData/Canterbury/BrotliCompressed/fields.cFastest.br
Binary file not shown.
Binary file added
BIN
+3.41 KB
....IO.Compression.Tests/BrotliTestData/Canterbury/BrotliCompressed/fields.cNoCompression.br
Binary file not shown.
Binary file added
BIN
+2.77 KB
...System.IO.Compression.Tests/BrotliTestData/Canterbury/BrotliCompressed/fields.cOptimal.br
Binary file not shown.
Binary file added
BIN
+1.35 KB
...tem.IO.Compression.Tests/BrotliTestData/Canterbury/BrotliCompressed/grammar.lspFastest.br
Binary file not shown.
Binary file added
BIN
+1.32 KB
....Compression.Tests/BrotliTestData/Canterbury/BrotliCompressed/grammar.lspNoCompression.br
Binary file not shown.
Binary file added
BIN
+1.12 KB
...tem.IO.Compression.Tests/BrotliTestData/Canterbury/BrotliCompressed/grammar.lspOptimal.br
Binary file not shown.
Binary file added
BIN
+173 KB
...tem.IO.Compression.Tests/BrotliTestData/Canterbury/BrotliCompressed/kennedy.xlsFastest.br
Binary file not shown.
Binary file added
BIN
+124 KB
....Compression.Tests/BrotliTestData/Canterbury/BrotliCompressed/kennedy.xlsNoCompression.br
Binary file not shown.
Binary file added
BIN
+63.9 KB
...tem.IO.Compression.Tests/BrotliTestData/Canterbury/BrotliCompressed/kennedy.xlsOptimal.br
Binary file not shown.
Binary file added
BIN
+166 KB
...stem.IO.Compression.Tests/BrotliTestData/Canterbury/BrotliCompressed/lcet10.txtFastest.br
Binary file not shown.
Binary file added
BIN
+145 KB
...O.Compression.Tests/BrotliTestData/Canterbury/BrotliCompressed/lcet10.txtNoCompression.br
Binary file not shown.
Binary file added
BIN
+113 KB
...stem.IO.Compression.Tests/BrotliTestData/Canterbury/BrotliCompressed/lcet10.txtOptimal.br
Binary file not shown.
Binary file added
BIN
+218 KB
...em.IO.Compression.Tests/BrotliTestData/Canterbury/BrotliCompressed/plrabn12.txtFastest.br
Binary file not shown.
Binary file added
BIN
+194 KB
...Compression.Tests/BrotliTestData/Canterbury/BrotliCompressed/plrabn12.txtNoCompression.br
Binary file not shown.
Binary file added
BIN
+164 KB
...em.IO.Compression.Tests/BrotliTestData/Canterbury/BrotliCompressed/plrabn12.txtOptimal.br
Binary file not shown.
Binary file added
BIN
+56.8 KB
tests/System.IO.Compression.Tests/BrotliTestData/Canterbury/BrotliCompressed/ptt5Fastest.br
Binary file not shown.
Binary file added
BIN
+52.5 KB
...stem.IO.Compression.Tests/BrotliTestData/Canterbury/BrotliCompressed/ptt5NoCompression.br
Binary file not shown.
Binary file added
BIN
+42.7 KB
tests/System.IO.Compression.Tests/BrotliTestData/Canterbury/BrotliCompressed/ptt5Optimal.br
Binary file not shown.
Binary file added
BIN
+14 KB
tests/System.IO.Compression.Tests/BrotliTestData/Canterbury/BrotliCompressed/sumFastest.br
Binary file not shown.
Binary file added
BIN
+13 KB
...ystem.IO.Compression.Tests/BrotliTestData/Canterbury/BrotliCompressed/sumNoCompression.br
Binary file not shown.
Binary file added
BIN
+10.8 KB
tests/System.IO.Compression.Tests/BrotliTestData/Canterbury/BrotliCompressed/sumOptimal.br
Binary file not shown.
Binary file added
BIN
+1.94 KB
.../System.IO.Compression.Tests/BrotliTestData/Canterbury/BrotliCompressed/xargs.1Fastest.br
Binary file not shown.
Binary file added
BIN
+1.83 KB
...m.IO.Compression.Tests/BrotliTestData/Canterbury/BrotliCompressed/xargs.1NoCompression.br
Binary file not shown.
Binary file added
BIN
+1.47 KB
.../System.IO.Compression.Tests/BrotliTestData/Canterbury/BrotliCompressed/xargs.1Optimal.br
Binary file not shown.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: inconsistent use of brace brackets.
You don't need the else statement.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed