Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Shifting versus Mutliplying
#7
@Terry - I changed the program slightly to compare the times and added a termination condition. Hope you don't mind.

Flickering: Maybe the IDE under QB 3.12 requires more memory, or generally requires more performance?

Code: (Select All)

'Geschwindigkeitstest fuer Bilderverschieben, Terry - 11. Maerz 2024

Option _Explicit

Dim x As Integer
Dim y As Integer
Dim i As Long
Dim t As Double
Dim t1 As Double
Dim t2 As Double
Dim As Integer z

Locate 2, 2
Print "Shows how long it takes for 1 billion shifts "
Locate 3, 2
Print "with multiplication or shift."
Locate 5, 2

z = 0
x = 4
Do
  i = 0
  t = Timer(.001)
  Do
    y = x * 4
    i = i + 1
  Loop Until i = 1000000000 ' a billion times
  t1 = Timer(.001) - t

  i = 0
  t = Timer(.001)
  Do
    y = _ShL(x, 2)
    i = i + 1
  Loop Until i = 1000000000
  t2 = Timer(.001) - t

  Beep
  'Cls
  Print
  Print Using " #.### --> Multiplying"; t1
  Print Using " #.### --> Shiting left"; t2
  Locate CsrLin + 1, 2

  z = z + 1
Loop Until z = 4

End

[Image: Bildverschiebung-Zeitdauer2024-03-11.jpg]
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: 4 Guest(s)