⏱ The Benchmark Thread

Post statistics

Total Read Time: Approx. 18m 20s according to my TTS app. But that includes the mark-down. Spent about three days writing this up lol. Word says 1415 words.
Stats do not include this section.


Prologue - Backstory

Open Prologue

I recently ran a mini non-competitive competition on my other thread, :heavy_check_mark: :coffee:General Conversation Thread for which the results are in this post:

✔ ☕ General Conversation Thread

Or for simplicity here is it again:

SYSTEM NAME OR TYPE CPU MAKE CPU BASE CLOCK CPU PEAK CLOCK CPU CORES CPU THREADS RAM SIZE RAM SPEED STORAGE NAME AND SIZE STORAGE TYPE DEBUG AVERAGE [seconds] RELEASE NATIVE TOOLCHAIN AVERAGE [seconds]
Intel Ghost Canyon NUC Intel Core i9 9980HK 2.4 5 8 16 64 2400 Intel 760p NVMe SSD 8.5 39.5
Microsoft Surface Book 2 1TB Intel Core i7 8650U 1.9 4.2 4 8 16 1867 Samsung MZFLW1T0HMLH-000MU NVMe SSD 12 62.75
Intel Skull Canyon NUC Core i7 6770HQ 2.6 3.5 4 8 32 2400 Intel 660P 1TB x2 RAID-0 NVMe SSD 10 58.5
Intel Forest Canyon NUC DN2820FYKH Intel Celeron N2830 2.16 2.41 2 2 8 1333 Sandisk 120GB SATAIII SSD 56.5 313
Microsoft Surface Pro 2 512GB Intel Core i5 4200U 1.6 2.6 2 4 8 1600 Samsung MZMTD512HAGL-000MV 512GB SATAIII SSD 24.5 127.5
Custom Desktop Intel Intel Core i7 10875H 2.3 5.1 8 16 64 2667 1TB Samsung 970 EVO PLUS NVMe SSD 6 31
Surface Book Core i5-6300U 2.4 3 2 4 8 1867 256GB Likely Samsung NVMe SSD 12 120
ASUS ROG GL752VW Intel i7-6700HQ 2.6 3.5 4 8 16 2133 Samsung MZNLF128HCHP-00004 128GB SATAIII SSD 7 55

Simple Graph:

Detailed Graph:

However, a friend pit me against his 3080 upgrade a few days ago and it got me thinking, One, What’s your result? :stuck_out_tongue_winking_eye: and Two, I have been thinking about discussing and creating Benchmarking in MonoGame for some time now…

For those wondering, I get a nice Time Spy result:

With a 2070 RTX… he got an 18,000~ Graphics score [Not overall, he got 15,000~] with his 3080 RTX, so I cannot wait to afford a 3090 RTX! [My CPU was better]

Do share your results in here! no specs required, just a boasting thing for those who wish to participate! [Or just share the results panels as above]


Chapter One - Goals ¦ Start Here TL/DR

Open Chapter One

The main goal for this thread is code for benchmarking and building a benchmark tool as a generic testing tool! Ideally something as a MonoGame Hello World Compilation Benchmark tool! which benchmarks both the time it takes to compile and then the results for the benchmark results, a two in one goal! where the compilation time is considered! [Of course, you would need a stopwatch for when you click compile until you get the app window running or CornFlowerBlue visible]

I will be utilising UWP throughout as that is my platform of choice when creating software…

However, the code will work regardless of what platform you are on so you could implement the code into your games, which is the goal here. [Though storing data files differs however for Desktop and UWP - and Android and iOS -, we will want to access debug data so likely we can use a conditional compilation symbol {bits of text code to define what is used} to use one of two codes for data storage.]

This would add a benefit to all MGDev projects I think as we can implement and include a benchmark in our game result products! same as any AAA studio!

And the win here is, complete beginners can have this from the get-go!

I have not yet decided on how I will work on this project, GitHub might be an option [I have a pro licence] so, I think that might be a good route, I can work on a private version and share a public version maybe? as I plan to release a fixed version to the store eventually, for free. I may force a licence on the tool where the project must show a specific logo or wording to point out that the code is free so that end users know there is a free version available and should people wish to build on top of the code. And to add to that, it could help grow new users here!

Yes, this is not a play-about project…

So, just getting this thread started for now to get the word out there and see if there is interest in such a project and for the rest of us to boast our systems hehe!, see! all inclusive! I will be going ahead with this project regardless of interaction.

