Repository navigation
factor: add benchmarks factoring many numbers in one invocation - #16439
Conversation
The existing benchmarks call uumain once per number, so they mostly measure the startup. These run one invocation over a few thousand numbers: small ones, the largest u64 values, the first values above 2^64 and products of two 31-bit primes.
Merging this PR will improve performance by ×3.21 warning
Performance Changes
Tip Curious why performance improved? Comment Comparing Footnotes
|
| .collect(); | ||
| let products = primes | ||
| .iter() | ||
| .flat_map(|&p| primes.iter().map(move |&q| p * q)) |
There was a problem hiding this comment.
this gives pp squares and both pq and q*p, and with take(500) p only goes over the first 16 primes. could you please only take pairs with p < q?
The products contained squares and both p*q and q*p, and only the first 16 primes were used as p.
80026ec to
42c0282
Compare
| /// above 2^31, where all the time goes into Pollard's rho. | ||
| #[divan::bench(sample_count = 10, sample_size = 1)] | ||
| fn factor_batch_of_semiprimes(bencher: Bencher) { | ||
| // The first primes above 2^31, 2^31 + 2^20, 2^31 + 2^21, ... |
There was a problem hiding this comment.
the starts are 2^31 + i * 2^20, the "2^21, ..." reads like powers of two. maybe write it that way?
|
Thanks for your PR |
Related to #1456.
The existing factor benchmarks call
uumainonce per number, so they mostly measure the startup. This adds four benchmarks that factor a few thousand numbers in one invocation: small numbers, the largest u64 values, the first values above 2^64 and products of two 31-bit primes.Separate from the factorization change so the benchmarks exist on main first.