Search iEntry News

WebProASP
FlashNewz
DevWebPro











GZip Vs. Deflate - Compression And Performance

By Mads Kristensen
Expert Author
Article Date: 2006-12-08

After I wrote about a HTTP compression module in ASP.NET 2.0 one of my colleagues pointed out that the Deflate compression is faster than GZip.

Because the HTTP compression module chooses GZip over Deflate if the browser allows it, I thought that I'd better make a quick performance test just to be sure. I used this little test method to give me the answer I was looking for:

using System.IO.Compression;
using System.IO;
using System.Diagnostics;

   private void PerformanceTest()
{
   byte[] buffer = new byte[5000];
   using (MemoryStream stream = new MemoryStream())
   {
     Stopwatch sw = new Stopwatch();
     sw.Start();
     for (int i = 0; i < 1000; i++)
     {
       GZipStream gzip = new GZipStream(stream, CompressionMode.Compress);
       gzip.Write(buffer, 0, buffer.Length);
     }

     sw.Stop();
     Response.Write(sw.ElapsedMilliseconds);
   }
}


First I tested the GZipStream and then the DeflateStream. I expected a minor difference because the two compression methods are different, but the result astonished me. I measured the DeflateStream to 41% faster than GZip. That's a very big difference. With this knowledge, I'll have to change the HTTP compression module to choose Deflate over GZip.

Comments

Add to Del.icio.us | Digg | Reddit | Furl

Bookmark WebProNews:

About the Author:
Mads Kristensen currently works as a Senior Developer at Traceworks located in Copenhagen, Denmark. Mads graduated from Copenhagen Technical Academy with a multimedia degree in 2003, but has been a professional developer since 2000. His main focus is on ASP.NET but is responsible for Winforms, Windows- and web services in his daily work as well. A true .NET developer with great passion for the simple solution.

http://www.madskristensen.dk/



Newsletter Archive | Article Archive | Submit Article | Advertising Information | Resources | About Us | Contact

WebProASP is an iEntry, Inc. ® publication - 1998-2008 All Rights Reserved Privacy Policy and Legal