QB64 Phoenix Edition
Comparison QB64 compiled with gcc optimizations and without - Printable Version

+- QB64 Phoenix Edition (https://qb64phoenix.com/forum)
+-- Forum: Chatting and Socializing (https://qb64phoenix.com/forum/forumdisplay.php?fid=11)
+--- Forum: General Discussion (https://qb64phoenix.com/forum/forumdisplay.php?fid=2)
+--- Thread: Comparison QB64 compiled with gcc optimizations and without (/showthread.php?tid=366)

Pages: 1 2 3 4 5 6 7 8


RE: Comparison QB64 compiled with Ofast and without - Coolman - 09-06-2022

(09-06-2022, 03:23 PM)Jack Wrote: Bucket Sort times
-O2 .88 sec
-O3 .7 sec
-Os .72 sec
keep in mind that timing differences between O levels may differ for different programs, sometimes -O2 is best and sometimes -Os

yes, that's why -Os is the right compromise.


RE: Comparison QB64 compiled with gcc optimizations and without - Coolman - 09-12-2022

i found this code here :

https://github.com/nsiatras/programming-languages-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.


RE: Comparison QB64 compiled with gcc optimizations and without - Jack - 09-12-2022

my times
compiled with Freebasic -gen gcc -Wc -Os
Free Basic Matrix Multiplication Benchmark finished in: 11 seconds

compiled with qb64pe v3.1.0 -Os
45 seconds
Coolman, what CPU do you have, Intel or AMD?
mine is Intel


RE: Comparison QB64 compiled with gcc optimizations and without - Coolman - 09-12-2022

(09-12-2022, 01:31 PM)Jack Wrote: my times
compiled with Freebasic -gen gcc -Wc -Os
Free Basic Matrix Multiplication Benchmark finished in: 11 seconds

compiled with qb64pe v3.1.0 -Os
45 seconds
Coolman, what CPU do you have, Intel or AMD?
mine is Intel

thanks for providing another point of comparison. you have a much faster computer than mine.

i was going to ask you the same question. i have a laptop with an i7-8550U processor. what processor do you have?


RE: Comparison QB64 compiled with gcc optimizations and without - Jack - 09-12-2022

my CPU is an Intel(R) Core(TM) i9-9900K CPU @ 3.60GHz, 3600 Mhz, 8 Core(s), 16 Logical Processor(s)
however, the CPU speed varies depending on load, it throttles up and down all the time usually between 800 and 5000 MHz


RE: Comparison QB64 compiled with gcc optimizations and without - Coolman - 09-12-2022

you have an excellent processor. the results should be better. under linux there are utilities to block the processor frequency to the maximum temporarily. i haven't tried it because i use a laptop but on a desktop it would be interesting to see when testing.


RE: Comparison QB64 compiled with gcc optimizations and without - Jack - 09-12-2022

there's no need to lock the speed, whenever I run a CPU intensive program it speeds up to 5GHz and remains at that speed until the program ends, locking the speed at 5GHz would severely shorten it's life


RE: Comparison QB64 compiled with gcc optimizations and without - Coolman - 09-20-2022

I have some free time. I have added the test of the C and freepascal source code located here :

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

if anyone is interested. see here :

https://qb64phoenix.com/forum/showthread.php?tid=366&pid=6535#pid6535