I will likely start my next post discussing basic benchmarking and later go into more advanced discussions of metrics and calculation methods…

For example, a simple test app or code would be displaying simple FPS rates and upgrading it to an average FPS display… with custom fonts support… [Woops I spoke too soon, keep reading]

A more advanced discussion would be having multiple scenes and calculating the various aspects of those scenes, or how to calculate the results into a comprehensible result instead of it looking like a splatter chart… so, something like 1,569 score instead of 20,267FPS total… I have not dug into that aspect yet, but I think it will happen eventually, or we could just take the average per scene and tally that?


Chapter Two - Flashback Note

Open Chapter Two

But yeah [Looks at notes on paper], Before I forget the reason this whole idea exists…

  • Do you guys remember 3D Mark 2000?
Video link here

image
https://www.youtube.com/watch?v=PPPVU3mjcmQ

  • Here’s the full collection for memory lanes sake:
Video link here

image
https://www.youtube.com/watch?v=ovBUb_Yr_iw

  • And an extended edition…
Video link here

image
https://www.youtube.com/watch?v=xs3rnFicHG8

Unfortunately YouTube videos do not function inside the details tags...

Now for me, 3D Mark 2000 was very inspirational, I have ever since wanted to create something like it. It was my first benchmark app, I tested 3DMark99 soon after as well as subsequent ones.

But copying it exact, would be a bit challenging, so I decided to do something in spirit of it, which should tick my fuzzy feelings box or something.

I should add I have some intense books on the subject and will try implementing them into the toolset somehow.


Epilogue - Gifts for Beginners*

Open The Epilogue

To get the beginners reading this, here’s some code to get some FPS going.

*I decided to create another post to keep this one shorter, so the code for the FPS will be posted shortly after this post.

I do hope this inspires people to give something like this a go too… the more the better! and it can make for a lovely showcase and as you will see in the Off-Topic section below, something for practice as well.

That concludes this post, below are some additional thoughts and ideas for discussion.

Thank you for reading.

Valentine.


Off-Topic Topics:

Go Hunting In The Off-Topic Forest 🌲
  • Random Idea One-

I got the idea to run a mini benchmarking competition, not sure what the prize would be, but perhaps a mini MG competition just to test your skills as a personal test? could run it quarterly? This could serve as a practice project for beginners as well just so they can experience how things go together or something.

  • Random Idea Two-

A side question, who would like me to review the various books I have on XNA/MG? hmm I need a webcam… maybe…

  • Random Idea Three-

Is there a way to cascade sections of a post on the forum? [SOLVED]

Look at this link

https://forum.digikey.com/t/an-unofficial-discourse-user-reference-guide/1125#heading--UsingHTML

Yep, looks like there is a way to do that but here’s something handy for beginners on the forum! [The software used for this forum is called Discourse], See below.

Click for the link for the above

https://meta.discourse.org/t/hide-shortcode/25585/12

Here is the raw code view link

https://meta.discourse.org/raw/25585/12
To see how this is done, click on the DigiKey link and read the bottom of the first post there

A general post on the topic here regarding BBCode and MarkDown

Direct link to the start of the tutorial:
https://meta.discourse.org/t/post-format-reference-documentation/19197/2
The listing and link to the tutorial:
https://commonmark.org/help/

Another handy Code link finally just cs

Direct link to a forum thread:
https://meta.discourse.org/t/how-do-i-select-a-language-in-code-blocks/19247

A Final Note

Yes, I do author novels, just slowly now.
And do tell me if you love or hate this format, it takes some time to get it like this, but I believe it is cleaner to navigate.

Another Final Note

I might create a forum post writing app if anyone is interested, I may get on it sooner.

Stats on this post

Total Read Time: Approx. 26m 8s according to my TTS app. But that includes the mark-down. Spent about two days writing this up lol. Word says 2293 words.
Stats do not include this section.


A Basic Non-Blocking FPS display

[Non-Blocking meaning it does not impact your FPS/drawing thread {well, not too much}.]

Welcome to the Overly Detailed Guide on Making an FPS Display and Spritefont Tutorial… I figured I may as well hit two birds with three stones [I know, comedic effect] … so, I hope this helps anyone needing a detailed guide on the matter at hand.

You can begin in Chapter One; the Prologue is just something worth mentioning.

I should add a handy link here

And I know I never used it in this post, perhaps in future.

