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.


From: Std-Proposals <std-proposals-bounces@lists.isocpp.org> on behalf of Hans Åberg via Std-Proposals <std-proposals@lists.isocpp.org>
Sent: Friday, August 8, 2025 2:31:51 PM
To: Oliver Hunt <oliver@apple.com>
Cc: Hans Åberg <haberg_1@icloud.com>; std-proposals@lists.isocpp.org <std-proposals@lists.isocpp.org>
Subject: Re: [std-proposals] Multiprecision division


> On 7 Aug 2025, at 23:25, Oliver Hunt <oliver@apple.com> wrote:
>
> You are making the claim that std::span introduces overhead that is not present if the API uses raw pointers.
>
> I just provided you an example showing that the code generation is _identical_.

There is 9–10% overhead with std::span relative to using clang O3 in some 10 million random division runs of the function “div32” calling the “div” function I mentioned. Somewhat less with g++ O3, but it has somewhat worse absolute timings on the “without” variation.

--
Std-Proposals mailing list
Std-Proposals@lists.isocpp.org
https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals