Comparison QB64 compiled with gcc optimizations and without
#2
Fractal Tree : I got this code from the site rosettacode.

4.1x seconds : program compiled with qb64 -Ofast
6.1x seconds : program compiled with original qb64

it seems that there is an interesting gain when graphic commands like pset or line are used.

Code: (Select All)
_Title "Fractal Tree"
Const sw% = 640
Const sh% = 480

Screen _NewImage(sw, sh, 8)
_Delay 0.2
_ScreenMove _Middle

start = Timer(.001)
For i% = 1 To 1000
    Color (Rnd * 15)
    Call tree(sw \ 2, sh - 10, _Pi * 1.5, _Pi / 180 * 29, 112, 15)
Next i%
Print Timer(.001) - start; "seconds"
Sleep
System

Sub tree (x As Integer, y As Integer, initAngle As Double, theta As Double, length As Double, depth As Integer)
    Dim As Integer iL, newX, newY, iX, iY, iD
    iL = length: iX = x: iY = y: iD = depth
    newX = Cos(initAngle) * length + iX
    newY = Sin(initAngle) * length + iY
    Line (iX, iY)-(newX, newY)
    iL = length * .78
    iD = iD - 1
    If iD > 0 Then
        Call tree(newX, newY, initAngle - theta, theta, iL, iD)
        Call tree(newX, newY, initAngle + theta, theta, iL, iD)
    End If
End Sub
Reply


Messages In This Thread
RE: Comparison QB64 compiled with Ofast and without - by Coolman - 05-07-2022, 09:16 AM



Users browsing this thread: 18 Guest(s)