If you are wondering how code highlighting works:
https://meta.discourse.org/t/how-do-i-select-a-language-in-code-blocks/19247


Prologue - Who Reads This Stuff? ¦ Assumptions About You

Open Prologue

To begin with:

Assumptions About You

Open Assumptions about you

I assume you already have Visual Studio 2019 {VS} [at this point in time] set up and have all the required components installed and ready.
I strongly advise you to take a gander over here: https://docs.monogame.net/articles/getting_started/1_setting_up_your_development_environment_windows.html
To Install the required components for VS and how to get MonoGame {MG} set up and running.

Feel free to ask for tips on how to use the NuGet manager to update your MG installation. I wrote a guide on it recently… somewhere…

Oh, I made a video… https://www.youtube.com/watch?v=gXC0uYh7OVQ&list=PLKTfNvOk8stZ2b4BV6Z4fTaEQyWITk_QI but it’s more about setting up Visual Studio… and me blabbering on for half an hour…

Part two in setting up an MG project is here: https://www.youtube.com/watch?v=mkdrKQ0s6W0&list=PLKTfNvOk8stZ2b4BV6Z4fTaEQyWITk_QI&index=2
I should really redo those videos… and create a video on installing MonoGame via NuGet… or something…

In short, I assume you have your development environment ready to go and you have already run a Hello World app to ensure everything is working.

I also assume you are on Windows 10 and will be using a UWP Project.

I should point out that this code is not optimised, and not fully commented.


Chapter One - Getting Started ¦ Your Project

Open Chapter One

Let’s begin with the blank project template for MG.

  • Start Visual Studio 2019.

  • Create a new UWP MG XAML Project, name it whatever you wish to name it, the name of mine was Game2. Select this project template like so:

image

  • At the top of your screen, select x64 [It may be on ARM by default] and click Local Machine or hit F5 to build your project and ensure everything is working, this will also speed up your next F5 hit. The section in question:

image

Close the running Game2 [Or whatever your project was named] game window.

To begin with, we require a Font… so, let’s make that! Head on over to Chapter 2 for that.


Chapter Two - A Font, My Kingdom for a Font ¦ Making a Spritefont!

Open Chapter Two

OK, so I assume you are familiar with the Content.mgcb… no? let me explain how to find and open it.

Side Note on the MGCB NuGet setup

It is buggy but make sure you ran the command-line script relating to it, found here

Here is it in case the link breaks in future

Install MGCB Editor

MGCB Editor is a tool for editing .mgcb files, which are used for building content.

To register the MGCB Editor tool with Windows and Visual Studio 2019, run the following from the Command Prompt.

dotnet tool install --global dotnet-mgcb-editor
mgcb-editor --register

My understanding on this is, it is so you can open the Editor by clicking the Content.MGCB file in Windows Explorer rather than Visual Studio. Despite what I wrote later on.


First steps to creating a Spritefont

This section helps you understand the various parts associated with the tools required to create a Spritefont, so kind of a workflow structure

Just making sure I cover one step here, a Spritefont is a single image that holds the text your game engine will display to the user, it also helps circumvent certain other issues, more on that later.]

So, in your solution explorer, expand Content:

image

Right click Content.mgcb and select Open With...:

image

Select mgcb-editor-wpf [It may be default already if not we do that here again anyway], click Set as Default on the right and click OK to open the editor. Sometimes you may need to repeat this process [you can skip the Set as Default part and just hit OK] if you close the editor, so refrain from closing it until you close VS. The hope is that it opens when you double click Content.mgcb in Solution Explorer. More on that shortly.

image

It can take a hot moment for the editor to open once you click OK above.

You should see this:

Click Edit>Add> in the command bar:

image

Select New Item:

image

Rename File to PerfFont and select Spritefont Description (.spritefont) and then click Create below.

Side Note On That File Name

You can name it whatever you like, it is your reference to the font, and it has no relation to the font that will be embedded within it later. Though it doesn’t hurt to include a reference to it if it helps with development.


image

Next, you build everything… Click Build>Build or simply hit F6, like so:

image

You can also use one of the shortcut icons:

image

Once built, you should see the following:

image

Should you see anything other than the above, post a support request on the forum, but do try hitting build a few times before doing so.


Specifying the font, we want to use to create our Spritefont

In this section, we dig into the file which assists in creating the Spritefont we wish to use, we also specify the display size of the font

Next, we need to modify the file created, return to Visual Studio and right click the Content folder in solution explorer:

image

And select Open Folder in File Explorer.

Where you should find the following items [You can ignore the folders for the purposes of this tutorial, but do not remove them]:

image

Right click PerfFont.spritefont:

image

And select Open With

image

It is up to you if you keep that check box ticked there, I usually untick it so I can change the tool easier in future. Click where it says More apps.

I use another text editor but for the purpose of this tutorial I shall use Notepad:
Select Notepad or your preferred editor if you have one - or open it using your preferred editor- and click OK.

Once you open this up, we are only concerned at this point in time with the top section as below:

First up, we want to change the font type:

image

Change FontName to Segoe UI or whatever font you prefer, though it must be one that is installed on your system:

    <FontName>Segoe UI</FontName>
SIDE NOTE! There is a whole discussion on Fonts and Game Development

Obligatory IANALS. I Am Not A Lawyer/Solicitor.

Keeping this one short. Basically, when using a font in your game, you must ensure you have a licence for every scenario that font will be used and if not covered by one, you should purchase one. Unless you created it.

This is in no way a complete explanation and you should do your own research on the matter.

With a quick web search for the topic at hand in this detail panel I found:
https://typetype.org/licensing/
Which lists a Videogames licence with a PDF viewable here:
https://typetype.org/upload/iblock/a81/License%20for%20Videogames.pdf

Discovered through this search query. [got to love typos]

Remember, you still require a licence even if you create a spritesheet, and the licence must cover videogame use.

If in doubt, seek legal counsel.


And because I like things to be readable for people like me… let’s set the font to size 16 like so:

    <Size>16</Size>

It should now look like the following:

Save the file and close it.

Go back to the MGCB Editor and hit build again. Leave the editor open and minimise it, if you wish to play around with more font styles or sizes; repeat the edit and build process where you change the font name and the size to use a different font type/size. Remember to hit build in the MGCB Editor whenever you change the Spritefont data.

Once again, should you see anything different, post a support request on the forum, but do make a search for previous related issues first, before creating a new topic.


Finishing up this Chapter

In this section we ensure everything is working thus far

Head back to Visual Studio again.

Now a bit of a side tangent, but if you managed to open Content.MGCB inside Visual Studio, you should be seeing the following, I am adding this here for completion:

Anyway, with that mentioned, let’s hit Build/Run or F5 in Visual Studio, here is that button again for a reminder:

image

Avoid hitting the drop-down arrow.

Did you see your CornFlowerBlue window? good, close it again.

Now, we want to load the font into our Visual Studio project.

Head on into Chapter Three.



Chapter Three - Seeing Things ¦ Displaying the Spritefont

Open Chapter Three

Now that we have a Spritefont ready to go, we need to load it into our game engine.

So, let’s get started!

Adding supportive fields to the Game1 Class.

This section adds fields to the Game1 Class

In Visual Studio, open Game1.cs.

Just so that you are forced to type the following into the program, I will use images here. It should help you get used to memorising the code.

Just below the default SpriteBatch, enter the following:

image

I have included surrounding code, so you know precisely where to enter the code, further code snippets will also include some surrounding code for orientation purposes.

We will have a float struct for the following fields:

  • fps
  • frameTime
  • updateInterval with an initial value of 1.0
  • timeSinceLastUpdate with a default value of 0.0
  • frameCount with an initial value of 0

And a Spritefont:

  • fpsFont

Which we will use later in the program.


Disabling frame rate limits and turning off VSync

In this section we disable the frame limits and synchronisation with VSync

Next in the Game1() method, we add some code to disable the refresh rate sync and uncap the 60FPS limit, however, this is not required for all projects, only for this current project so we can see how many frames our graphics systems can process with just CornFlowerBlue showing:

Next, we load our Spritefont.


Loading in the Spritefont we created earlier

In this section we enter the code to load our Spritefont

In the Initialise() method, we make no changes.

Just past Initialise(), within the LoadContent() method, we load our font like so:

Note that we do not include .spritefont in the name of the font file.

This part has now given us access to the font within the engine, let’s see about displaying it next.


Adding code that helps with the FPS display

In this section we add some code to help with the FPS being displayed

But before that, we require some additional code to give us some data to utilise for the Frames Per Second display.

Move into the Update() method.

This code just assists with some metrics which we use later to display the information we require for the purposes of this tutorial, though it is also useful for the FPS display in your projects too.

Next we add the drawing code to display the FPS on-screen.


