Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re^4: Counting the number of items returned by split without using a named array

by Anonymous Monk
on May 03, 2006 at 15:16 UTC ( #547176=note: print w/replies, xml ) Need Help??


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 (Pope) 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

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://547176]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (6)
As of 2021-01-19 03:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Notices?