Ibook performance

Archives Forums/MacOS X Discussion/Ibook performance

ImaginaryHuman(Posted 2004) [#1]
You can use the enclosed short(ish) program to test some speed results for your OpenGL 2D graphics.

These are my results on a G3 300MHz iBook.

[EDIT] This is all in 32-bit color

800x600 - no clearscreen, computing and printing fps only - 17fps
640x480 - no clearscreen, computing and printing fps only - 29fps
320x240 - no clearscreen, computing and printing fps only - 59fps

800x600 - with clearscreen, computing and printing fps - 14.5fps
640x480 - with clearscreen, computing and printing fps - 23fps
320x240 - with clearscreen, computing and printing fps - 55fps

640x480 - with 10 128x128 zooming/rotating/tinted objects in LIGHTBLEND - 7fps

In the non-object tests there is no other processing occuring in the loop other than the screen flip (which takes quite a bit of processing itself!). Throwing around 10 128x128 objects drops the framerate to about 6-7 frames per second at 640x480. Eeeeeeee!

Oh well. See what results you can get with this test program - you can just comment out the main loop stuff except the fps calculations in order to get the results consistent with those above. And just take out the Cls inside the loop for the non-clearing version. I KNOW that on more modern hardware the framerate is probably amazing.

You'll need to create a 128x128 (or so) image to use and change the incbin and loadimage commands in the source.......

'Bouncy images with gravity, color tint, rotation, zoom and masking

objects:Int=10
maxxspeed:Int=10
maxyspeed:Int=10
Const blendmode:Int=LIGHTBLEND
gravity:Float=0.3
maxspinspeed:Float=10
maxzoomspeed:Float=2

Const gwid:Int=640
Const ghig:Int=480
Const iflags:Int=0 'Image type
Graphics gwid,ghig,0
Incbin "ball.png"
img=LoadImage("incbin::ball.png",iflags)
wid=ImageWidth(img)
hig=ImageHeight(img)
halfwid:Int=wid/2
halfhig:Int=hig/2

Rand MilliSecs()
Global objpos:Float[objects,2]
Global movpos:Float[objects,2]
Global col:Byte[objects,3]
Global spin:Float[objects,2]
Global zoom:Float[objects,2]
Local xadd:Float
Local yaad:Float
For Local o:Int=0 To objects-1
	xadd=Rnd(maxxspeed*2)-maxxspeed
	yadd=Rnd(maxyspeed*2)-maxyspeed
	objpos[o,0]=maxxspeed+halfwid+Rnd(639-wid-maxxspeed-maxxspeed)
	objpos[o,1]=maxyspeed+halfhig+Rnd(479-hig-maxyspeed-maxyspeed)
	movpos[o,0]=xadd
	movpos[o,1]=yadd
	col[o,0]=128+Rnd(127)
	col[o,1]=128+Rnd(127)
	col[o,2]=128+Rnd(127)
	spin[o,0]=Rnd(359)
	spin[o,1]=Rnd(maxspinspeed)
	zoom[o,0]=Rnd(359)
	zoom[o,1]=Rnd(maxzoomspeed)
Next
SetColor $ff,$ff,$ff
SetImageHandle img,wid/2,hig/2
SetRotation 0
SetScale 1,1

Local counter:Int=MilliSecs()
Local passage:Int=0
Local m:Int=0
Local fps:Float=0.0
Repeat
	Cls
	SetBlend blendmode
	For o=0 To objects-1
		If ((objpos[o,0]<=maxxspeed+halfwid) Or (objpos[o,0]>=gwid-halfwid-maxxspeed))
			movpos[o,0]=-movpos[o,0]
		EndIf
		If ((objpos[o,1]<=maxyspeed*4+halfhig) Or (objpos[o,1]>=ghig-halfhig-maxyspeed*4))
			movpos[o,1]=-movpos[o,1]
		EndIf
		objpos[o,0]=objpos[o,0]+movpos[o,0]
		objpos[o,1]=objpos[o,1]+movpos[o,1]
		SetRotation spin[o,0]+(o*10)
		spin[o,0]=spin[o,0]+spin[o,1]
		SetScale 1.5*Sin(zoom[o,0]+o*30),1.5*Sin(zoom[o,0]+o*30)
		zoom[o,0]=zoom[o,0]+zoom[o,1]
		SetColor col[o,0],col[o,1],col[o,2]
		DrawImage img,objpos[o,0],objpos[o,1]
		movpos[o,1]=movpos[o,1]+gravity	
	Next
	m=MilliSecs()
	passage=m-counter
	fps=1000.0/passage
	counter=m	
	SetRotation 0
	SetScale 1,1
	SetBlend SOLIDBLEND
	DrawText fps+"fps",0,0
	Flip
Until KeyHit(KEY_ESCAPE)
End


Give it a try, let us know your results and on what hardware :-)


Perturbatio(Posted 2004) [#2]
you might want to use the Code or Codebox forum commands.

http://www.blitzbasic.com/faq/faq_entry.php?id=2

Codebox being my preference.


ImaginaryHuman(Posted 2004) [#3]
I tried it, couldn't get it to work. I got the {code} version to work, as above.


Perturbatio(Posted 2004) [#4]


replace {} with []

{codebox}
your source here
{/codebox}


ImaginaryHuman(Posted 2004) [#5]
codebox wouldn't work. no matter.


Perturbatio(Posted 2004) [#6]
two things, windowed mode is still in testing and make sure you run with debug build off.


ImaginaryHuman(Posted 2004) [#7]
Windowed mode is the ONLY mode that works on computers that don't have hardware graphics acceleration - like the iBook. And of course I turned the debug off ;-)


ImaginaryHuman(Posted 2004) [#8]
I ran the above program on my other mac, a 1GHz G4 with 64mb videoram as part of a Radeon MX gfx card .... these are the results..

1440x900 resolution, *650* 128x128 objects rotated/scaled/tinted/lightblended runs at 30fps! I think that's pretty awesome. It's using Images though which is kept in texture memory.

So I wanted to find out how fast those Pixmaps are at rendering. Oh .. my... gosh... I could only get it to render *10* 128x128 pixmap objects at 16fps! Also strangely it seemed like when doing this the framerate constantly got lower and lower and there started to be harddrive access. I've no idea what's going on there, but the pixmap rendering seems to be incredibly slow. Maybe I am just not doing it right but all I did was swap the Image commands for Pixmap commands ie LoadPixmap and DrawPixmap (and removed the ImageWidth/ImageHeight since there is no Pixmap version).

Sighs of relief, followed by sighs of dispair! lol


ImaginaryHuman(Posted 2004) [#9]
Test results above were a bit off. I now get up to 1350 objects on a 1024x768 screen.