zlib performance

Daniel Kozak via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Fri Aug 7 04:44:59 PDT 2015


On Friday, 7 August 2015 at 09:12:32 UTC, yawniek wrote:
> On Friday, 7 August 2015 at 08:50:11 UTC, Daniel Kozák wrote:
>>> > ldc[2] -O -release -boundscheck=off -singleobj  app.d
>>> 
>>> 
>>> ldc 0.15.2 beta2
>>> 2.86s user 0.55s system 77% cpu 4.392 total
>>> 
>>> v2.068-devel-8f81ffc
>>> 2.86s user 0.67s system 78% cpu 4.476 total
>>> 
>>> v2.067
>>> 2.88s user 0.67s system 78% cpu 4.529 total
>>> 
>
>
> i can now reproduce the results and indeed, its faster than 
> zcat:
> on a c4.xlarge aws instance running archlinux and dmd v2.067
> same file as above on my macbook.
>
> best run: 2.72s user 0.39s system 99% cpu 3.134 total
> worst run: 3.47s user 0.46s system 99% cpu 3.970 total
>
> zcat:
> best: 4.45s user 0.28s system 99% cpu 4.764 total
> worst: 4.99s user 0.57s system 99% cpu 5.568 total
>
>
> so i guess on os x there is still something to be optimized

Can you try it without write operation (comment out all write)? 
And than try it without uncompression?


// without compression:

void main(string[] args)
{
   auto f = File(args[1], "r");
   foreach (buffer; f.byChunk(4096))
   {
           write(cast(char[])buffer);
   }
}

// without write:

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

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


More information about the Digitalmars-d-learn mailing list