Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Comparison QB64 compiled with gcc optimizations and without
#72
i found this code here :

https://github.com/nsiatras/programming-...-benchmark

Code: (Select All)
Dim fCount As Integer
fCount = 1024
Dim fArrayA(fCount, fCount) As Double
Dim fArrayB(fCount, fCount) As Double
Dim fArrayC(fCount, fCount) As Double
Dim benchmarkTests As Integer
Dim i As Integer, j As Integer, k As Integer
Dim tmp As String
Dim StartTime As Double, EndTime As Double
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

Print "Matrix Multiplication Benchmark started. Please wait..."

StartTime = Timer

For benchmarkTests = 0 To 4
    ' Add random values to Arrays A and B (0 to 1)
    For i = 0 To fCount - 1
        For j = 0 To fCount - 1
            fArrayA(i, j) = Rnd
            fArrayB(i, j) = Rnd
            fArrayC(i, j) = 0
        Next j
    Next i

    ' Multiply A to B values and add them to C
    For i = 0 To fCount - 1
        For j = 0 To fCount - 1
            For k = 0 To fCount - 1
                fArrayC(i, j) = fArrayC(i, j) + (fArrayA(i, k) * fArrayB(k, j))
            Next k
        Next j
    Next i
Next benchmarkTests

EndTime = Timer

Print "Matrix Multiplication Benchmark finished in: "; (EndTime - StartTime); " seconds"
Print "Press any key to exit"
Sleep

compiled with Freebasic -gen gas64
Free Basic Matrix Multiplication Benchmark finished in: 63.6x seconds
executable size : 65,4 Kio

compiled with Freebasic -gen gcc -Wc -Os
Free Basic Matrix Multiplication Benchmark finished in: 40.0x seconds
executable size : 65,3 Kio

compiled with Freebasic -gen gcc -Wc -O3
Free Basic Matrix Multiplication Benchmark finished in: 39.8x seconds
executable size : 65,3 Kio

---

I tested the source code in C and in freepascal. results :

C optimization -Os
Matrix Multiplication Benchmark finished in 15.744985 seconds
executable size : 16,6 Kio
C without optimization
Matrix Multiplication Benchmark finished in 71.999291 seconds
executable size : 16,6 Kio

FreePascal activation optimization -O2
Matrix Multiplication Benchmark finished in: 44.972 seconds
executable size : 547,9 Kio
FreePascal without optimization
FreePascal Matrix Multiplication Benchmark finished in: 56.339 seconds
executable size : 547,9 Kio

---

compiled with qb64pe v3.1.0 original
144.2x seconds - executable size : 1016,8 Kio

compiled with qb64pe v3.1.0 -Os
64.0x seconds - executable size : 727,7 Kio

compiled with qb64pe v3.1.0 -O3
56.4x seconds - executable size : 947,7 Kio

the code generated by freebasic is more efficient than qb64pe. that's why the speed difference is so big. i noticed it before when testing console programs. freebasic programs are clearly faster, lighter and compile extremely fast. qb64pe keeps the advantage of the built-in editor, the syntax is easier and the code writing is faster. but the most important advantage of qb64pe is the license which is totally free without any restriction. the maintainers continue with version 3.1.0 to improve this point.
Reply


Messages In This Thread
RE: Comparison QB64 compiled with gcc optimizations and without - by Coolman - 09-12-2022, 11:36 AM



Users browsing this thread: 2 Guest(s)