Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
Here's a benchmark for Math::Big::Factors wheels of orders 5-7:
Rate 7 6 5 7 34.1/s -- -95% -100% 6 627/s 1739% -- -94% 5 9770/s 28548% 1458% --
and for factors_wheel of numbers near 32 bits, using an order 7 wheel:
s/iter 4294967291 4294967293 4294967295 4294967291 4.45 -- -61% -71% 4294967293 1.74 156% -- -25% 4294967295 1.31 241% 33% --
Note that 4294967291 is prime, 4294967293 has 2 large factors, and 4294967295 has 5 factors, the largest of which is 2**16+1.

For 4294967291, and wheel orders 5-7:

s/iter 7 5 6 7 4.44 -- -16% -21% 5 3.71 19% -- -6% 6 3.49 27% 6% --
In all fairness, I should probably mention that I've customized my own version of Math::Big::Factors to Memoize results where possible, and to reduce the calls to Math::BigInt::new() for constants.

Note that factors_wheel creates a new wheel every time (what a shame), instead of requiring a wheel reference be passed in. Caching wheel goes a little way in correcting this, without changing the interface.

You might also consider avoiding the use of Math::BigInt where possible, as you don't need numbers that big.

Now, back to the question at hand. For numbers near 2**32, factoring a prime number seems to take 150 times longer than creating the order 7 wheel. Creating the order 6 wheel is considerably faster, and so is the factoring based on that wheel.

I'm not sure where the breakpoint is for order 7 wheels. A casual search hints that it is very large.

Quantum Mechanics: The dreams stuff is made of

In reply to Re^5: Algorithm for cancelling common factors between two lists of multiplicands by QM
in thread Algorithm for cancelling common factors between two lists of multiplicands by BrowserUk

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?

    What's my password?
    Create A New User
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others studying the Monastery: (4)
    As of 2020-08-14 05:30 GMT
    Find Nodes?
      Voting Booth?
      Which rocket would you take to Mars?

      Results (75 votes). Check out past polls.