This article is a mirror article of machine translation, please click here to jump to the original article.

View: 3487|Reply: 3

[Source] .NET 6 tests Gzip and Brotli algorithms

[Copy link]
Posted on 9/17/2023 10:45:34 AM | | | |
Requirements: HTTP now adds a Brotli compression algorithm to test Gzip and Brotli algorithms. Depending on the project, only the speed of decompression is tested in the article.

Brotli has12 levels of compression, from 0 to 11, where 0 provides the fastest compression speed but the lowest compression ratio, while 11 provides the highest compression ratio but requires more computing resources and time. When we first implemented Brotli 5 years ago, we determined that 4-level compression provided a balance of byte savings and compression time without compromising performance. The higher the compression level, the smaller the footprint, but it sells more CPU and memory resources.

ASP.NET Brotli algorithm is already built into the core and does not require reference to third-party packages. (This article will refer to the third-party package: BrotliSharpLib and the built-in one for comparison), the configuration is as follows:


ASP.NET Core Brotli compression call flow: ResponseCompressionServicesExtensions -> AddResponseCompression -> ResponseCompressionProvider -> BrotliCompressionProvider -> BrotliStream.



The compression level enumeration code is as follows:

Create a new .NET 6 console project with the following benchmark code:


The test results are as follows:



I tested a 503kb file, and after compression, there was not much difference, all around 400kb, and it turned out that Gzip's decompression speed was still faster than Brotli's, which should be the samefile size, . NET version, compression level, file content, etcIn short, it is best to choose the scene that suits you.

If you encounter an error like this:

Environment
  Summary -> Detected error exit code from one of the benchmarks. It might be caused by following antivirus software:
        - 360 SafeGuard (C:\Program Files (x86)\360\360Safe\safemon\360tray.exe)
        - Windows Defender (windowsdefender://)
Use InProcessEmitToolchain or InProcessNoEmitToolchain to avoid new process creation.
solution

or
(End)





Previous:[Turn]. NET uses Brotli to compress and decompress data
Next:EF6 Required allows empty strings but not nullities
 Landlord| Posted on 9/17/2023 10:46:46 AM |

asp.net core 3.1 enables the website Brotli compression algorithm
https://www.itsvse.com/thread-9532-1-1.html

.net/c# GZipStream data compression
https://www.itsvse.com/thread-4240-1-1.html




 Landlord| Posted on 9/17/2023 10:48:01 AM |
[Turn]. NET uses Brotli to compress and decompress data
https://www.itsvse.com/thread-10662-1-1.html
 Landlord| Posted on 1/7/2025 10:18:37 AM |
【zip】. NET/C# uses built-in System.IO.Compression to compress and decompress
https://www.itsvse.com/thread-10912-1-1.html
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com