Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Shifting versus Mutliplying
#3
(03-11-2024, 03:57 AM)DSMan195276 Wrote: Functionally speaking a regular `* 4` with a constant 4 should not be faster than `_SHL`. The C++ compiler is smart enough to simply use a left shift to implement multiplication when it's a power of two, you don't have to use `_SHL`. The benefits come when the shift value is not a constant, in that case the compiler cannot optimize the multiplication.

For your test code, I think the general issue is that `TIMER(.001)` is significantly more expensive than the single shift you're doing, I would expect any kind of fluctuation to be more related to `TIMER(.001)`s performance than anything else. Instead of looping for a set amount of time, you should instead try performing a set number of `_SHL` or `* 4` commands (ex. 1 million of them) and then measure how long it takes to execute all of them by calling `TIMER(.001)` at the start and end.

(03-11-2024, 03:36 AM)TerryRitchie Wrote: Also, has anyone else noticed that the 3.12.0 IDE flickers occasionally when not using it (not the active window)? As I am writing this text into the forum it's flickering now and then. This also happens when I run code and press keys while the code is running, the IDE flickers in the background.
I have not heard about that, but I'll keep an eye out, that sounds odd.
Thanks for the reply. I'll rework the code to keep TIMER out of the loops.

The flickering is the line numbers on the left hand side highlighting very briefly along with the highlight bar (the current line the cursor is on). It's as if the IDE is becoming the active window for very brief periods of time. This only happens when typing on the keyboard.
New to QB64pe? Visit the QB64 tutorial to get started.
QB64 Tutorial
Reply


Messages In This Thread
Shifting versus Mutliplying - by TerryRitchie - 03-11-2024, 03:36 AM
RE: Shifting versus Mutliplying - by DSMan195276 - 03-11-2024, 03:57 AM
RE: Shifting versus Mutliplying - by TerryRitchie - 03-11-2024, 04:19 AM
RE: Shifting versus Mutliplying - by TerryRitchie - 03-11-2024, 04:34 AM
RE: Shifting versus Mutliplying - by a740g - 03-11-2024, 05:16 AM
RE: Shifting versus Mutliplying - by DSMan195276 - 03-11-2024, 06:21 AM
RE: Shifting versus Mutliplying - by Kernelpanic - 03-11-2024, 12:28 PM
RE: Shifting versus Mutliplying - by mcalkins - 05-05-2024, 11:51 PM



Users browsing this thread: 3 Guest(s)