in reply to Re^3: Counting the number of items returned by split without using a named array
in thread Counting the number of items returned by split without using a named array

Strange
perhaps it depends on the length of the input string?
My attempt shows a different result
You seem to be under windows - so just for comparison:
$ cat a.pl; echo '-----------' ;echo;./a.pl #!/usr/local/bin/perl -w use Benchmark qw(:all) ; our $s = join ' ', 'aa'..'zz';; cmpthese( -3, { split => q[ $_=$s; my $n = @{[ split ]}; ], regex => q[ $_=$s; my $n = () = /\S+/g; ] }); ----------- Rate regex split regex 981/s -- -53% split 2098/s 114% --

Hm, now where's the big diff to the other Bench?
I.
  • Comment on Re^4: Counting the number of items returned by split without using a named array
  • Download Code

Replies are listed 'Best First'.
Re^5: Counting the number of items returned by split without using a named array
by BrowserUk (Patriarch) on May 03, 2006 at 16:34 UTC
    Hm, now where's the big diff to the other Bench?

    Try switching warnings on in your first benchmark. It will probably explain the difference :)


    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.
      Ok, I see :)
      That could explain it *g*

      I.

Re^5: Counting the number of items returned by split without using a named array
by Anonymous Monk on May 03, 2006 at 15:20 UTC
    Argh... Link went wrong :( meant to link to the other benchmark above: http://www.perlmonks.org/?node_id=547169