Liste des Groupes | Revenir à se design |
On Fri, 1 Nov 2024 16:03:00 -0700, Don Y <blockedofcourse@foo.invalid>Most compilers these days are smart enough to move loop invariants outside of a loop and then dispose of the loop. You must have side effects in any code that you want to benchmark. Optimisers can be *really* smart about rearranging code for maximum performance by avoiding pipeline stalls. Only the very best humans can match them now.
wrote:
On 11/1/2024 3:50 PM, Nick Hayward wrote:We want to time the execution of a control algorithm. One way to timeWhat about C++?>
C++ is an order of magnitude more complex than C. Even a
casual C programmer can imagine what his code will look
like after compilation. I.e., can imagine exactly what the
CPU will be doing (ignoring the fact that the compiler will
often out-think the coder in terms of time/space efficiency).
it is to run it in a loop maybe 100K times and measure that with a
stopwatch. But a very smart compiler might run it once, notice that
nothing has changed, and skip the reruns.
It's best to bang a port pin and measure it with an oscilloscope.If the compiler can see that is true you could still get caught out.
We've had FPGA compilers do that sort of thing, optimize out
intentional delays. One fix is to XOR signals with a level from a pin
that *we* know is always low.
Les messages affichés proviennent d'usenet.