P is for Practical | |
PerlMonks |
xs outputs faster than perl can keep upby zentara (Archbishop) |
on Feb 05, 2007 at 22:08 UTC ( [id://598428]=perlquestion: print w/replies, xml ) | Need Help?? |
zentara has asked for the wisdom of the Perl Monks concerning the following question:
The node title suggests what I'm guessing the problem to be in this script. The xs portion of the script seems to output so fast, that newlines printed by Perl can't keep up, and the result is blocks of correct output, separated by blocks of newlines. This is a script which divides a sequence of numbers by pi, using very high precision, provided by syphilis 's nice port of the Multiple Precision Float Library , which is at Math-MPFR-1.10. I was making a comparison of speeds between c and Perl, and made 2 identical scripts, 1 c, and 1 Perl. The c script outputs as I expect, i.e 1 number per line. The Perl script outputs correct values, but the output comes in chunks of numbers, followed by chunks of newlines. If you look at the output loop, you can see that I print a newline after each number, but apperently Perl is saving them up and printing them all at once, instead of interleaving them into the output. This is totally bizarre behavior which I have never seen. Can anyone explain why Perl isn't immediately putting the newline out, before continuing the loop?
I'm not really a human, but I play one on earth. Cogito ergo sum a bum
Back to
Seekers of Perl Wisdom
|
|