Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / Set Sprite Visible Set Sprite Active performance?

Author
Message
flexusjan
10
Years of Service
User Offline
Joined: 15th Jan 2014
Location:
Posted: 3rd Feb 2014 13:45
Hey Guys

If I have an empty Screen, I have ~1300 FPS on my Notebook.

If I generate 1000 Sprites, then I make this...

.. on each sprite. I get ~600 FPS.

If I generate more sprites the FPS get even lower...


Is there a reason for this? or is that a bug?
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 3rd Feb 2014 18:52 Edited at: 3rd Feb 2014 18:55
do u disable it once or maybe every sync loop?

maybe SetSpriteActive belongs the physics engine if you use this
also for ,0

AGK 108 (B)19 : Windows 8.1 Pro 64 Bit : AMD Radeon HD 6670
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 4th Feb 2014 09:28
SetSpriteActive is for animation and physics. If the sprite is set to not visible and not active I would expect it to not cause any slow down so yes I would say it is a bug. I may have to re-think one or two of my systems if this is what is happening.

oct(31) = dec(25)
flexusjan
10
Years of Service
User Offline
Joined: 15th Jan 2014
Location:
Posted: 4th Feb 2014 09:47
Quote: "do u disable it once or maybe every sync loop?"

I disable activity and visibility only once.



Okay I think, that`s a Bug!
flexusjan
10
Years of Service
User Offline
Joined: 15th Jan 2014
Location:
Posted: 4th Feb 2014 10:19
Digital Awakening
AGK Developer
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Sweden
Posted: 4th Feb 2014 11:14
If you look at it, it's no big deal. Going from doing nothing to handling 1000 invisible sprites you double the time per frame. Gonna require a lot of sprites to get it below 60 FPS. Why AppGameKit doesn't completely ignore these sprites I do not know.

Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 4th Feb 2014 11:31 Edited at: 4th Feb 2014 11:48
i see no much difference,my pc has ~ 10000 frames

(1300 frames = 0,79 ms each frame,
600 frames =1,66 ms each frame,
you loss 1 ms for something...)



AGK 108 (B)19 : Windows 8.1 Pro 64 Bit : AMD Radeon HD 6670
JimHawkins
15
Years of Service
User Offline
Joined: 26th Jul 2009
Location: Hull - UK
Posted: 4th Feb 2014 11:40
Internally it obviously still has to access the sprites to see if they are active or not, unless it keeps two lists - active and not active. Only Paul can answer that.

-- Jim - When is there going to be a release?
TDavid
11
Years of Service
User Offline
Joined: 7th Feb 2013
Location:
Posted: 4th Feb 2014 13:29
What fps do you have when they are visible and active?
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 4th Feb 2014 17:09
flexusjan, I looked at your bug list post. While no longer a Community Tester (CT), I would like to comment that you need to clarify the version of AppGameKit you are using. Saying it is 108 is not enough. There are 21 108 versions.

Also, you mention testing in multiple platforms. Do you mean that you are testing via a Player or that you built the project and installed and tested it on all the platforms?

Finally, please supply complete code that demonstrates the problem. Simply saying what it is is not enough. A CT can create a test case, but it might not show the issue in the same way that your code does. It is not uncommon for a CT to test supplied code and be able to determine that it is a coding issue and not an AppGameKit issue.

Cheers,
Ancient Lady
AGK Community Tester and AppGameKit Master
flexusjan
10
Years of Service
User Offline
Joined: 15th Jan 2014
Location:
Posted: 5th Feb 2014 08:21
Excuse me, this is my first bugreport.

I have added the used OS.
And I have added the used version of AGK.
And I have wrote an examplecode.



Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 5th Feb 2014 17:21
what happens if you disable physics or rem this line SetSpritePhysicsOn(i, 1)?

for i = 1 to 10000
SetSpriteActive(i, 0)
SetSpriteVisible(i, 0)
SetSpritePhysicsOff( i)
next i

AGK 108 (B)19 : Windows 8.1 Pro 64 Bit : AMD Radeon HD 6670
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 5th Feb 2014 17:28
flexusjan, excellent demo code.

I don't know what the current Player version is in the Playstore. If it is v10821, than that might be part of the issue.

After I get back from work tonight, I'll try to see how your code behaves on my devices (I have v10819 Players built for Android and iOS and multiple devices to play on).

Cheers,
Ancient Lady
AGK Community Tester and AppGameKit Master
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 6th Feb 2014 05:39 Edited at: 6th Feb 2014 05:46
Well, I tried to test on my devices.

I was able to run your test code on my PC and got about what I would expect. Fastest with no sprites created, next fastest with hidden sprites and slowest with visible sprites.

But, I cannot get my setup to work with broadcasting at the moment. I am currently living in a hotel (until at least mid-April). I tried connecting via my hotspot on my phone, but it didn't get through.

If I can get the broadcasting to work, then I will test again.

This is the code I tested with. It gets the average FPS for each stage and then displays the results at the end.


Cheers,
Ancient Lady
AGK Community Tester and AppGameKit Master
TDavid
11
Years of Service
User Offline
Joined: 7th Feb 2013
Location:
Posted: 6th Feb 2014 14:06
Question related to the topic (somehow): I read there is a memory leak with the deletesprite function and that it is better performance-wise to make them invisible instead of deleting them. Is it true?
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 7th Feb 2014 03:44
TDavid, if you expect that you will be using the sprite more than once, definitely make it invisible and also move it outside the play area so that nothing accidentally interacts with it (invisibility doesn't stop physics and such).

Cheers,
Ancient Lady
AGK Community Tester and AppGameKit Master
flexusjan
10
Years of Service
User Offline
Joined: 15th Jan 2014
Location:
Posted: 7th Feb 2014 10:25
For my current game I need many sprites. Most of them are out of the screen. This sprites must be invisible but still have physic an collisions.

With this "bug", it's quit impossible for me to develop with acceptable performance....
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 7th Feb 2014 11:50
AGK is more than fast enough for most 2D games. It's probably just a case of finding a better way to do what it is you need to do.

I have hundreds of sprites loaded in a single level with around 120 fps easily. Just how many sprites are you loading?

Optimising game code is all about small tweaks to improve performance and you need to constantly be thinking of small improvements to achieve a really great framerate. My own animation system for example is about to get a massive leap in performance because of an idea I had to improve one simple calculation. My lighting system also only calculates lighting for objects that are within a certain distance of the edge of the screen to get a measurable difference in performance.

oct(31) = dec(25)
Matty H
16
Years of Service
User Offline
Joined: 7th Oct 2008
Location: England
Posted: 7th Feb 2014 16:19 Edited at: 7th Feb 2014 16:20
This is not a bug. As Jim says, agk may be looping through all sprites to check things like active/visible etc.

I would suggest that if all your sprites are off screen most of the time then you don't need sprites? Sprites are useful for being on screen only, an off-screen sprite may as well not exist, I mean the rendering part, not the positional/rotational data etc

It's hard to say what you should do without knowing more, but some sort of sprite creation when a sprite enters the screen may be the way to go. Or just have 100 sprites but change their image/size/position etc depending on what they currently represent?

Login to post a reply

Server time is: 2024-11-25 01:35:09
Your offset time is: 2024-11-25 01:35:09