Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
Well, yet again I've posted as the AM by mistake, and cannot edit my node:( So, one correction, everywhere I wrote String::IO, that should of course be IO::String.

Now, here's the benchmarks...

Benchmark: timing 10000 iterations of fifo, perlio, string...
      fifo:  8 wallclock secs ( 7.52 usr +  0.00 sys =  7.52 CPU) @ 1329.79/s (n=10000)
    perlio:  1 wallclock secs ( 0.73 usr +  0.00 sys =  0.73 CPU) @ 13698.63/s (n=10000)
    string: 15 wallclock secs (14.82 usr +  0.01 sys = 14.83 CPU) @ 674.31/s (n=10000)
          Rate string   fifo perlio
string   674/s     --   -49%   -95%
fifo    1330/s    97%     --   -90%
perlio 13699/s  1932%   930%     --
the code: ------- package fifo; # note: this was just a work in progress, now abandoned # and never to be finished, so it's still somewhat crude. use base 'Tie::Handle'; use Symbol (); sub new { my $class = shift; my $self = bless Symbol::gensym(), ref($class) || $class; tie *$self, $self; $self->open(@_); $self; } sub open { my $self = shift; return $self->new(@_) unless ref($self); *$self->{contents} = []; return $self; } sub TIEHANDLE { return $_[0] if ref($_[0]); my $self = bless Symbol::gensym(), $_[0]; $self->open(@_); return $self; } sub PRINT { my $self = shift; push( @{*$self->{contents}}, split( /^/om, join( '', (pop @{*$self->{contents}} || '', @_) ) ) ); } sub PRINTF { my $self = shift; my $fmt = shift; $self->PRINT(sprintf($fmt, @_)); } sub READLINE { return $_[0]->readlines() if wantarray; return shift(@{*{$_[0]}->{contents}}); } sub readlines { my $contents = *{$_[0]}->{contents}; *{$_[0]}->{contents} = []; return @$contents; } sub EOF { return not (scalar @{*{$_[0]}->{contents}}); } 1; ------------ #!/usr/bin/perl use fifo; use IO::String; my $fh1 = fifo->new(); my $fh2 = IO::String->new(); my $fh3; my $buf = ''; open($fh3, "+<", \$buf); sub foo { for (1..10) { print $fh1 "xxxx\n"; } while (<$fh1>) { # print; } } sub bar { for (1..10) { print $fh2 "xxxx\n"; } $fh2->pos(0); while (<$fh2>) { # print; } $fh2->pos(0); } sub baz { for (1..10) { print $fh3 "xxxx\n"; } seek($fh3, 0, 0); while (<$fh3>) { # print; } seek($fh3, 0, 0); } use Benchmark qw(cmpthese); cmpthese ( 10000, { fifo => \&foo, string => \&bar, perlio => \&baz, } );
-- O thievish Night, Why should'st thou, but for some felonious end, In thy dark lantern thus close up the stars? --Milton

In reply to Re: Re: perl 5.8.0 perlio by Felonious
in thread perl 5.8.0 perlio by Anonymous Monk

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?

    What's my password?
    Create A New User
    [tye]: I don't know if you can just dismount, but I thought so.
    [davido]: yeah, umount -f isn't powerful enough.
    [tye]: probably something in the init subsystem that does the mounting that you could disable and reboot.
    davido needs to close laptop to board flight home from yapc.
    [davido]: I'll look into it in a few hours probably.
    [davido]: when i do get to that point I think I'll do it in a vm snapshot just in case. :)
    [oiskuu]: tye, you were right: loginuid/sessionid are part of task struct if compiled with AUDITSYSCALL. I have some doubts if you should actually depend on that feature.
    [Corion]: oiskuu: Depends on what you want to do with that information
    [tye]: I'm not depending on that feature. But I could in this environment. I'm using getlogin(). shrug
    [Corion]: For benign logging (which user started this DB instance), it's OK

    How do I use this? | Other CB clients
    Other Users?
    Others taking refuge in the Monastery: (5)
    As of 2017-06-23 20:06 GMT
    Find Nodes?
      Voting Booth?
      How many monitors do you use while coding?

      Results (555 votes). Check out past polls.