Test Sprite output speed...

Everything else that doesn't fall into one of the other PB categories.
newart
User
User
Posts: 34
Joined: Sat Feb 12, 2005 1:59 am
Location: Russia, SPb

Test Sprite output speed...

Post by newart »

I have written the program for testing speed of cursor Sprites. I measure quantity sprites for 1/100 seconds Here a source code.

=================================

#color=32; (16 bit or 32 bit color depth)

If InitSprite() = 0 Or InitKeyboard() = 0 Or InitMouse()=0:MessageRequester("Error", "Can't open DirectX 7 Or later", 0):End:EndIf
If InitSprite3D() = 0:MessageRequester("Error", "Direct3D system can't be initialized correctly", 0):End:EndIf

Global timer, tm16,tm24,tm32,tm48,tm64,test,nm,tm16t,tm24t,tm32t,tm48t,tm64t,tm16d,tm32d,tm64d,tm128d,tm256d

Procedure put_fps(Value)
Repeat
Delay (1000)

If test=1
Select nm
Case 0:tm16+timer
Case 1:tm24+timer
Case 2:tm32+timer
Case 3:tm48+timer
Case 4:tm64+timer
EndSelect:EndIf
If test=2
Select nm
Case 0:tm16t+timer
Case 1:tm24t+timer
Case 2:tm32t+timer
Case 3:tm48t+timer
Case 4:tm64t+timer
EndSelect:EndIf
If test=3
Select nm
Case 0:tm16d+timer
Case 1:tm32d+timer
Case 2:tm64d+timer
Case 3:tm128d+timer
Case 4:tm256d+timer
EndSelect:EndIf

If test<4
nm+1
If nm=5:test+1:nm=0:EndIf
timer=0
EndIf


ForEver
EndProcedure


test=1

