Simple Performance Test is a stub project to enable GameMaker developers to quickly set up and run performance tests comparing two snippets of GML code to see which is the faster.
Ever wanted to know which way of coding your project will run faster?
Want to understand GML better?
Use Simple Performance Test to compare two blocks of GML code, and prove which is faster.
Don’t guess at which code is better optimized, test it and know!
It’s completely free!
Here’s a quick tip for performance throttling in GameMaker.
Say you’ve got some code that you need to execute frequently, but if the game starts slowing down too much, you can live without executing this block of code.
Like, for example, say you want to spawn a new instance of some object very frequently, such as in the Step event, but if performance starts to lag you can skip it. You could try to test out how many instances the game can handle without frame rate dropping to an unacceptable level, and cap the number to something somewhat below the maximum. The problem is that this number will vary depending on the hardware. Someone running your game on an older, slower machine will not be able to sustain the same performance that someone with a brand new, high end machine. There really isn’t a true, one-size-fits-all number that works for every situation.
What you really want to do is base the cap on the current performance of the game as it’s running right now. To do that, wrap it up in an if statement like this:
if room_speed < fps
//keep doing the thing that will eventually cause performance issues
The way this code works, as soon as
fps drops below
room_speed, it will stop doing the thing that contributes to the performance problem. This technique does not guarantee that
fps will never drop below
room_speed, but it will cause performance to stop degrading by not contributing to the problem once performance has degraded to the point that the conditional check takes the “false” branch.
If you don’t want ANY noticeable performance degradation, you may want to make the conditional check be something more like
if (room_speed + 10) < fps
instead; this will give you a little buffer to keep the fps enough above room_speed that you should not see any noticeable performance problems. Or, substitute the calculation
room_speed + n with the literal value that you don’t want
fps to drop below. Use this to ensure a safer margin of acceptable GameMaker performance.
A few days ago, YoYoGames released some new features in the beta channel that will be a part of GameMaker Studio 1.2. I took a few minutes today to test out the new YoYoCompiler.
I tried rebuilding my Radar demo project with the YYC, and found that I was able to get up to 8000 objects with it still running at ~30fps on my workhorse Lenovo Thinkpad T61p, 2GHz Core2 Duo, 8GB RAM, purchased in 2007. When I tried to run 40,000 objects in my radar demo, fps dropped to around 6-7. Presumably on a modern Core i7 CPU, one would expect to achieve much greater performance than this.
Using the old compiler, on this same hardware I was getting about 27-28 fps with just 4000 objects in my Radar demo, so it looks like the new compiler is giving about a 200% performance boost for this project. Not bad!
Of course the exact improvement depends greatly on the implementation details of a specific project.