Re: Perl Quiz of the Week #23

Kurt Starsinic <[email protected]>
Newsgroups gmane.comp.lang.perl.qotw.discuss
Message-ID <[email protected]>
On Fri, 03 Sep 2004 09:47:29 -0400, Mark Jason Dominus <[email protected]> wrote:
> [email protected] (Kurt Starsinic):
> >     % time parens 12 > /dev/null
> >     real    0m4.541s
> >     user    0m4.460s
> >     sys     0m0.012s
> >
> >     The "tail" version has to generate all the output, it just doesn't
> > have to display most of it to the s*l*o*w tty.  Interestingly, the
> > "/dev/null" version isn't that much faster, which reinfoces the idea
> > that the slowness isn't in the I/O subsystem per se, but rather in the
> > tty driver specifically.
> 
> I don't think the > /dev/null version is using the TTY driver.  Why
> would it be?

    Ah, I see that I was unclear.  I'm not implying that the /dev/null
version is using the tty driver.  I'm pointing out that the difference
in times between [sending output to a pipe, where the data actually
has to travel end-to-end, but most of it never touches a tty] and
[sending output to /dev/null, where the data gets copied into the
kernel and thrown away (thus circumventing slightly more than half of
the I/O subsystem)] is very small, which suggests that the I/O
subsystem in and of itself isn't a major contributor to overall
runtime.

> I guess that you will not see much decrease in time if you remove the
> printing from your program.

    Exactly:
        % time parens_no_output 12
        real    0m4.252s
        user    0m4.200s
        sys     0m0.012s

    - Kurt
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.