Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Re: Believably slow..

by aquarium (Curate)
on Jun 25, 2003 at 13:55 UTC ( [id://268856]=note: print w/replies, xml ) Need Help??


in reply to Unbelievably slow..

i found the culprit operation which costs the most time:
if($num & $shift)
i'd say it's to do with having to add so many bits to $shift once $num starts to skyrocket. It should have been implemented in binary/packed format of same size bit patterns. btw: you can reduce the use of huge numbers to start with by generating that same bit pattern (1..24), repeating it, and just adding leftmost 1 bits as required. you can also precalc the "anded" values and leave out the & altogether. and with the other fixes to make it more perlish (the for loops), the prog should run in the order of a couple of minutes max. i got 6 minutes just by taking out the "if($num & shift)" and the "else"

Replies are listed 'Best First'.
Re: Re: Believably slow..
by kiat (Vicar) on Jun 26, 2003 at 10:06 UTC
    When you left out if($num and $shift), did you get 187692 as the computed value? That the number it should print when the computation is done.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (2)
As of 2024-04-25 22:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found