Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Comparison QB64 compiled with gcc optimizations and without
#18
Code: (Select All)
' Speed Test for g++ optimization parameters
' modifies .\internal\c\makeline_win.txt (restores changes on exit)

o$ = "c_compiler\bin\g++ -s -Wfatal-errors -w -Wall qbx.cpp -lws2_32 -lwinspool parts\core\os\win\src.a "
o$ = o$ + "-lopengl32 -lglu32 -lwinmm -lgdi32 -mwindows -static-libgcc -static-libstdc++ -D GLEW_STATIC "
o$ = o$ + "-D FREEGLUT_STATIC -lksguid -lole32 -lwinmm -ldxguid -o ..\..\"

Shell "copy .\internal\c\makeline_win.txt .\internal\c\makeline_win.bak"

Open "sptest_t1.bas" For Output As #1
Do
    Read c$
    If c$ = "" Then Exit Do
    Print #1, c$
Loop
Close #1
Shell _Hide "copy sptest_t1.bas sptest_t2.bas"
Shell _Hide "copy sptest_t1.bas sptest_t3.bas"
Shell _Hide "copy sptest_t1.bas sptest_t4.bas"

m$(1) = "" '          no optimization
m$(2) = "-O2" '       oxygen
m$(3) = "-O3" '       ozone
m$(4) = "-Ofast" '    Lamborghini?

start_at = 2 '        skip NO optimization because it's a turkey

For pass = start_at To 4
    c$ = Left$(o$, 22) + m$(pass) + " " + Right$(o$, Len(o$) - 22)
    Open ".\internal\c\makeline_win.txt" For Output As #1
    Print #1, c$
    Close #1
    c$ = "qb64 -x sptest_t" + Chr$(48 + pass)
    Shell _Hide c$
    Shell _Hide "copy .\internal\c\makeline_win.bak .\internal\c\makeline_win.txt" '    restore file
    GoSub keycheck '                                                                    exit?
Next pass

Do
    best# = 99999
    For pass = start_at To 4
        start# = Timer '
        c$ = "sptest_t" + Chr$(48 + pass)
        Shell c$ '                                                                      run the test
        elapse# = Timer - start#
        If elapse# < best# Then best# = elapse#: bestpass = pass
        Print Using "####.##  "; elapse#;: Print m$(pass) '                             show the timing
        GoSub keycheck '
    Next pass
    count(bestpass) = count(bestpass) + 1
    For pass = start_at To 4
        Print Using "####  "; count(pass);
    Next pass
    Print Using "####  "; count(1) + count(2) + count(3) + count(4);
    Print
Loop

keycheck:
If _Exit Or Len(InKey$) Then
    Shell _Hide "del .\internal\c\makeline_win.bak"
    Shell _Hide "del sptest_t*.*"
    System
End If
Return

Data "Dim c(256) as _unsigned long"
Data "xm = 100: ym = 100"
Data "Screen _NewImage(xm, ym, 32)"
Data "_screenmove _desktopwidth-xm,0"
Data "x1 = -2: x2 = .6: y1 = -1.25: y2 = 1.25"
Data "xd = (x2 - x1) / xm: yd = (y2 - y1) / ym"
Data "c(0) = _RGB32(0, 0, 0)"
Data "For i = 1 To 31"
Data "c(i) = _RGB32(rnd*255,rnd*255,rnd*255)"
Data "Next i"
Data "For y = 0 To ym - 1"
Data "mandely = y1 + y * yd"
Data "For x = 0 To xm - 1"
Data "mandelx = x1 + x * xd"
Data "Itera = 5000: real = 0: imag = 0: size = -1"
Data "While (Itera > 0) And (size < 0)"
Data "Itera = Itera - 1"
Data "hold = imag"
Data "imag = (real * imag) * 2 + mandely"
Data "real = real * real - hold * hold + mandelx"
Data "size = (real * real + imag * imag) - 99"
Data "Wend"
Data "PSet (x, y), c(Itera Mod 32)"
Data "Next x"
Data "Next y"
Data "System"
Data ""
Reply


Messages In This Thread
RE: Comparison QB64 compiled with Ofast and without - by ChiaPet - 05-09-2022, 01:26 AM



Users browsing this thread: 46 Guest(s)