[PLUG] Re: Perl
Wil Cooley
wcooley at nakedape.cc
Sat Jul 8 04:17:42 UTC 2006
On Fri, 2006-07-07 at 18:02 -0700, Rogan Creswick wrote:
> <snip>
>
> > cmpthese -1, {
> > split_re_dot => sub { my @x = split /\./, $string_to_split; return; },
> > split_ch_dot => sub { my @x = split '.', $string_to_split; return; },
> > };
>
> Part of the reason you may be seeing such a difference in performance
> is that those two commands don't do the same thing... The second one
> will split on every character, unless I'm mistaken.
Yeah, you're right. Changing the second to '\.' yields pretty much the
same performance as /\./:
Timing splitting of 'a.b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y.z'...
Rate split_re_dot split_ch_dot
split_re_dot 44383/s -- -1%
split_ch_dot 44823/s 1% --
That's not what I'd expect, though--I'd expect a literal string to be
treated as if all regex metacharacters were escaped (which was, in fact,
part of my motivation for using a string instead of a pattern to begin
with).
Oh well; live and learn.
Wil
--
Wil Cooley <wcooley at nakedape.cc>
Naked Ape Consulting, Ltd. <http://nakedape.cc>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
URL: <http://lists.pdxlinux.org/pipermail/plug/attachments/20060707/85687d10/attachment.asc>
More information about the PLUG
mailing list