Decompressing zip files with C#
Which is the fastest way to decompress ZIP files (fragments actually) using C#?I tried with SharpZipLib vs zlib.net vs a wrapper on top of zlib 1.2.3.
Which one is faster?
I tried with the same test file, repeating 1000 times and these are the results:
$ time mono unzip.exe file ziplib 1000
real 0m4.491s
user 0m4.392s
sys 0m0.119s
$ time mono unzip.exe file sharp 1000
real 0m3.631s
user 0m3.550s
sys 0m0.090s
$ time mono unzip.exe file zlib 1000
real 0m1.754s
user 0m1.684s
sys 0m0.079s
Clear, right?
So, the zlib wrapper is two times faster than SharpZipLib which, in turn, is faster than zlib.net
For zlib wrapper I just called the uncompress method.
With SharpZipLib I used InflaterInputStream
InflaterInputStream st = new InflaterInputStream(file, new Inflater(true));
and for zlib.NET
zlib.ZOutputStream outZStream = new zlib.ZOutputStream(outStream);
Hope it helps!
how big what the file?
ReplyDeleteHi,
ReplyDeleteI tried with both small files (28Kb) and then a big number of text and binary files (about 3000), and zlib seems to be always faster
Sounds normal.
ReplyDeleteWhere can one get your zlib binding?
Hi,
ReplyDeleteYou should try the 7zip C# lib too. I'm not sure if its faster, or not, but I'm sure I've been pretty satisfied with its results compressing a Webservice requests and responses in real-time to some huge resultsets (up to 10MB of data each).
Cheers,
Hi,
ReplyDeleteIf you can use a GPL library, you can take a look at:
http://www.koders.com/csharp/fid91385D2988B36B949C4771DF3BCD36519D43154A.aspx
Hi Alexandre,
ReplyDeleteThanks! I'll try to find the 7zip lib!
Sorry about that, forgot the link :P
ReplyDeletehttp://www.7-zip.org/sdk.html