zlib performance
yawniek via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Fri Aug 7 00:19:43 PDT 2015
hi,
unpacking files is kinda slow, probably i'm doing something wrong.
below code is about half the speed of gnu zcat on my os x machine.
why?
why do i need to .dup the buffer?
can i get rid of the casts?
the chunk size has only a marginal influence.
https://github.com/yannick/zcatd
import
std.zlib,
std.file,
std.stdio;
void main(string[] args)
{
auto f = File(args[1], "r");
auto uncompressor = new UnCompress(HeaderFormat.gzip);
foreach (ubyte[] buffer; f.byChunk(4096))
{
auto uncompressed = cast(immutable(string))
uncompressor.uncompress(buffer.dup);
write(uncompressed);
}
}
More information about the Digitalmars-d-learn
mailing list