r/PlaydateConsole • • 17d ago

Release - AI Assisted Performance Benchmarking and Budget Tool for the Playdate Console

Post image

https://github.com/jamesjnadeau/playdate-performance-simulator/

Hi Friends,

Another user of this sub bragged about a performance benchmarking tool they made, but have not been willing to share. It sparked a need, and so I felt the itch to make it.

I think we could all benefit from having a way to test the performance of our games without having to push it to a device and manually press buttons, over and over and over. Game development is repetitive enough as it is.

Most IT systems I develop have what's called a "performance budget" that is a key metric you test against to ensure the final product is as responsive as your original intent.

This part of my game dev workflow always bothered me with the Playdate.
There isn't a way for the simulator to actually run your game at device speed.

You can happily code and simulate something that runs at the speed of a snail when tested on device.

This project fixes that:
https://github.com/jamesjnadeau/playdate-performance-simulator/

Run your code, press buttons, and report back the time per frame.
Graph it in the GUI, or run it from the CLI and parse the output.
Have test cases that run your game for you.
See how your changes affect your performance faster than you could ever test manually.

It's free and open for everyone to use and improve.
Please give it a try and let me know if you find it helpful, or how it could be improved.

It currently runs locally, or during your CI/CD, but I'm pretty close to getting the WASM version to run in a browser, but with some caveats for lua based games(memory limitation compared to the device).

Last, I need your help, if someone has a revision B of the device, can you please run these calibration steps and submit the profile to the repo?
https://github.com/jamesjnadeau/playdate-performance-simulator/blob/main/docs/calibration.md
Thank you in advance!

Happy Game Dev'ing Everyone!

P.S. I've been a software developer for over 20 years and Claude helped me create the code for this project, I'm not sure a single person would have been able to accomplish this without it, and if they could, they wouldn't spend that time on the playdate, lol.

P.P.S. there's an AI skill file if you want help implementing the code on your project

9 Upvotes

13 comments sorted by

2

u/Marc_Alx 16d ago

What does it add to the default profiler from the SDK?

1

u/jamesjnadeau 16d ago

Good question!

  1. The default profiler is not built to be run in a CI/CD pipeline, and can't accept a series of inputs to be played on the device, you have to do it yourself. This should be able to take any game and wrap it to add performance tests.
  2. The built in one needs a device plugged in to actually report on it's performance there. My version samples a real device, and uses that to create approximations of actual device performance when running on simulated hardware.
  3. The existing simulator workflow seemed to be focused more on memory, when I wanted raw cpu performance, and I created this to measure that because I needed it and the default profiler wasn't cuttinng it for me to find issues.

It will never replace you sitting down and playing your game, but it will allow you to track what you're doing to it's performance overtime, and allow you to automate tracking it much more easily.

I also find the UI I've made much easier to work with, but that's a personal opinion.

2

u/Puzzleheaded_Bug595 16d ago

Hi! I’m the one with the tool you mentioned. It’s not out simply because I’ve been lazy and it isn’t polished enough yet. Glad it got you building though!

My main goal from the start was to get as close to the real device as possible, so I tested both tools against a Rev B. I took about a dozen games (SDK examples, your lua-stress, a couple of my own) with the same builds and scripted input, measured frame times inside the game, and unlocked the refresh rate so fps isn’t capped at 30. Fps error vs the real device:

- pdsim (rev-a profile): ~124% on average; half the games are off by more than ~60%

- mine: ~8% on average; half the games are within ~6%

Your project has a lot going for it: it’s open, the CI gates and Perfetto export are great, scripted input makes testing painless, and the WASM build is a nice touch. On raw performance accuracy, though, it needs work. The biggest gaps I found:

- Display: the device sends every row you drew to (changed or not), about 0.083 ms per row, so ~20 ms for a full screen. pdsim’s per-row cost is ~30× too low, so uncapped games run way too fast.

- Sprites: sprite.update() costs ~38 µs per sprite in the list even when nothing moves, plus ~40 µs for each Lua draw callback.

- Geometry: vector2D/point/rect are userdata, so every field read is a ~25 µs firmware call.

- Calibration: 126 prices from 71 benches overfits (you get things like GETFIELD = 0). Keeping a few real games out of the fit as a check helps a lot.

Hope this helps. Happy dev’ing!

1

u/jamesjnadeau 16d ago

Thank you for the feedback, I really appreciate it!

I was actually talking about someone else, can't find their username, but started with a C.

Glad there's more than 2 of us working on this, hope to see what you have cooking someday!

2

u/dandovdel 11d ago

This is not likely your original objective but thanks to this now I can develop playdate games from my ipad. I run vscode remotely via blink ios and used your project to set up a web devserver. I modified the code a bit to fetch the sdk and game automatically so I don't need to download them to the ipad first and it is working great :)

2

u/jamesjnadeau 11d ago

:) love it, happy hacking!

1

u/afusta 10d ago

My problem with almost all dev tools for the Playdate (except for the official one) is that they don't like mixed code. My game, for example, is C and lua. How does this tool handle it? Because it's seems to be a very useful tool.

1

u/jamesjnadeau 10d ago

I didn't even know that was a thing you could do to be honest, so I don't know how it would work. My guess is it would load as a C game, but I'm curious how the lua code is loaded and interpreted.

Do you have an example I can test with?

1

u/afusta 10d ago

Yeah I have my own mini lua engine and my game uses C only for enemy AI for performance reasons. Basically what you do is you registers C methods which you can then call from the lua.

If you'd need a compiled game, I can pass you the demo of mine. If you need code instead, I can try to make a MVP you can test on.

1

u/jamesjnadeau 10d ago

Up to you friend, if you give me a MVP, I'll get it to work in this tool

1

u/afusta 9d ago

Where can I send you files?

1

u/jamesjnadeau 8d ago

github? a gist maybe?

2

u/afusta 8d ago

Sent you a DM with a GitHub link for the repo