stdio performance in tango, stdlib, and perl

Andrei Alexandrescu (See Website For Email) SeeWebsiteForEmail at erdani.org
Thu Mar 22 09:16:43 PDT 2007


kris wrote:
> torhu wrote:
>> torhu wrote:
>> <snip>
>>
>>> Fastest first:
>>>
>>> tango.io.Console, no flushing (Andrei's): ca 1.5s
>>>
>>> C, reusing buffer, gcc & msvc71: ca 3s
>>>
>>> James' C++, gcc: 3.5s
>>>
>>> Phobos std.cstream, reused buffer: 11s
>>>
>>> C w/malloc and free each line, msvc71: 23s
>>>
>>> Andrei's C++, gcc: 27s
>>>
>>> C w/malloc and free each line, gcc: 37s
>>>
>>> Andrei's C++, msvc71: 50s
>>>
>>> James' C++,  msvc: 51s
>>
>>
>> I've run some of the tests with more accurate timing. Andrei's Tango 
>> code uses 0.9 seconds, with no flushing, and 1.6 seconds with 
>> flushing.  I also tried cat itself, from the gnuwin32 project.  cat 
>> clocks in at 1.3 seconds.
> 
> 
> Just for jollies, a briefly optimized tango.io was tried also: it came 
> in at around 0.7 seconds. On a tripled file-size (3 million lines), that 
> version is around 23% faster than bog-standard tango.io

That's great news!

> Thanks for giving it a whirl, tohru :)
> 
> 
> p.s. perhaps Andrei should be using tango for processing those vast 
> files he has?

Is it compatible with C's stdio? IOW, would this sequence work?

readln(line);
int c = getchar();

Is 'c' the first character on the next line?


Andrei



More information about the Digitalmars-d mailing list