Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Comparison QB64 compiled with gcc optimizations and without
#30
I found this code in the old forum apparently created by SMcNeill. Here, the interest is to see the difference in processing speed between the version of QB64 compiled in -O3 and the original version :

13.2x seconds : program compiled with qb64 -O3
26.2x seconds : program compiled with original qb64

Code: (Select All)
Screen _NewImage(1280, 720, 32)
_Delay 0.2
_ScreenMove _Middle
Dim Shared Primes(1500000) As Long, count As Long
DefLng A-Z
Dim Shared Factors(10000000) As Long
Primes(0) = 2
Print "One moment.... finding primes"
start = Timer(.001)
For i = 3 To 1000000 Step 2
    FindPrime (i)
Next
Print: Print "There are "; count; " numbers which are prime that can go into our numbers as factors"
Print
For i = 123456789 To 123456819
    FindFactor (i)
Next
Print: Print "FINISHED IN "; Timer(.001) - start; "seconds"
End
Sub FindFactor (num)
    Print num; "=";
    Do
        For i = 0 To count
            p = Primes(i)
            If p >= Sqr(num) Then Exit Do
            If num Mod p = 0 Then 'it divides
                Print p; "x";
                num = num / p
                Exit For
            End If
        Next
    Loop Until num = 1
    Print num
End Sub
Sub FindPrime (num)
    For i = 0 To count
        If num Mod Primes(i) = 0 Then Exit Sub
    Next
    count = count + 1
    Primes(count) = num
End Sub
Reply


Messages In This Thread
RE: Comparison QB64 compiled with Ofast and without - by Coolman - 05-13-2022, 06:34 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  niXman gcc-13.1.0 Jack 8 1,851 10-04-2023, 12:51 PM
Last Post: a740g
  BASIC's Comparison Matrix: ideas for content? CharlieJV 28 6,721 10-03-2022, 01:27 AM
Last Post: CharlieJV
  String comparison oddity...[SOLVED] Pete 6 1,292 08-05-2022, 07:16 PM
Last Post: Pete
  Found a BUG with the QB64 editor compiled with the -O3 option Coolman 2 826 06-02-2022, 06:27 PM
Last Post: Coolman

Forum Jump:


Users browsing this thread: