Recommended performance values

Which are the recommended performance values to keep an eye on during development? I intend to print some of them on screen just to get a rough idea about the performance.

Classic value is I guess FPS? Anybody has some example code for me which does provide basic info about performance values?

I only print FPS and Garbage Collections 0,1,2 (with GC.CollectionCount )

Most of my other debug prints are not generic (e.g. number of lights calculated / number of lights present, active particle systems, …)

1 Like

How does GC.CollectionCount() work?

int gcgencounter;
...
GC.CollectionCount(gcgencounter++);

Always gives me 0? But I don’t think it should be zero because I am using strings to show the info with spriteBatch.

Ok if I use a static value of 1 it returns higher numbers…

You don’t need to implement your own counter

To call how many GC collection counts just call
GC.CollectionCount(0).

That will show you the total number of collection counts

I keep the update FPS, draw FPS, and accumulated garbage on screen.

// in update loop
float deltaTime = (float)gameTime.ElapsedGameTime.Ticks / TimeSpan.TicksPerSecond;
double updateFPS = 1d / deltaTime;
long garbageCount = GC.GetTotalMemory(false) / 1024;

// in draw loop
float deltaTime = (float)gameTime.ElapsedGameTime.Ticks / TimeSpan.TicksPerSecond;
double drawFPS = 1d / deltaTime;

Then just draw to the screen using SpriteBatch.DrawString().

1 Like

I keep an average fps. This is handy when running at high fps, as when running at 1000 fps monogame can spike either way.

I also set a debug key (f5 or something) to reset the average fps. As once you scroll through your menus (generally run at a high fps) and your in game it takes a while for the average to settle

I also keep a skipped frame counter. Have a separate counter at the end of each update loop and one at the end of the draw loop for fixed fps. The skipped frames will be the difference between them. If your skipping frames then your doing too much computation in a frame somewhere

1 Like

Good idea to have both UPS and FPS.

Good ideas too. Do you have example code for it?