TROGDOR has asked for the wisdom of the Perl Monks concerning the following question:
Greetings fellow monks,
I am a strong advocate of perl, so I was very disappointed today when I ran some disk benchmarks and found that perl disk IO seems to be very slow.
I'm writing a gds parser. gds is a binary file format that defines a microchip layout. I wrote a very simple perl script for benchmark testing that just opens the file and reads it in using read commands, without actually doing anything with the data. The code is included below.
This script processes 10 megs of data per second. An equivalent C program that does the exact same thing processes 50 megs of data per second. Why is perl's IO so slow, and is there anything I can do to improve it? Is there an IO module with a more efficient implementation?
Thanks,
TROGDOR
I am a strong advocate of perl, so I was very disappointed today when I ran some disk benchmarks and found that perl disk IO seems to be very slow.
I'm writing a gds parser. gds is a binary file format that defines a microchip layout. I wrote a very simple perl script for benchmark testing that just opens the file and reads it in using read commands, without actually doing anything with the data. The code is included below.
This script processes 10 megs of data per second. An equivalent C program that does the exact same thing processes 50 megs of data per second. Why is perl's IO so slow, and is there anything I can do to improve it? Is there an IO module with a more efficient implementation?
Thanks,
TROGDOR
open (FILE, "$path") or die "ERROR: Could not open $path.\n"; while (1) { $eof = read (FILE, $header, 4); ($size, $code, $ftype) = unpack ("nCC", $header) ; if ($size == 0) { print "Size is zero. Exiting.\n"; last; } $size = $size - 4; if ($size > 0) { $eof = read (FILE, $data, $size); } } close FILE;
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Perl's poor disk IO performance
by moritz (Cardinal) on Apr 29, 2010 at 19:29 UTC | |
Re: Perl's poor disk IO performance
by BrowserUk (Patriarch) on Apr 29, 2010 at 19:57 UTC | |
Re: Perl's poor disk IO performance
by roboticus (Chancellor) on Apr 29, 2010 at 21:33 UTC | |
Re: Perl's poor disk IO performance
by Marshall (Canon) on Apr 29, 2010 at 23:43 UTC | |
by BrowserUk (Patriarch) on Apr 30, 2010 at 00:20 UTC | |
by Marshall (Canon) on Apr 30, 2010 at 19:27 UTC | |
Re: Perl's poor disk IO performance
by snoopy (Curate) on Apr 29, 2010 at 23:09 UTC | |
Re: Perl's poor disk IO performance
by Anonymous Monk on Dec 31, 2010 at 00:20 UTC | |
Re: Perl's poor disk IO performance
by kikuchiyo (Hermit) on Apr 30, 2010 at 14:26 UTC |
Back to
Seekers of Perl Wisdom