zlib performance

Daniel Kozák via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Fri Aug 7 01:05:00 PDT 2015


On Fri, 07 Aug 2015 08:01:27 +0000
"yawniek" <dlang at srtnwz.com> wrote:

> On Friday, 7 August 2015 at 07:48:25 UTC, yawniek wrote:
> > On Friday, 7 August 2015 at 07:43:25 UTC, Daniel Kozák wrote:
> > the fastest version i could come up so far is below.
> > std.conv slows it down.
> > going from a 4kb to a 4mb buffer helped. now i'm within 30% of 
> > gzcat's performance.
> 
> ok maybe not, there is another problem, not everything seems to 
> get flushed, i'm missing output
> 
> 
> 

import 
  std.zlib, 
  std.file,
  std.stdio,
  std.conv;

void main(string[] args)
{
  auto f = File(args[1], "rb");
  auto uncompressor = new UnCompress(HeaderFormat.gzip);

  foreach (buffer; f.byChunk(4096))
  {
          auto uncompressed =
  cast(char[])(uncompressor.uncompress(buffer.idup));
  write(uncompressed); }
  write(cast(char[])uncompressor.flush);
}

this is faster for me than zcat



More information about the Digitalmars-d-learn mailing list