C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Multiprecision division

From: Hans Åberg <haberg_1_at_[hidden]>
Date: Fri, 8 Aug 2025 17:56:54 +0200
I put them in an array, optionally check that all functions produce the same value, and then time the functions I want to test using the same table, with a computed hash value to prevent the computed values from being optimized away. I can also repeat the test to see the difference between different array values. If the table is sufficiently large, 10–80 million, there is not so much difference between runs.

This method is also good to detect issues, or special values, which can be put into the table and run the same every time. I use it mainly for debugging, but it can also be used for timing, especially if one wants to check different code variants.


> On 8 Aug 2025, at 17:23, Tiago Freire <tmiguelf_at_[hidden]> wrote:
>
> I would not try to measure with random divisions unless the random is pre-generated and is the exact same numbers on every test.
> The amount of time a division takes to complete can vary depending on the input.
> You may not actually be measuring the compiler difference on this particular function so much as you are measuring a bias in your random number generator.

Received on 2025-08-08 15:57:10