big speed hit ...
BlitzPlus Forums/BlitzPlus Programming/big speed hit ...
| ||
look at these 2 code, it's the same, only difference is that i copyrect to an imagebuffer instead of the same backbuffer, there's a big speed difference beetween the 2 i wonder why ... anyone have tips about that ? or it's a bug ? Graphics 800,600,32,0 Dim x(100),y(100) For a=0 To 100 x(a)=Rand(800) y(a)=Rand(400) Text x(a),y(a),"this is a test" Next Repeat Cls For t=0 To 100 x(t)=x(t)+Rand(5)-3 y(t)=y(t)+Rand(5)-3 Text x(t),y(t),"this is a test" Next For a= 1 To 100 CopyRect 0,400+a,800,1,0,600-a Next Flip Until KeyDown(1) And Graphics 800,600,32,0 miror=CreateImage(800,100) Dim x(100),y(100) For a=0 To 100 x(a)=Rand(800) y(a)=Rand(400) Text x(a),y(a),"this is a test" Next Repeat Cls For t=0 To 100 x(t)=x(t)+Rand(5)-3 y(t)=y(t)+Rand(5)-3 Text x(t),y(t),"this is a test" Next For a= 1 To 100 CopyRect 0,400+a,800,1,0,100-a,BackBuffer,ImageBuffer(miror) Next DrawImage miror,0,500 Flip Until KeyDown(1) anyone have an idea of why such a speed difference ? i'm using b+ on 1.4 ghz P4, radeon 9600 |
| ||
Obviously you are performing two drawing operations with the second example. One draw to the buffer, one to the screen. In the first example you are only performing one draw. Second example will be half as fast. |
| ||
it's not the reason, it seem that drawing operation to an imagebuffer is wayyyy slower than a drawing operation to mainscreen buffer as i added in the code the drawimage command to check if it's why i have an as big speed hit also, note that i do 100 time the copyrect stuff and just 1 more drawing operation in the second example, so the speed hit would be 1 percent more... Graphics 800,600,32,0 miror=CreateImage(800,100) Dim x(100),y(100) For a=0 To 100 x(a)=Rand(800) y(a)=Rand(400) Text x(a),y(a),"this is a test" Next Repeat Cls For t=0 To 100 x(t)=x(t)+Rand(5)-3 y(t)=y(t)+Rand(5)-3 Text x(t),y(t),"this is a test" Next DrawImage miror,0,500 For a= 1 To 100 CopyRect 0,400+a,800,1,0,600-a Next Flip Until KeyDown(1) |
| ||
miror=CreateImage(800,100,1,2) See the loadimage docs for new Image flags in BlitzPlus, does the above parameters speed it up? |
| ||
Sorry, I overlooked the 100 For/Next loop. |
| ||
uh right skidracer :) thanks... but i didn't know there's new flags... my fault i had to read more the docs :op Graphics 800,600,32,0 max=255 Dim x(max),y(max) For a=0 To max x(a)=Rand(800) y(a)=Rand(600) Next Repeat Cls For t=0 To max Color t,t,t x(t)=x(t)+Rand(5)-3 y(t)=y(t)+Rand(5)-3 Text x(t),y(t),t Next Color 20,20,40 Rect 0,500,800,100 miror=CreateImage(800,100,1,2) Stp#=1 For a= 1 To 100 z#=z#+Stp# CopyRect 0,400+a,800,1,(100-a)*Cos(z#),100-a,BackBuffer,ImageBuffer(miror) Next z#=z#-99*Stp# DrawImage miror,0,500 FreeImage miror Flip Color 255,255,255 Until KeyDown(1) work better :)) thanks |