If OpenScreen(800, 600,#color, "Speed test: 32bit")
Gosub Loadspr
SetFrameRate(100)

For a=0 To 500
x=Random(640-64):y=Random(480-64):DisplaySprite(nm,x,y)
Next a

thid=CreateThread(@put_fps(), 0)

Repeat:ExamineKeyboard()

Select test
Case 1:x=Random(640-64):y=Random(480-64):DisplaySprite(nm,x,y):timer+1
Case 2:x=0:Random(640-64):y=Random(480-64):DisplayTransparentSprite(nm,x,y):timer+1
Case 3:x=0:Random(640-256):y=Random(480-256):Start3D():DisplaySprite3D(nm,x,y,255):Stop3D():timer+1
EndSelect

Until test=4 Or KeyboardPushed(#PB_Key_Escape)
Else:MessageRequester("Error", "Can't open a 800*600 - 32 bit screen !", 0):End:EndIf

txt$="Speed test v0.1 (c) newart"+Chr(13)+Chr(10)+Chr(13)+Chr(10)+"gfx card: ";+GetGFXCard()
txt$=txt$+Chr(13)+Chr(10)+Chr(13)+Chr(10)+"Sprite put in 1/100 second."
txt$=txt$+Chr(13)+Chr(10)+Chr(13)+Chr(10)+Str(#color)+" bit mode"+Chr(13)+Chr(10)+Chr(13)+Chr(10)
txt$=txt$+"Put sprites (in one frame):"+Chr(13)+Chr(10)+Chr(13)+Chr(10)
txt$=txt$+"16x16="+Str(tm16/100)+Chr(13)+Chr(10)
txt$=txt$+"24x24="+Str(tm24/100)+Chr(13)+Chr(10)
txt$=txt$+"32x32="+Str(tm32/100)+Chr(13)+Chr(10)
txt$=txt$+"48x48="+Str(tm48/100)+Chr(13)+Chr(10)
txt$=txt$+"64x64="+Str(tm64/100)+Chr(13)+Chr(10)
txt$=txt$+Chr(13)+Chr(10)+"Put transparent sprites (in one frame):"+Chr(13)+Chr(10)+Chr(13)+Chr(10)
txt$=txt$+"16x16="+Str(tm16t/100)+Chr(13)+Chr(10)
txt$=txt$+"24x24="+Str(tm24t/100)+Chr(13)+Chr(10)
txt$=txt$+"32x32="+Str(tm32t/100)+Chr(13)+Chr(10)
txt$=txt$+"48x48="+Str(tm48t/100)+Chr(13)+Chr(10)
txt$=txt$+"64x64="+Str(tm64t/100)+Chr(13)+Chr(10)
txt$=txt$+Chr(13)+Chr(10)+"Put 3d sprites (in one frame):"+Chr(13)+Chr(10)+Chr(13)+Chr(10)
txt$=txt$+"16x16="+Str(tm16d/100)+Chr(13)+Chr(10)
txt$=txt$+"32x32="+Str(tm32d/100)+Chr(13)+Chr(10)
txt$=txt$+"64x64="+Str(tm64d/100)+Chr(13)+Chr(10)
txt$=txt$+"128x128="+Str(tm128d/100)+Chr(13)+Chr(10)
txt$=txt$+"256x256="+Str(tm256d/100)+Chr(13)+Chr(10)


If CreateFile(1, Str(#color)+"bit.txt")
WriteString(txt$)
CloseFile(1)
Else
MessageRequester("Speed test v0.1", "Saved log error!", 0)
EndIf

MessageRequester("Speed test v0.1", "Tested ok !", 0):
End


Loadspr:
LoadSprite(0,"16x16.bmp", 0)
LoadSprite(1,"24x24.bmp", 0)
LoadSprite(2,"32x32.bmp", 0)
LoadSprite(3,"48x48.bmp", 0)
LoadSprite(4,"64x64.bmp", 0)
LoadSprite(5,"16x16.bmp", #PB_Sprite_Texture)
LoadSprite(6,"32x32.bmp", #PB_Sprite_Texture)
LoadSprite(7,"64x64.bmp", #PB_Sprite_Texture)
LoadSprite(8,"128x128.bmp", #PB_Sprite_Texture)
LoadSprite(9,"256x256.bmp", #PB_Sprite_Texture)

Sprite3DQuality(0)
CreateSprite3D(0,5)
CreateSprite3D(1,6)
CreateSprite3D(2,7)
CreateSprite3D(3,8)
CreateSprite3D(4,9)

For a=0 To 4
TransparentSpriteColor(a, 255, 255, 255)
Next a
Return

=================================


At me: athlon 1400, 256mb, GeForce2 MX 400. Such results have turned out:


Win XP:

16 bit & 32 bit
- almost identical numbers!!!

Normal sprites:
16x16=1669
24x24=1651
32x32=1653
48x48=952
64x64=552

Put transparent sprites:
16x16=1654
24x24=1672
32x32=1690
48x48=952
64x64=552

Put 3d sprites:
16x16=737
32x32=749
64x64=242
128x128=65
256x256=17

Win 98:

16 bit:

Normal sprites:
16x16=4205
24x24=3278
32x32=1975
48x48=947
64x64=547

Transparent sprites:
16x16=4097
24x24=3300
32x32=1961
48x48=931
64x64=551

3d sprites:
16x16=1074
32x32=968
64x64=228
128x128=63
256x256=17


32 bit:

Normal sprites:
16x16=2844
24x24=1356
32x32=860
48x48=430
64x64=245

Transparent sprites:
16x16=3321
24x24=1695
32x32=983
48x48=455
64x64=261

3d sprites:
16x16=1203
32x32=430
64x64=109
128x128=29
256x256=7


Why such difference between XP and Win 98? Business really in drivers? (2 difference!!!) and why in XP between 16 and 32 few differences?
fweil
Enthusiast
Enthusiast
Posts: 725
Joined: Thu Apr 22, 2004 5:56 pm
Location: France
Contact:

Post by fweil »

newart,

Just a bit difficult to help you in doing the same tests here.

First when posting your code, do not forget to use Code tag so that it will display well in the post.

Then I don't want to create many sprites for such test, but as you use a defined frame rate it is possible that results will be different on my laptop. Withtout a limited frame rate (by using FlipBuffers(0)), I get usually 300 frames per sencond even when managing some hundreds of sprites up to 64x64.

Depending on the sprite size you use, it is easily understandable to get lower results with larger sprites, and this is linked to your graphical interface which manages sprites with an eventual limitation.

Usually sprites larger that 64x64 pixels are not fast processed.

Then depending on the OS you use, what can you tell about drivers used ? BTW XP supports better drivers usually, but starting in analyzing about the interface board you have will maybe give some answers about interface possibilities and provided drivers on different OS releases.

Just one last thing : have you got your benchmark results using Purebasic source, with or without debugger, or using compiled executables ?

This can make some or many difference in results.

Well, also I would not measure 1/100 seconds loops even using a good PC, it is not large enough to get stable results.
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.
Post Reply