Replace SimpleJSON with something else to increase performance

What to use? How to improve writing/reading performance? Is there anything else other than SimpleJSON?

How often are you reading and writing to a JSON? Once you read the data, simply stick it into a regular C# class. Only write to JSON when you need to save the data. Players are used to waiting a few moments for games to load or save.

If you really need extra performance, run it through the profiler.

1 Like

We have fast paced mobile game where saving have to happen at the end of every round which is roughly every 10 seconds or so. JSON is doing its thing for seconds and it’s annoying to see how the game freezes when it happens, it just eats all CPU.

You could try XML? I think there’s a way to stream data, though, in real time. Maybe an external dll is needed? Not sure…

How much data are you saving? I use json.net and haven’t had hang ups that I noticed. JsonUtility which is Unity’s json is suppose to be fast, though I haven’t tried it.

Seconds freezing is a big deal. Do you need JSON? Straoght binary serialisation will be faster. (But less robust against changes.)

I would still challenge your saving frequency. Why not just hold the data in memory and then save out after several minutes.

I was tempted to respond to this thread yesterday, and had the same thought as @Kiwasi ; why force a save every 10 seconds? Find some useful timed/key moments to do the save, at the small risk of a crash inbetween one(or even a few)… Much better compromise for a smoother running game, I’d guess.

We used LitJson, and it only takes anything in the “seconds” range when we’re deserializing multi-MB json files. I would be absolutely shocked if you actually need to save that much data at all for a save-game, let alone every 10 seconds. I think you ought to find ways to reduce unnecessary data being saved.

One option for the repeating saves would be to only save things that have changed in the last 10 seconds.

1 Like

Thanks for the answers everyone, it looks like we’ll have to change our methods after all.