Jump to content

  • Log In with Google      Sign In   
  • Create Account

Interested in a FREE copy of HTML5 game maker Construct 2?

We'll be giving away three Personal Edition licences in next Tuesday's GDNet Direct email newsletter!

Sign up from the right-hand sidebar on our homepage and read Tuesday's newsletter for details!


We're also offering banner ads on our site from just $5! 1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


low perfomance


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
12 replies to this topic

#1 devdber   Members   -  Reputation: 130

Like
0Likes
Like

Posted 17 June 2013 - 08:38 AM

Hello again, i have an another problem with dx11. When i tried to implement my sprite class i spoted that my scene draws slower... i checked fps and it was about 6k when there's nothing to draw and 4.8-5k when single sprite is on the screen... it that problem in my implementation or this is the way it's meant to be?


Edited by devdber, 17 June 2013 - 08:40 AM.


Sponsor:

#2 Brother Bob   Moderators   -  Reputation: 8431

Like
13Likes
Like

Posted 17 June 2013 - 08:49 AM

A drop from 6000 FPS to 5000 FPS is equivalent to a drop from 60 FPS to ~59.9 FPS. Measure performance in linear time instead of non-linear FPS, and the drop corresponds to roughly 30 microseconds, while a frame at 60 FPS is about 17000 microseconds.

 

Don't worry about your 1000 FPS drop from 6000 FPS. Instead, worry when you drop 10 FPS from 60 FPS instead.


Edited by Brother Bob, 17 June 2013 - 08:50 AM.


#3 devdber   Members   -  Reputation: 130

Like
0Likes
Like

Posted 17 June 2013 - 08:53 AM

But i cant understand - is it normal or there's problem?

thanks for your answer



#4 Brother Bob   Moderators   -  Reputation: 8431

Like
2Likes
Like

Posted 17 June 2013 - 09:16 AM

One cannot say anything from those numbers. It may very well be normal and everything is fine with your sprites. It may also be something really wrong, but it's not possible to say because the numbers are so high they really don't have any practical meaning. If you cannot maintain a desired frame rate, then you have a problem.



#5 rip-off   Moderators   -  Reputation: 8516

Like
21Likes
Like

Posted 17 June 2013 - 09:18 AM

It is normal that doing something takes longer than doing nothing.



#6 GeneralQuery   Crossbones+   -  Reputation: 1263

Like
0Likes
Like

Posted 17 June 2013 - 06:00 PM

As others have stated, attempting to read anything from such high frame rates is meaningless other than "doing something takes longer than doing nothing". As a side note, I like to use a more revealing metric such as pixels per second (or megapixels per second) in conjunction with frames per second.



#7 Servant of the Lord   Crossbones+   -  Reputation: 20308

Like
16Likes
Like

Posted 17 June 2013 - 07:24 PM

FPS verses millaseconds-per-frame:

 

As Brother Bob is saying, only gamers measure in FPS, because FPS is almost meaningless. Game developers usually measure the amount of time a frame takes in millaseconds (1/1000th of a second) or in microseconds (1/1,000,000 of a second). At the very least, developers need to understand the difference between FPS and actual frame speeds.

 

Observe:

1 FPS = 1000 millaseconds a frame.

2 FPS = 500 millaseconds a frame.

3 FPS = 333 millaseconds a frame.

4 FPS = 250 millaseconds a frame.

...

10 FPS = 100 millaseconds a frame.

50 FPS = 20 millaseconds a frame.

100 FPS = 10 millaseconds a frame.

 

FPS is a misleading measurement. It's accurate, but can confuse you if you don't understand how it is measured.

 

From 1 FPS to 2 FPS is 500 millaseconds more being taken by every frame.

From 50 FPS to 100 FPS is only 10 millaseconds more being taken by every frame.

 

As Brother Bob said, "A drop from 6000 FPS to 5000 FPS is equivalent to a drop from 60 FPS to ~59.9 FPS". 1000 FPS lost when you are at 6000 FPS, is as small and insignificant as dropping from 60 FPS to 59.9 FPS.

 

"Economies of scale":

 

In addition to all the above, it's also good to remember that sometimes doing something (like drawing a sprite) might have alot of one-time setup costs.

 

Theoretical example: What's the difference between drawing 1 sprite and 5 sprites?

