zlib performance
yawniek via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Fri Aug 7 00:48:24 PDT 2015
On Friday, 7 August 2015 at 07:43:25 UTC, Daniel Kozák wrote:
>> i don't understand why the program crashes when i do not do
>> the .dup
> This is weird. I would say it should not crash
exactely. but try it yourself.
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.
import
std.zlib,
std.file,
std.stdio;
void main(string[] args)
{
auto f = File(args[1], "rb");
auto uncompressor = new UnCompress(HeaderFormat.gzip);
foreach (ubyte[] buffer; f.byChunk(1024*1024*4))
{
auto uncompressed = cast(immutable(string))
uncompressor.uncompress(buffer.dup);
write(uncompressed);
}
}
More information about the Digitalmars-d-learn
mailing list