Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: Re: Optimizing Output

by ariels (Curate)
on Apr 15, 2002 at 12:54 UTC ( [id://159152]=note: print w/replies, xml ) Need Help??


in reply to Re: Optimizing Output
in thread Optimizing Output

"If, for some reason, you have to write to a file on an operating system that does no buffering, buffer yourself, and write large chunks."

This is odd. For this level of output, you're not looking so much at operating system buffering, but at the buffering your run-time environment provides. For Perl, this is given by the "normal" output functions (not sysread and syswrite). For C, this is e.g. the stdio.h functions. See K&R for details on how to implement putc and getc. It all happens in user space, not kernel space.

The vast majority of benefit from buffering comes from this application library level. In fact, the cited benchmarks say just that: switching off Perl's buffering (with $|=0) turns off this buffering; it doesn't do any hacking on obscure OS parameters. And doing it clobbers performance.


Juerd below is, of course, correct. You switch buffering off by making your output "piping hot": $|=1.

Replies are listed 'Best First'.
Re: Re: Re: Optimizing Output
by Juerd (Abbot) on Apr 15, 2002 at 13:06 UTC

    switching off Perl's buffering (with $|=0)

    The other way around. $| controls autoflush, the opposite of buffering.

    $| = 1; # Autoflush on, buffering off. $| = 0; # Autoflush off, buffering on. $|++; # $| = 1 $|--; # $| = !$| (flip setting 0/1)

    - Yes, I reinvent wheels.
    - Spam: Visit eurotraQ.
    

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://159152]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (8)
As of 2024-04-23 15:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found