Showing the data on-screen

In this section we add the drawing code to the Draw() method

Moving along into the final part, the Draw() method.

Since this is a huge chunk and the image becoming tiny to read easily, I will break it down a little, so ignore the above image and let’s look at what is happening in bits…

First, we are taking a snapshot of the time…

Then we begin our SpriteBatch to utilise our Spritefont to draw the FPS to the screen.

Notice the underscores? _ I used them just for visual effect, you don’t have to use them if you don’t want to, but you will see it makes the data more visible, though I may improve the code in future.

And finally, the last bit we all want to see clearer…

This is not required for the program to work, I just added it for fun when I found the code…

Notice the commented out WriteLine code, this was something I discovered drastically adjusted the drawing rate, no matter where I put the code… I believe when I placed it in Update() I still had a dip in FPS, so until I find another method for active data metric storage, this should work for now. I will be creating something for that in the future.

Did it tell you; you need a new PC?

And that concludes this tutorial.

Open the Epilogue to see what the end program shows.



Epilogue - Seeing is Believing ¦ The Final Result

Open Epilogue

Now, if you run the program, you should see something like the following…

And that concludes this tutorial, I hope you found it useful.


Proofreads all text, forgets to check comments in code, oh well, I hope that tutorial was useful for someone, I will get back to studying now, and see if I can add more here in the coming weeks/months…

Hope you are all doing well.

:sake:

In case anybody missed it in the hidden bits above, this is the thing that sparked this thread 20~ years ago…

Adding Mouse Data

Welcome to another addition to this thread. Let’s get started!

I wanted to see my mouse data and accidently realised MouseState has a handy function…

I am using a font which I have a licence to use. I will likely be using this font for all my tutorials going forward.

Assumptions About You

I assume you have read the first two tutorials in this thread.

Getting it Working

The Meat of the Tutorial - Click to Open

This will be an informal tutorial.

First up:

Add this public field to allow you to use part code in your Update() and Draw() methods.

Next:

Add this to your Update() method to update the data available to the field.

And finally:

You will have to adjust the position Vector2(X,Y) to fit your position on screen.

In the image at the start of this post I have three mouse buttons pressed. The display is 3840x2160, I have more to add to this in future as reaching the full width and height is proving to have strange behaviour.

Hit run and you should be good.

And that should be working as the opening image to this post.

Hope you found this useful.

Latest Data:

SYSTEM NAME OR TYPE CPU MAKE CPU BASE CLOCK CPU PEAK CLOCK CPU CORES CPU THREADS RAM SIZE RAM SPEED STORAGE NAME AND SIZE STORAGE TYPE DEBUG AVERAGE [seconds] RELEASE NATIVE TOOLCHAIN AVERAGE [seconds]
Intel Ghost Canyon NUC Intel Core i9 9980HK 2.4 5 8 16 64 2400 Intel 760p NVMe SSD 8.5 39.5
Microsoft Surface Book 2 1TB Intel Core i7 8650U 1.9 4.2 4 8 16 1867 Samsung MZFLW1T0HMLH-000MU NVMe SSD 12 62.75
Intel Skull Canyon NUC Core i7 6770HQ 2.6 3.5 4 8 32 2400 Intel 660P 1TB x2 RAID-0 NVMe SSD 10 58.5
Intel Forest Canyon NUC DN2820FYKH Intel Celeron N2830 2.16 2.41 2 2 8 1333 Sandisk 120GB SATAIII SSD 56.5 313
Microsoft Surface Pro 2 512GB Intel Core i5 4200U 1.6 2.6 2 4 8 1600 Samsung MZMTD512HAGL-000MV 512GB SATAIII SSD 24.5 127.5
Custom Desktop Intel Intel Core i7 10875H 2.3 5.1 8 16 64 2667 1TB Samsung 970 EVO PLUS NVMe SSD 6 31
Surface Book Core i5-6300U 2.4 3 2 4 8 1867 256GB Likely Samsung NVMe SSD 12 120
ASUS ROG GL752VW Intel i7-6700HQ 2.6 3.5 4 8 16 2133 Samsung MZNLF128HCHP-00004 128GB SATAIII SSD 7 55
ASUS VivoBook S15 AMD Ryzen 7 4700U 2 4.1 8 8 12 3200 512GB SSD - NVMe Kingston OM8PCP3512F-AB NVMe SSD 7.5 44

EDIT

Fixed the graph graphics