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

Re^4: using bits to print part of a string (Bitops win by an order of magnitude)

by McA (Priest)
on Mar 17, 2013 at 00:17 UTC ( [id://1023860]=note: print w/replies, xml ) Need Help??


in reply to Re^3: using bits to print part of a string (Bitops win by an order of magnitude)
in thread using bits to print part of a string

Hi,

why have you thrown my regex solution out of the race? :) I've been interested to see it in your benchmark.

McA

  • Comment on Re^4: using bits to print part of a string (Bitops win by an order of magnitude)

Replies are listed 'Best First'.
Re^5: using bits to print part of a string (Bitops win by an order of magnitude)
by BrowserUk (Patriarch) on Mar 17, 2013 at 04:01 UTC

    sub { printf 'regex: '; my $mask = shift; my $re = '^' . join('', map $_ ? '(.)' : '.', split '', $mask +) . '$'; return sub { my $fh = shift; my $out; my $count = 0; $out = join( '', m[$re]o ), ++$count while <$fh>; $count; } }, __END__ C:\test>1023727 -OPT=4 regex: Took 274.157906 seconds for 2606 records (9.505471 recs/second)

    With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.

      Ok, ok, ok, now I know why you kicked it out. ;-)

      Anyway, thank you for giving it a try. The only thing I've seen for improvment is to build the regex like some of the other solutions, so not every hit character is a regex pattern, but consecutive characters build one regex.

      Investigating this rises a point of criticism in your benchmark: You don't have one mask for all tests. And the way some solutions depend on the pattern of the mask has an influence on the performance, e.g. Think of the substrref solution with a pattern '1' x 400_000.

      Have a nice sunday
      McA

        You don't have one mask for all tests.

        Sorry, but you are mistaken. The srand $S ensures that the same mask is built for each run.

        You can change it using sommand line arg -S=nn, but so long as you use the same value for each run (1 by default) then the same mask will be generated for each test.


        With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
        Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
        "Science is about questioning the status quo. Questioning authority".
        In the absence of evidence, opinion is indistinguishable from prejudice.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (6)
As of 2024-04-25 15:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found