Mandelbrot speed test - PB shifts some
When doing speed test, you need to respect the original benchmarks. All are in windowed mode, so doing it too. Just changing this gains about 100 kpx/sec. Also, the VC.net and VB example aren't double buffered, which is not the same at all (but I can't change them). Writing on a visible video surface is more restrictive than writing on a backbuffer. On the final test, PB is around 700 kpix/secs when GLbasic is 600 kpix/sec. There is some strange line on the PB example, may be a computation is wrong too.
Code: Select all
; --------------------------------- ;
; Project: Mandelbrot - Speedtest
; Start: Tuesday, September 09, 2003
; PB Version: 3.90
; Based on GLBasic code at http://www.glbasic.com/en/download.html
; Converted by Ged Byrne
#max.f = 128 ; #max iterations
#x1 = 640 ; ScreenX
#y1 = 480 ; ScreenY
xstart.f = -2.025
ystart.f = -1.125
xende.f = 0.6
yende.f = 1.125
xzoom.f = (xende - xstart) / #x1
yzoom.f = (yende - ystart) / #y1
fac.f = 0.99
Procedure HSB2RGB(hue.f, saturation.f, brightness.f)
If brightness = 0
ProcedureReturn 0
EndIf
If saturation = 0
ProcedureReturn RGB(brightness*255, brightness*255, brightness*255)
EndIf
DefType.f red, green, blue, domainOffset
If hue < 1.0/6
; red domain; green ascends
domainOffset = hue
red = brightness
blue = brightness * (1.0 - saturation)
green = blue + (brightness - blue) * domainOffset * 6
ElseIf hue < 2.0/6
; yellow domain; red descends
domainOffset = hue - 1.0/6
green = brightness
blue = brightness * (1.0 - saturation)
red = green - (brightness - blue) * domainOffset * 6
ElseIf hue < 3.0/6
; green domain; blue ascends
domainOffset = hue - 2.0/6
green = brightness
red = brightness * (1.0 - saturation)
blue = red + (brightness - red) * domainOffset * 6
ElseIf hue < 4.0/6
; cyan domain; green descends
domainOffset = hue - 3.0/6
blue = brightness
red = brightness * (1.0 - saturation)
green = blue - (brightness - red) * domainOffset * 6
ElseIf hue < 5.0/6
; blue domain; red ascends
domainOffset = hue - 4.0/6
blue = brightness
green = brightness * (1.0 - saturation)
red = green + (brightness - green) * domainOffset * 6
Else
; magenta domain; blue descends
domainOffset = hue - 5.0/6
red = brightness
green = brightness * (1.0 - saturation)
blue = red - (brightness - green) * domainOffset * 6
EndIf
ProcedureReturn RGB(red * 255, green * 255, blue * 255)
EndProcedure
Procedure.f DotsColor(xval.f, yval.f) ; color value from 0.0 to 1.0 by iterations
DefType.f i, m, r, j
While (j < #max) And (m < 4.0)
j=j+1
m = r * r - i * i
i = 2.0 * r * i + yval
r = m + xval
Wend
ProcedureReturn j / #max
EndProcedure
Procedure mandelbrot(xstart.f, ystart.f, xzoom.f, yzoom.f) ; calculate all points
DefType.f h, old
For x = 0 To #x1 - 1
For y = 0 To #y1 - 1
h = DotsColor(xstart + (xzoom * x), ystart + (yzoom * y)) ; color value
If h <> old
b = 1.0 - h * h ; brightness
col = HSB2RGB(h, 0.8, b)
old = h;
EndIf
Plot(x, y, col)
Next
Next
EndProcedure
If InitKeyboard() And InitSprite()
OpenWindow(0, 0, 0, #x1, #y1, #PB_Window_SystemMenu, "Test")
If OpenWindowedScreen(WindowID(), 0, 0, #x1, #y1, 0, 0, 0)
Repeat
While WindowEvent() : Wend
xende = xende * fac
xstart = xstart * fac
ystart = ystart * fac
yende = yende * fac
xzoom = (xende - xstart) / #x1
yzoom = (yende - ystart) / #y1
timer = GetTickCount_()
StartDrawing(ScreenOutput())
mandelbrot(xstart.f, ystart.f, xzoom.f, yzoom.f)
timer = GetTickCount_() - timer
speed = Int(#x1*#y1 / (1+(timer)))
Locate(0,0)
DrawText("Speed: " + Str(speed) + " Kpix/sec. Press and hold escape to exit")
StopDrawing()
FlipBuffers()
Until ExamineKeyboard() And KeyboardPushed(#PB_Key_Escape)
EndIf
EndIf -
Froggerprogger
- Enthusiast

- Posts: 423
- Joined: Fri Apr 25, 2003 5:22 pm
- Contact:
-
Froggerprogger
- Enthusiast

- Posts: 423
- Joined: Fri Apr 25, 2003 5:22 pm
- Contact:
Dreglor,
Here is the same code using WindowOuput() instead of DirectX. Does it display OK on your PC?
Does the GL Version display OK?
Here is the same code using WindowOuput() instead of DirectX. Does it display OK on your PC?
Does the GL Version display OK?
Code: Select all
; --------------------------------- ;
; Project: Mandelbrot - Speedtest without DirectX
; Start: Tuesday, September 09, 2003
; PB Version: 3.90
; Based on GLBasic code at http://www.glbasic.com/en/download.html
; Converted by Ged Byrne
#max.f = 128 ; #max iterations
#x1 = 640 ; ScreenX
#y1 = 480 ; ScreenY
xstart.f = -2.025
ystart.f = -1.125
xende.f = 0.6
yende.f = 1.125
xzoom.f = (xende - xstart) / #x1
yzoom.f = (yende - ystart) / #y1
fac.f = 0.99
Procedure HSB2RGB(hue.f, saturation.f, brightness.f)
If brightness = 0
ProcedureReturn 0
EndIf
If saturation = 0
ProcedureReturn RGB(brightness*255, brightness*255, brightness*255)
EndIf
DefType.f red, green, blue, domainOffset
If hue < 1.0/6
; red domain; green ascends
domainOffset = hue
red = brightness
blue = brightness * (1.0 - saturation)
green = blue + (brightness - blue) * domainOffset * 6
ElseIf hue < 2.0/6
; yellow domain; red descends
domainOffset = hue - 1.0/6
green = brightness
blue = brightness * (1.0 - saturation)
red = green - (brightness - blue) * domainOffset * 6
ElseIf hue < 3.0/6
; green domain; blue ascends
domainOffset = hue - 2.0/6
green = brightness
red = brightness * (1.0 - saturation)
blue = red + (brightness - red) * domainOffset * 6
ElseIf hue < 4.0/6
; cyan domain; green descends
domainOffset = hue - 3.0/6
blue = brightness
red = brightness * (1.0 - saturation)
green = blue - (brightness - red) * domainOffset * 6
ElseIf hue < 5.0/6
; blue domain; red ascends
domainOffset = hue - 4.0/6
blue = brightness
green = brightness * (1.0 - saturation)
red = green + (brightness - green) * domainOffset * 6
Else
; magenta domain; blue descends
domainOffset = hue - 5.0/6
red = brightness
green = brightness * (1.0 - saturation)
blue = red - (brightness - green) * domainOffset * 6
EndIf
ProcedureReturn RGB(red * 255, green * 255, blue * 255)
EndProcedure
Procedure.f DotsColor(xval.f, yval.f) ; color value from 0.0 to 1.0 by iterations
DefType.f i, m, r, j
While (j < #max) And (m < 4.0)
j=j+1
m = r * r - i * i
i = 2.0 * r * i + yval
r = m + xval
Wend
ProcedureReturn j / #max
EndProcedure
Procedure mandelbrot(xstart.f, ystart.f, xzoom.f, yzoom.f) ; calculate all points
DefType.f h, old
For x = 0 To #x1 - 1
For y = 0 To #y1 - 1
h = DotsColor(xstart + (xzoom * x), ystart + (yzoom * y)) ; color value
If h <> old
b = 1.0 - h * h ; brightness
col = HSB2RGB(h, 0.8, b)
old = h;
EndIf
Plot(x, y, col)
Next
Next
EndProcedure
If OpenWindow(0, 0, 0, #x1, #y1, #PB_Window_SystemMenu, "Test")
While WindowEvent() : Wend
xende = xende * fac
xstart = xstart * fac
ystart = ystart * fac
yende = yende * fac
xzoom = (xende - xstart) / #x1
yzoom = (yende - ystart) / #y1
timer = GetTickCount_()
StartDrawing(WindowOutput())
mandelbrot(xstart.f, ystart.f, xzoom.f, yzoom.f)
timer = GetTickCount_() - timer
speed = Int(#x1*#y1 / (1+(timer)))
Locate(0,0)
DrawText("Speed: " + Str(speed) + " Kpix/sec.")
StopDrawing()
FlipBuffers()
Repeat
Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf
-
remi_meier
- Enthusiast

- Posts: 468
- Joined: Sat Dec 20, 2003 6:19 pm
- Location: Switzerland
-
remi_meier
- Enthusiast

- Posts: 468
- Joined: Sat Dec 20, 2003 6:19 pm
- Location: Switzerland
Just to say:
This GLBasic man used SUB's and I read on his page, that the functions and SUBs are the same in GLBasic.... I replaced the mandelbrot() whith a GoSub and we have 100Kpix/s more
About your Problem GedB:
I know that GLBasic uses OpenGL and PB uses DirectX, so look at your preferences for your GFX-Card. Perhaps you have to change something to have a fair result!
bye
remi
This GLBasic man used SUB's and I read on his page, that the functions and SUBs are the same in GLBasic.... I replaced the mandelbrot() whith a GoSub and we have 100Kpix/s more
About your Problem GedB:
I know that GLBasic uses OpenGL and PB uses DirectX, so look at your preferences for your GFX-Card. Perhaps you have to change something to have a fair result!
bye
remi
Athlon64 3700+, 1024MB Ram, Radeon X1600
As I said, I don't think it is the drawing functions.
If I remove the drawing functions completely, the rate doesn't increate that much.
All of the work is being done in the DotsColor procedure.
I reckon that they are relying on some customer floating point code, whereas PB is relying on the maths co-processor.
I don't know how I would go about testing this idea.
If I remove the drawing functions completely, the rate doesn't increate that much.
All of the work is being done in the DotsColor procedure.
I reckon that they are relying on some customer floating point code, whereas PB is relying on the maths co-processor.
I don't know how I would go about testing this idea.
What I just can answer is that the Mandelbrot calculation used in the GLBasic benchmark is not the one I use to do, and performances are not the same at all ...
If you are interested to test ... change DotsColor() with this one :
Rgrds
If you are interested to test ... change DotsColor() with this one :
Code: Select all
Procedure.f MB(xf.f, yf.f)
fx.f = xf
fy.f = yf
j.l = 0
u.f = 0.0
v.f = 0.0
While j <= #max And (u + v) < 4.0
u = fx * fx
v = fy * fy
fy = 2.0 * fx * fy + yf
fx = u - v + xf
j + 1
Wend
ProcedureReturn j / #max
EndProcedure
My avatar is a small copy of the 4x1.8m image I created and exposed at 'Le salon international du meuble à Paris' january 2004 in Matt Sindall's 'Shades' designers exhibition. The original laminated print was designed using a 150 dpi printout.




