Matt Sergeant <[EMAIL PROTECTED]> writes:

> > -----Original Message-----
> > From: Doug MacEachern [mailto:[EMAIL PROTECTED]]
> > 
> > i'm guessing part of the difference in your code is due to 
> > fprintf having a pre-allocated buffer, whereas the SV's SvPVX 
> > has not been pre-allocated and gets realloc-ed each time you 
> > call sv_catpv.  have a look at the code below, fprintf is faster 
> > than sv_catpvn, but if the SvPVX is preallocated,
> > sv_catpvn becomes faster than fprintf:
> > 
> > timethese(1_000, {
> >     fprintf   => sub { TickTest::fprintf() },
> >     svcat     => sub { TickTest::svcat() },
> >     svcat_pre => sub { TickTest::svcat_pre() },
> > });
> > 
> > Benchmark: timing 1000 iterations of fprintf, svcat, svcat_pre...
> >    fprintf:  9 wallclock secs ( 8.72 usr +  0.00 sys =  8.72 
> > CPU) @ 114.68/s (n=1000)
> >      svcat: 13 wallclock secs (12.82 usr +  0.00 sys = 12.82 
> > CPU) @ 78.00/s (n=1000)
> >  svcat_pre:  2 wallclock secs ( 2.75 usr +  0.00 sys =  2.75 
> > CPU) @ 363.64/s (n=1000)
> 
> Very interesting. I'll try that (I wish you'd been listening to clp.mod when
> I posted - other perl gurus weren't much help).
> 
> Matt.

<OT type="rant"> 
IMO clp.mod is a sinkhole for perl-related discussions, and like
Abigail[1], despite its noble intentions I think clp.mod fails to 
serve the Perl community in any useful way.  IME, this mailing list (and 
p5p when appropriate) is one of the best places to ask about perl 
performance-related issues (that aren't covered by Stas' guide, 
of course :).  You could also don the high rubber boots and try 
clp.misc, which IMO seems to be a bit improved since the creation 
of the beginners' [2] mailing lists.

[1]: (long, unwrapped url)
  
http://groups.google.com/groups?hl=en&group=comp.lang.perl.misc&rnum=1&selm=slrn820ckc.ls3.abigail%40alexandra.delanet.com

  Personally I had similar experiences with clp.moderated, 
  so I don't read it anymore either.

[2]: IIRC, they are at
  http://learn.perl.org/

 but I can't connect to it at the moment.

</OT>

-- 
Joe Schaefer

Reply via email to