stdio performance in tango, stdlib, and perl

torhu fake at address.dude
Thu Mar 22 16:53:41 PDT 2007


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.

Couple of more results:

ActiveState Perl 5.8.8: 3.8s.
Python 2.5: 3.6s.


cat.py:
---
#!/usr/bin/env python
import sys
sys.stdout.writelines(sys.stdin.xreadlines())

# to process each line:
#sys.stdout.writelines(do_stuff_with_each_line(sys.stdin.xreadlines()))
# possibly slower:
#sys.stdout.writelines(do_stuff_with_each_line(s) for s in sys.stdin)
---

cat.pl:
---
#!/usr/bin/env perl
while (<>) {
    print;
}
---

I guess that's enough benchmarking for now.



More information about the Digitalmars-d mailing list