Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: Efficient bit-twiddling in Perl.

by salva (Abbot)
on Feb 28, 2013 at 15:17 UTC ( #1021066=note: print w/ replies, xml ) Need Help??


in reply to Efficient bit-twiddling in Perl.

Not a big improvement, but you can eliminate the AND operation when calculating $top14.

If you have to do that millions of times, you can try building a table for the combined three 6bit quantities:

my @table; $table[$_] = [..., ..., ...] for 0..0x0003ffff; ... for my $n (...) { my $top = $n >> 18; my ($nxt, $mid, $bot) = @{$table[$n & 0x0003ffff]}; ... }


Comment on Re: Efficient bit-twiddling in Perl.
Select or Download Code
Re^2: Efficient bit-twiddling in Perl.
by BrowserUk (Pope) on Feb 28, 2013 at 19:13 UTC
    you can try building a table for the combined three 6bit quantities:

    The lookup table gains about 20%. Less than I expected, but worth having. Thank you.


    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
Node Status?
node history
Node Type: note [id://1021066]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (9)
As of 2015-07-04 10:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (59 votes), past polls