Here are the benchmark but isn't realistic FB-gfx does clipping and use single values as params also !
Code: Select all
#ifndef __ALINE_BI__
#define __ALINE_BI__
#define RGB16(r,g,b) ((r and &B11111000) shl 9) or ((g and &B11111100) shl 4) or ((b and &B11111000) shr 3)
#define StepSign(v) (iif(0<(v),1,0)-iif((v)<0,1,0))
dim shared as integer pitch
dim shared as any ptr pixels
#macro aLine(_type_,_shift_)
dim as integer dx=x1-x0
dim as integer dy=y1-y0
dim as integer sx=StepSign(dx)
dim as integer sy=StepSign(dy)
if dx<0 then dx=-dx
if dy<0 then dy=-dy
dim as integer iErr=dx-dy
dim as integer iPitch=pitch shr _shift_
dim as _type_ ptr p=pixels
if (x0<>x1) or (y0<>y1) then *(p+x1+y1*iPitch)=c
p+=x0+y0*iPitch
if sy<0 then
iPitch=-iPitch
elseif sy=0 then
iPitch=0
end if
do
*p=c
dim as integer iErr2=iErr shl 1
if (iErr2 > -dy) then iErr-=dy:x0+=sx:p+=sx
if (iErr2 < dx) then iErr+=dx:y0+=sy:p+=iPitch
loop while ((x0<>x1) or (y0<>y1))
#endmacro
sub aLine8(byval x0 as integer,byval y0 as integer,byval x1 as integer,byval y1 as integer,byval c as ubyte)
aLine(UBYTE,0)
end sub
sub aLine16(byval x0 as integer,byval y0 as integer,byval x1 as integer,byval y1 as integer,byval c as ushort)
aLine(USHORT,1)
end sub
sub aLine32(byval x0 as integer,byval y0 as integer,byval x1 as integer,byval y1 as integer,byval c as ulong)
aLine(ULONG,2)
end sub
#endif '__ALINE_BI__
const as integer NUM_OF_RUNS=60
const as integer NUM_OF_LINES=10000
dim as double B8,B16,B32
dim as integer bits=8
while bits<33
screenres 640,480,bits,2
screenset 1,0
windowtitle "BASIC " & bits & " bit mode"
pixels=ScreenPtr()
screeninfo ,,,,pitch
select case as const bits
case 8
dim as ubyte c
B8=timer()
for n as integer=1 to NUM_OF_RUNS
for i as integer = 1 to NUM_OF_LINES
c=rnd*255
aLine8 rnd*639,rnd*479,rnd*639,rnd*479,c
next
flip
next
B8=timer()-B8
sleep 1000
case 16
dim as ubyte r,g,b
B16=timer()
for n as integer=1 to NUM_OF_RUNS
for i as integer = 1 to NUM_OF_LINES
r=rnd*255 : g=rnd*255 : b=rnd*255
aLine16 rnd*639,rnd*479,rnd*639,rnd*479,RGB16(r,g,b)
next
flip
next
B16=timer()-B16
sleep 1000
case 32
dim as ubyte r,g,b
B32=timer()
for n as integer=1 to NUM_OF_RUNS
for i as integer = 1 to NUM_OF_LINES
r=rnd*255 : g=rnd*255 : b=rnd*255
aLine32 rnd*639,rnd*479,rnd*639,rnd*479,RGB(r,g,b)
next
flip
next
B32=timer()-B32
sleep 1000
end select
bits shl=1
wend
dim as double C8,C16,C32
bits=8
while bits<33
screenres 640,480,bits,2
screenset 1,0
windowtitle "C-GFX " & bits & " bit mode"
pixels=ScreenPtr()
screeninfo ,,,,pitch
select case as const bits
case 8
dim as ubyte c
C8=timer()
for n as integer=1 to NUM_OF_RUNS
for i as integer = 1 to NUM_OF_LINES
c=rnd*255
Line (rnd*639,rnd*479)-(rnd*639,rnd*479),c
next
flip
next
C8=timer()-c8
sleep 1000
case 16
dim as ubyte r,g,b
C16=timer()
for n as integer=1 to NUM_OF_RUNS
for i as integer = 1 to NUM_OF_LINES
r=rnd*255 : g=rnd*255 : b=rnd*255
Line (rnd*639,rnd*479)-(rnd*639,rnd*479),RGB(r,g,b)
next
flip
next
C16=timer()-C16
sleep 1000
case 32
dim as ubyte r,g,b
C32=timer()
for n as integer=1 to NUM_OF_RUNS
for i as integer = 1 to NUM_OF_LINES
r=rnd*255 : g=rnd*255 : b=rnd*255
Line (rnd*639,rnd*479)-(rnd*639,rnd*479),RGB(r,g,b)
next
flip
next
C32=timer()-C32
sleep 1000
end select
bits shl=1
wend
screenres 640,480
print "BASIC: " & b8,b16,b32
print "C GFX: " & C8,C16,C32
sleep