This is a very rough - please excuse my bad coding
each benchmark is a function that returns time in milliseconds.
So far I just added a few simple ones - please feel
free to write new ones or improve this code.
// --------------------------------- //
// Project: GLBasic Mark - Mikiex
// Start: Monday, April 23, 2006
// IDE Version: 3.109
//Run through all benchmarks
WHILE TRUE
num_results = 3
DIM test_results[num_results]
DIM test_name$[num_results]
test_results[0] = FORlooptest()
test_name$[0] = "For Loop (20k)"
test_results[1] = pixeltest()
test_name$[1] = "PixelDraw (20k)"
test_results[2] = FILLRECtTest()
test_name$[2] = "Fillrect (20k)"
SHOWSCREEN
//Show results on screen
//set position for results
xposresults = 10
yposresults = 100
linegap = 12
//show platform info
PRINT PLATFORMINFO$("")+" "+PLATFORMINFO$("ID")+" "+PLATFORMINFO$("BATTERY"),xposresults,yposresults
yposresults = yposresults + linegap
//show resuts for each benchmark
showresult (test_name$[0],test_results[0],xposresults,yposresults)
yposresults = yposresults + linegap
showresult (test_name$[1],test_results[1],xposresults,yposresults)
yposresults = yposresults + linegap
showresult (test_name$[2],test_results[2],xposresults,yposresults)
yposresults = yposresults + linegap
//total result
FOR tr = 0 TO num_results - 1
TOtalresult = TOtalresult + test_results[tr]
NEXT
showresult ("Total",TOtalresult,xposresults,yposresults)
TOtalresult = 0
yposresults = yposresults + 15
SHOWSCREEN
MOUSEWAIT
WEND
// function show result
FUNCTION showresult: funcname$, func , x , y
FOR tx = x TO x + func
FOR ty = y TO y + 10
SETPIXEL tx,ty,RGB(0,250,0)
NEXT
NEXT
PRINT funcname$+" "+FORMAT$(0, 2, func)+"ms",x+10,y+2
ENDFUNCTION
//All Benchmarks are just functions below
// for loop test
FUNCTION FORlooptest:
LOCAL starttime = GETTIMERALL()
FOR px = 0 TO 100
FOR py = 0 TO 200
NEXT
NEXT
RETURN GETTIMERALL() - starttime
ENDFUNCTION
// pixel draw test
FUNCTION pixeltest:
LOCAL starttime = GETTIMERALL()
FOR px = 0 TO 100
FOR py = 0 TO 200
SETPIXEL px,py,RGB(250,0,0)
NEXT
NEXT
RETURN GETTIMERALL() - starttime
ENDFUNCTION
// fillrectest
FUNCTION FILLRECtTest:
LOCAL starttime = GETTIMERALL()
FOR px = 0 TO 100
FOR py = 0 TO 200
FILLRECT 0,0,px,py,RGB(0,250,0)
NEXT
NEXT
RETURN GETTIMERALL() - starttime
ENDFUNCTION
btw I get:
win32 XP (2800 Athlon64)
for loop = 0.07ms
pixel draw = 40.47ms
fillrect = 41.37ms
MDA compact (Xscale 416mhz)
for loop = 5.98ms
pixel draw = 22.41ms
fillrect = 17301.6 ms
Its interesting to see the pocket pc win on the pixel draw??
I expect for the fillrect the pocket pc is doing that pixel by pixel
- maybe why it is so slow, as that test draws 20,000 boxes.
I shall have to run the tests multiple times and then take an average
also add some 3d tests that have results in fps
I added some tests. I 've not tested on a real device - we should reduce/increase some loops for nice values...
Also, we should get one device as a reference device. I think a iPaq3600 would be nice. It's the slowest device required for gaming in PocketPC developer forums.
// --------------------------------- //
// Project: GLBasic Mark - Mikiex
// Start: Monday, April 23, 2006
// IDE Version: 3.109
//Run through all benchmarks
WHILE TRUE
num_results = 7
DIM test_results[num_results]
DIM test_name$[num_results]
test_name$[0] = "For Loop (200k)"
PRINT test_name$[0], 0, 0; SHOWSCREEN
test_results[0] = FORlooptest()
test_name$[1] = "PixelDraw (20k)"
PRINT test_name$[1], 0, 0; SHOWSCREEN
test_results[1] = pixeltest()
test_name$[2] = "Fillrect (20k)"
PRINT test_name$[2], 0, 0; SHOWSCREEN
test_results[2] = FILLRECtTest()
test_name$[3] = "AlphaFill (20k)"
PRINT test_name$[3], 0, 0; SHOWSCREEN
test_results[3] = alphatest()
test_name$[4] = "Showscreen (50x)"
PRINT test_name$[4], 0, 0; SHOWSCREEN
test_results[4] = SHOWSCREENtest()
test_name$[5] = "Create 3D (2000 tri)"
PRINT test_name$[5], 0, 0; SHOWSCREEN
test_results[5] = Test3DCreate()
test_name$[6] = "Test3D (2000*360tri)"
PRINT test_name$[6], 0, 0; SHOWSCREEN
test_results[6] = Test3DDraw()
//Show results on screen
X_MAKE2D
//set position for results
xposresults = 10
yposresults = 20
linegap = 12
//show platform info
PRINT PLATFORMINFO$("")+" "+PLATFORMINFO$("ID")+" "+PLATFORMINFO$("BATTERY"),xposresults,yposresults
yposresults = yposresults + linegap
//show resuts for each benchmark
FOR i=0 TO num_results-1
showresult (test_name$[i],test_results[i],xposresults,yposresults)
yposresults = yposresults + linegap
NEXT
//total result
FOR tr = 0 TO num_results - 1
TOtalresult = TOtalresult + test_results[tr]
NEXT
showresult ("Total",TOtalresult,xposresults,yposresults)
TOtalresult = 0
yposresults = yposresults + 15
SHOWSCREEN
MOUSEWAIT
WEND
// function show result
FUNCTION showresult: funcname$, func , x , y
FOR tx = x TO x + func
FOR ty = y TO y + 10
SETPIXEL tx,ty,RGB(0,250,0)
NEXT
NEXT
PRINT funcname$+" "+FORMAT$(0, 2, func)+"ms",x+10,y+2
ENDFUNCTION
//All Benchmarks are just functions below
// for loop test
FUNCTION FORlooptest:
LOCAL starttime = GETTIMERALL()
FOR px = 0 TO 1000
FOR py = 0 TO 200
NEXT
NEXT
RETURN GETTIMERALL() - starttime
ENDFUNCTION
// pixel draw test
FUNCTION pixeltest:
LOCAL starttime = GETTIMERALL()
FOR px = 0 TO 100
FOR py = 0 TO 200
SETPIXEL px,py,RGB(250,0,0)
NEXT
NEXT
RETURN GETTIMERALL() - starttime
ENDFUNCTION
// fillrectest
FUNCTION FILLRECtTest:
LOCAL starttime = GETTIMERALL()
FOR px = 0 TO 100
FOR py = 0 TO 200
FILLRECT 0,0,px,py,RGB(0,250,0)
NEXT
NEXT
RETURN GETTIMERALL() - starttime
ENDFUNCTION
FUNCTION alphatest:
LOCAL starttime = GETTIMERALL()
ALPHAMODE 1
FOR py = 0 TO 200
FILLRECT 0,0,100,py,RGB(0,250,0)
NEXT
RETURN GETTIMERALL() - starttime
ENDFUNCTION
// SHOWSCREEN
FUNCTION SHOWSCREENtest:
LOCAL starttime = GETTIMERALL()
LIMITFPS -1
FOR i=0 TO 49
SHOWSCREEN
NEXT
RETURN GETTIMERALL() - starttime
ENDFUNCTION
// ------------------------------------------------------------- //
// -=# CREATETORUS #=-
//
// By Samuel R. Buss
// http://math.ucsd.edu/~sbuss/MathCG
// ------------------------------------------------------------- //
FUNCTION CreateTorus: num, MinorRadius, MajorRadius, NumWraps, NumPerWrap, TextureWrapVert, TextureWrapHoriz, col
// Diese Variablen sind als LOCAL definiert:
// x, y,
// Draw the torus
LOCAL i, di, j, wrapFrac, wrapFracTex, phi, thetaFrac, thetaFracTex, theta
LOCAL x, y, z, r
X_AUTONORMALS 2
X_OBJSTART num
FOR di=0 TO NumWraps-1
FOR j=0 TO NumPerWrap
FOR i=di+1 TO di STEP -1
wrapFrac = MOD(j, NumPerWrap)/NumPerWrap
wrapFracTex = j/NumPerWrap
phi = 360*wrapFrac
thetaFrac = (MOD(i, NumWraps)+wrapFracTex)/NumWraps
thetaFracTex = (i+wrapFracTex)/NumWraps
theta = 360*thetaFrac
r = MajorRadius + MinorRadius*COS(phi)
x = SIN(theta)*r
z = COS(theta)*r
y = MinorRadius*SIN(phi)
X_OBJADDVERTEX x,y,z, thetaFracTex*TextureWrapVert, wrapFracTex*TextureWrapHoriz, col
NEXT
NEXT
X_OBJNEWGROUP
NEXT
X_OBJEND
ENDFUNCTION // y
// 3D functionality
FUNCTION Test3DCreate:
LOCAL starttime = GETTIMERALL()
CreateTorus(0, 10, 20, 50, 20, 2,2, RGB(255,255,255))
RETURN GETTIMERALL() - starttime
ENDFUNCTION
// 3D functionality
FUNCTION Test3DDraw:
LOCAL starttime = GETTIMERALL()
X_MAKE3D 1,500,45
X_CAMERA 0,200,200,0,0,0
X_AMBIENT_LT 0, RGB( 255,128,64)
FOR i=0 TO 360
X_MOVEMENT (i-180)/4, 0,0
X_ROTATION i, 1,0,0
X_DRAWOBJ 0, 0
NEXT
RETURN GETTIMERALL() - starttime
ENDFUNCTION
This looks really good guys, well done.
Iv a new puppy and my activesync cable has been chewed (Grrr!) but I ordered a new one yesterday, so I should have it by tomorrow. Ill run the benchtest then.
Now if Gernot could post this on the German forum, as well, we could possibly get a decent table of results together. Interesting! :)
Well done Mikie, its a great idea.
Ian
We should get some perfomance tests first to see if some test needs tweaking.
Then, we should convert the times into a 1000/times GL-Mark index.
Thanks Gernot, the more tests the better - and thanks for some code cleaning up :)
I shall have to think up some new tests :)
T-Mobile SDA II (Smartphone):
For-Loop: 173ms
PixelDraw 45ms
Fillrect: 39159ms -> too long
AlphaFill: 1687ms
Showscreen: 415ms
Create3D: 10999ms
Test3D: 60435ms -> much too long
I think no test longer than 5 seconds on this device, OK?
iPAQ hx4700
For-Loop: 43.56ms
PixelDraw 26.34ms
Fillrect: 14841,74ms
AlphaFill: 648,23ms
Showscreen: 1673,62ms ????
Create3D: 8012,02ms
Test3D: 21266,47ms
Send me the errorlog.txt from you PocketPC's /Temp directory. I'll see why your showscreen is a bit slow. This way you get 30 FPS at max.
I added two more tests
drawing a sinewave using sin 100 times
drawing a sinewave from an array of stored sin values 100 times
I have not tested on ppc, but on my PC it seems slightly faster to just use sin
// --------------------------------- //
// Project: GLBasic Mark - Mikiex
// Start: Monday, April 23, 2006
// IDE Version: 3.109
//Run through all benchmarks
WHILE TRUE
num_results = 9
DIM test_results[num_results]
DIM test_name$[num_results]
test_name$[0] = "For Loop (200k)"
PRINT test_name$[0], 0, 0; SHOWSCREEN
test_results[0] = FORlooptest()
test_name$[1] = "PixelDraw (20k)"
PRINT test_name$[1], 0, 0; SHOWSCREEN
test_results[1] = pixeltest()
test_name$[2] = "Fillrect (20k)"
PRINT test_name$[2], 0, 0; SHOWSCREEN
test_results[2] = FILLRECtTest()
test_name$[3] = "AlphaFill (20k)"
PRINT test_name$[3], 0, 0; SHOWSCREEN
test_results[3] = alphatest()
test_name$[4] = "Showscreen (50x)"
PRINT test_name$[4], 0, 0; SHOWSCREEN
test_results[4] = SHOWSCREENtest()
test_name$[5] = "Create 3D (2000 tri)"
PRINT test_name$[5], 0, 0; SHOWSCREEN
test_results[5] = Test3DCreate()
test_name$[6] = "Test3D (2000*360tri)"
PRINT test_name$[6], 0, 0; SHOWSCREEN
test_results[6] = Test3DDraw()
test_name$[7] = "Sin (100*360)"
PRINT test_name$[7], 0, 0; SHOWSCREEN
test_results[7] = sinewavetest()
test_name$[8] = "Sin table (100*360)"
PRINT test_name$[8], 0, 0; SHOWSCREEN
test_results[8] = sinewave_tabletest()
//Show results on screen
X_MAKE2D
//set position for results
xposresults = 10
yposresults = 20
linegap = 12
//show platform info
PRINT PLATFORMINFO$("")+" "+PLATFORMINFO$("ID")+" "+PLATFORMINFO$("BATTERY"),xposresults,yposresults
yposresults = yposresults + linegap
//show resuts for each benchmark
FOR i=0 TO num_results-1
showresult (test_name$[i],test_results[i],xposresults,yposresults)
yposresults = yposresults + linegap
NEXT
//total result
FOR tr = 0 TO num_results - 1
TOtalresult = TOtalresult + test_results[tr]
NEXT
showresult ("Total",TOtalresult,xposresults,yposresults)
TOtalresult = 0
yposresults = yposresults + 15
SHOWSCREEN
MOUSEWAIT
WEND
// function show result
FUNCTION showresult: funcname$, func , x , y
FOR tx = x TO x + func
FOR ty = y TO y + 10
SETPIXEL tx,ty,RGB(0,250,0)
NEXT
NEXT
PRINT funcname$+" "+FORMAT$(0, 2, func)+"ms",x+10,y+2
ENDFUNCTION
//All Benchmarks are just functions below
// for loop test
FUNCTION FORlooptest:
LOCAL starttime = GETTIMERALL()
FOR px = 0 TO 1000
FOR py = 0 TO 200
NEXT
NEXT
RETURN GETTIMERALL() - starttime
ENDFUNCTION
// pixel draw test
FUNCTION pixeltest:
LOCAL starttime = GETTIMERALL()
FOR px = 0 TO 100
FOR py = 0 TO 200
SETPIXEL px,py,RGB(250,0,0)
NEXT
NEXT
RETURN GETTIMERALL() - starttime
ENDFUNCTION
// fillrectest
FUNCTION FILLRECtTest:
LOCAL starttime = GETTIMERALL()
FOR px = 0 TO 100
FOR py = 0 TO 200
FILLRECT 0,0,px,py,RGB(0,250,0)
NEXT
NEXT
RETURN GETTIMERALL() - starttime
ENDFUNCTION
FUNCTION alphatest:
LOCAL starttime = GETTIMERALL()
ALPHAMODE 1
FOR py = 0 TO 200
FILLRECT 0,0,100,py,RGB(0,250,0)
NEXT
RETURN GETTIMERALL() - starttime
ENDFUNCTION
// SHOWSCREEN
FUNCTION SHOWSCREENtest:
LOCAL starttime = GETTIMERALL()
LIMITFPS -1
FOR i=0 TO 49
SHOWSCREEN
NEXT
RETURN GETTIMERALL() - starttime
ENDFUNCTION
// ------------------------------------------------------------- //
// -=# CREATETORUS #=-
//
// By Samuel R. Buss
// http://math.ucsd.edu/~sbuss/MathCG
// ------------------------------------------------------------- //
FUNCTION CreateTorus: num, MinorRadius, MajorRadius, NumWraps, NumPerWrap, TextureWrapVert, TextureWrapHoriz, col
// Diese Variablen sind als LOCAL definiert:
// x, y,
// Draw the torus
LOCAL i, di, j, wrapFrac, wrapFracTex, phi, thetaFrac, thetaFracTex, theta
LOCAL x, y, z, r
X_AUTONORMALS 2
X_OBJSTART num
FOR di=0 TO NumWraps-1
FOR j=0 TO NumPerWrap
FOR i=di+1 TO di STEP -1
wrapFrac = MOD(j, NumPerWrap)/NumPerWrap
wrapFracTex = j/NumPerWrap
phi = 360*wrapFrac
thetaFrac = (MOD(i, NumWraps)+wrapFracTex)/NumWraps
thetaFracTex = (i+wrapFracTex)/NumWraps
theta = 360*thetaFrac
r = MajorRadius + MinorRadius*COS(phi)
x = SIN(theta)*r
z = COS(theta)*r
y = MinorRadius*SIN(phi)
X_OBJADDVERTEX x,y,z, thetaFracTex*TextureWrapVert, wrapFracTex*TextureWrapHoriz, col
NEXT
NEXT
X_OBJNEWGROUP
NEXT
X_OBJEND
ENDFUNCTION // y
// 3D functionality
FUNCTION Test3DCreate:
LOCAL starttime = GETTIMERALL()
CreateTorus(0, 10, 20, 50, 20, 2,2, RGB(255,255,255))
RETURN GETTIMERALL() - starttime
ENDFUNCTION
// 3D functionality
FUNCTION Test3DDraw:
LOCAL starttime = GETTIMERALL()
X_MAKE3D 1,500,45
X_CAMERA 0,200,200,0,0,0
X_AMBIENT_LT 0, RGB( 255,128,64)
FOR i=0 TO 360
X_MOVEMENT (i-180)/4, 0,0
X_ROTATION i, 1,0,0
X_DRAWOBJ 0, 0
NEXT
RETURN GETTIMERALL() - starttime
ENDFUNCTION
// Sinewave test
FUNCTION sinewavetest:
LOCAL starttime = GETTIMERALL()
FOR numsines = 1 TO 100
FOR t = 0 TO 360
LOCAL y = SIN(t) * 50
SETPIXEL t,y+200+numsines,RGB(0,200,0)
NEXT
NEXT
RETURN GETTIMERALL() - starttime
ENDFUNCTION
// Sinewave table test
FUNCTION sinewave_tabletest:
DIM SINtable[361]
FOR tx = 0 TO 360
SINtable[tx]= SIN(tx) * 50
NEXT
LOCAL starttime = GETTIMERALL()
FOR numsines = 1 TO 100
FOR tr= 0 TO 360
LOCAL yr = SINtable[tr]
SETPIXEL tr,yr+200+numsines,RGB(0,200,200)
NEXT
NEXT
RETURN GETTIMERALL() - starttime
ENDFUNCTION
On PPC you will see the very opposite! Sin/Cos and Sqr are very expensive on the PPC. See my previous post - I posted it in German last time, sorry.
This is the great thing about a benchmark, seeing where you need to adapt
for different platforms. I expected ppc was going to have problems with that
test :)
I was writing something intended for ppc that uses cosine interpolation,
now I know I should use a lookup table :)