Who we are

We are the developers of Plastic SCM, a full version control stack (not a Git variant). We work on the strongest branching and merging you can find, and a core that doesn't cringe with huge binaries and repos. We also develop the GUIs, mergetools and everything needed to give you the full version control stack.

If you want to give it a try, download it from here.

We also code SemanticMerge, and the gmaster Git client.

Decompressing zip files with C#

Friday, August 22, 2008 Pablo Santos , 7 Comments

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!
Pablo Santos
I'm the CTO and Founder at Códice.
I've been leading Plastic SCM since 2005. My passion is helping teams work better through version control.
I had the opportunity to see teams from many different industries at work while I helped them improving their version control practices.
I really enjoy teaching (I've been a University professor for 6+ years) and sharing my experience in talks and articles.
And I love simple code. You can reach me at @psluaces.

7 comments:

  1. Hi,

    I 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

    ReplyDelete
  2. Sounds normal.

    Where can one get your zlib binding?

    ReplyDelete
  3. Hi,

    You 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,

    ReplyDelete
  4. Hi,

    If you can use a GPL library, you can take a look at:

    http://www.koders.com/csharp/fid91385D2988B36B949C4771DF3BCD36519D43154A.aspx

    ReplyDelete
  5. Hi Alexandre,

    Thanks! I'll try to find the 7zip lib!

    ReplyDelete
  6. Sorry about that, forgot the link :P

    http://www.7-zip.org/sdk.html

    ReplyDelete