One sprite:

 - Bind shader (let's pretend it takes 20 imaginary time units).

 - Bind texture (let's pretend it takes 10 ITUs).

 - Translate to the location (2 ITUs)

 - Render the sprite (3 ITUs)

 

Total (theoretical) cost: 35 ITUs. Cost per sprite: 35 ITUs.

 

Five sprites:

 - Bind shader (20 ITUs)

 - Bind texture for sprite A (10 ITUs)

 - Translate to location sprite A (2 ITUs)

 - Render the sprite A (3 ITUs)

 - Sprite A and B share the same texture, so we skip rebinding the texture.

 - Translate to the location B (2 ITUs) 

 - Render the sprite B (3 ITUs)

 - Bind texture for sprite C (10 ITUs)

 - Translate to sprite location C (2 ITUs) 

 - Render the sprite C (3 ITUs)

 - Bind texture for sprite D (10 ITUs)

 - Translate to sprite location D (2 ITUs) 

 - Render the sprite D (3 ITUs)

 - Sprite D and E share the same texture, so we skip rebinding the texture.

 - Translate to sprite location E (2 ITUs) 

 - Render the sprite E (3 ITUs)

 

Total (theoretical) cost for 5 sprites: 55 ITUs. Cost per sprite 11 ITUs.

 

When worried about your program's performance:

 

There's a general rule of thumb programmers have for when looking at the speed of your program: "Don't look at the speed of your program."

Or rather, the actual statement is, "Don't optimize prematurely". Make what you are going to make, and if (when all the fancy numbers are hidden) it noticeably runs too slow, then optimize to make it faster. But if your game runs fine, ignore the numbers, focus on the gameplay. You might even want to hide the numbers (like millasecond framerates and FPS), just so you aren't distracted by them, and only turn the numbers on when it starts to feel too slow. Then you use a profiler and see what parts are actually taking the most time (don't guess - measure with a profiler), then fix those areas.

 

Also, when worried about performance, make sure you are running in "release mode" rather than "debug mode", because debug mode adds in alot of extra invisible code to help with debugging, that sometimes make your program run slower than it'll actually run when released to users.

 

tldr: Yes, your program is working fine. laugh.png


It's perfectly fine to abbreviate my username to 'Servant' rather than copy+pasting it all the time.
All glory be to the Man at the right hand... On David's throne the King will reign, and the Government will rest upon His shoulders. All the earth will see the salvation of God.
Of Stranger Flames - [indie turn-based rpg set in a para-historical French colony] | Indie RPG development journal

[Fly with me on Twitter] [Google+] [My broken website]

[Need web hosting? I personally like A Small Orange]


#8 0r0d   Members   -  Reputation: 819

Like
0Likes
Like

Posted 17 June 2013 - 08:26 PM

But i cant understand - is it normal or there's problem?

thanks for your answer

It's normal.  When you're doing basically nothing the render loop will run insanely fast.  This is what you'd expect, right?  Then you do something, even rendering a single triangle, will cause the framerate to drop significantly.  Like others already pointed out, it's because you were already spending a tiny amount of time on each frame, and now you're spending a tiny amount plus another tiny amount.  If that new tiny amount is 2x the previous tiny amount, it means that your framerate is now 1/2 what it was before.



#9 frob   Moderators   -  Reputation: 22235

Like
5Likes
Like

Posted 17 June 2013 - 11:44 PM

As SotL pointed out above, actual time is a much better metric.

My preference is a trio of numbers, updated once per second:

Min microseconds / avg microseconds / max microseconds.

For your app it would look something like this:

150 / 180 / 190

And before your change it probably looked something like this:

145 / 160 / 190

As long as the numbers are less than 10'000 or so you don't need to be overly concerned.

If they last number is much bigger than the other two then you need to worry; that means one frame is stalling and you need to fix it. ('Much' bigger meaning several thousand microseconds.)

Otherwise, just learn that all code has a cost. In practice, the actual cost is typically much smaller than you expect.

Check out my book, Game Development with Unity, aimed at beginners who want to build fun games fast.

Also check out my personal website at bryanwagstaff.com, where I write about assorted stuff.


#10 swiftcoder   Senior Moderators   -  Reputation: 10236

Like
1Likes
Like

Posted 20 June 2013 - 09:19 PM

massive wall of awesome...

I think you should seriously converting that to an article.

I'd click the magic moderator "promote to article" button, but I don't want to steal your thunder smile.png

Tristam MacDonald - Software Engineer @Amazon - [swiftcoding]


#11 Servant of the Lord   Crossbones+   -  Reputation: 20308

Like
0Likes
Like

Posted 21 June 2013 - 05:20 PM

I think you should seriously converting that to an article.

Alright, I'll do so sometime this week.
It's perfectly fine to abbreviate my username to 'Servant' rather than copy+pasting it all the time.
All glory be to the Man at the right hand... On David's throne the King will reign, and the Government will rest upon His shoulders. All the earth will see the salvation of God.
Of Stranger Flames - [indie turn-based rpg set in a para-historical French colony] | Indie RPG development journal

[Fly with me on Twitter] [Google+] [My broken website]

[Need web hosting? I personally like A Small Orange]


#12 devdber   Members   -  Reputation: 130

Like
0Likes
Like

Posted 23 September 2013 - 12:14 PM

wow thank you people  smile.png



#13 Servant of the Lord   Crossbones+   -  Reputation: 20308

Like
1Likes
Like

Posted 23 September 2013 - 12:50 PM

I forgot to post a link previously, but the post above was later turned into an article here:

 

Performance: Why did I just lose 100 FPS by drawing one triangle/sprite?


It's perfectly fine to abbreviate my username to 'Servant' rather than copy+pasting it all the time.
All glory be to the Man at the right hand... On David's throne the King will reign, and the Government will rest upon His shoulders. All the earth will see the salvation of God.
Of Stranger Flames - [indie turn-based rpg set in a para-historical French colony] | Indie RPG development journal

[Fly with me on Twitter] [Google+] [My broken website]

[Need web hosting? I personally like A Small Orange]





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS