I converted the JAPI Mandelbrot Set to Simple Window to compare the speed of the two libraries.
' Simple Window DLLC JIT
include "dllcinc.sb"
oxy = dllfile("/sb22/modules/oxygen.dll")
o2_basic = dllproc( oxy, "o2_basic i =(c*source) " )
o2_exec = dllproc( oxy, "o2_exec i =(i
call) " )
o2_error = dllproc( oxy, "o2_error c*=() " )
o2_errno = dllproc( oxy, "o2_errno i =() " )
o2_len = dllproc( oxy, "o2_len i =() " )
o2_mode = dllproc( oxy, "o2_mode (i mode) " )
dllcall(o2_mode,1)
src = """
externfunction mandel(
float zre,zim,
sys maxiter)
as sys float mx,my,betrag
sys iter
while iter < maxiter
and betrag < 4.0
iter = iter+1
tmp = mx*mx-my*my+zre
my = 2*mx*my+zim
mx = tmp
betrag = (mx*mx + my*my)
wend return iter
end functionsub finish()
terminateend subfunction link(
sys n)
as sys select n
case 0
return @finish
case 1
return @mandel
end selectend functionend externaddr link"""
dllcall(o2_basic, src)
dfn = dllcall(o2_exec,0)
mandel = dllproc(dfn,"mandel i = (f zre, f zim, i maxiter)", dllcald(dfn, 1))
finish = dllproc(dfn,"finish ()", dllcald(dfn, 0))
sw = dllfile("sw.dll")
Window = dllproc(sw, "Window i = (i width, i height, i mode)")
SetCaption = DLLC_Proc(sw, "SetCaption i = (c *capText)")
SetPixel = dllproc(sw, "SetPixel i = (i xPos, i yPos, i color)")
RGB = dllproc(sw, "RGB i = (i rValue, i gValue, i bValue)")
Redraw = DLLC_Proc(sw, "Redraw ( )")
WaitKey = dllproc(sw, "WaitKey i = ( )")
Quit = DLLC_Proc(sw, "Quit i = ( )")
xstart = -1.8
xend = 0.8
ystart = -1.0
yend = 1.0
hoehe = 240
breite = 320
dllcall(Window,320,240,1)
dllcall(SetCaption,"SB SW DLLC JIT")
st = dllsecs()
x = -1
y = -1
REPEAT x = (x+1) % breite
if(x = 0)
then y = (y+1) % hoehe
zre = xstart + x*(xend-xstart)/breite
zim = ystart + y*(yend-ystart)/hoehe
it = dllcall(mandel,zre,zim,512)
dllcall(SetPixel,x, y, dllcall(RGB,it*11,it*13,it*17))
dllcall(Redraw)
UNTIL ((x = breite-1)
and (y = hoehe-1))
PRINT format("%g",dllsecs() - st),"\n"
dllcall(WaitKey)
dllcall(Finish)
dllcall(Quit)
dllfile
C:\SB22\japi_dllc>scriba swmandeldllc.sb
5.57576
C:\SB22\japi_dllc>
If I remove the
Redraw() function and wait until the it's done to refresh the screen.
C:\SB22\japi_dllc>scriba swmandeldllc.sb
1.05691
C:\SB22\japi_dllc>
This is stock SB with no JIT assist.
' Simple Window DLLC
include "dllcinc.sb"
sw = dllfile("sw.dll")
Window = dllproc(sw, "Window i = (i width, i height, i mode)")
SetCaption = DLLC_Proc(sw, "SetCaption i = (c *capText)")
SetPixel = dllproc(sw, "SetPixel i = (i xPos, i yPos, i color)")
RGB = dllproc(sw, "RGB i = (i rValue, i gValue, i bValue)")
Redraw = DLLC_Proc(sw, "Redraw ( )")
WaitKey = dllproc(sw, "WaitKey i = ( )")
Quit = DLLC_Proc(sw, "Quit i = ( )")
function mandel(zre,zim,maxiter)
mx = 0.0
my = 0.0
iter=0
betrag=0.0
while ((iter < maxiter)
and (betrag < 4.0))
iter = iter+1
tmp = mx*mx-my*my+zre
my = 2*mx*my+zim
mx = tmp
betrag = (mx*mx + my*my)
wend mandel=iter
end functionxstart = -1.8
xend = 0.8
ystart = -1.0
yend = 1.0
hoehe = 240
breite = 320
dllcall(Window,320,240,1)
dllcall(SetCaption,"SB SW DLLC")
st = dllsecs()
x = -1
y = -1
REPEAT x = (x+1) % breite
if(x = 0)
then y = (y+1) % hoehe
zre = xstart + x*(xend-xstart)/breite
zim = ystart + y*(yend-ystart)/hoehe
it = mandel(zre,zim,512)
dllcall(SetPixel,x, y, dllcall(RGB,it*11,it*13,it*17))
UNTIL ((x = breite-1)
and (y = hoehe-1))
dllcall(Redraw)
PRINT format("%g",dllsecs() - st),"\n"
dllcall(WaitKey)
dllcall(Quit)
dllfile
With
Redraw() in the loop.
C:\SB22\japi_dllc>scriba swnojit.sb
45.0972
C:\SB22\japi_dllc>
Wait until the end to display the results.
C:\SB22\japi_dllc>scriba swnojit.sb
39.637
C:\SB22\japi_dllc>