JSON Performance Tests Round 2
By Thom McGrath on
After some community feedback, I decided to re-run the tests with three changes. First and most importantly, this round of tests was done with built apps, not using the debugger as the last set of tests did. Second, I added the JSONMBS class to the mix. While that class won't be acceptable for my app, there is merit in comparing how it performs. And finally, I added the M_JSON module, which is JSONItem_MTC's replacement for Xojo.Data.
The results are fascinatingly different.
In all tests except Xojo.Data, Windows outperformed the Mac, likely due to the shear higher clock speed of my PC. I'd have to setup Boot Camp on the Mac to negate that difference, which is not something I'm willing to do for this test.
MBS is the clear winner here by a large margin, but the JSONMBS class is not a drop-in replacement for any style of JSON currently used by Xojo. If you're starting a new project and can use the MBS plugin, use the JSONMBS class. But those looking to switch to it to gain performance are in for substantial refactoring. Update: Christian Schmitz has informed me that he has an example wrapper class to make JSONMBS compatible with JSONItem.
JSONItem_MTC performs roughly 6x faster on the Mac and 13x faster on Windows than in the debugger. M_JSON technically tested faster, but I'd call them effectively equal.
Neither the classic JSONItem or new framework Xojo.Data saw any performance improvements from building the app. While the new framework results are unsurprising, I was expecting to see a performance increase in the classic framework.
For my specific use case, I could roughly double my parsing speed on Windows, though sacrifice performance pretty significantly on Mac. But given that Windows is the vast majority of my userbase, that might be acceptable. Though that MBS speed is mighty tempting, it just doesn't fit into my usage requirements.
Results line up pretty much the same as the parsing test. MBS once again crushes the competition, JSONItem_MTC sees a substantial improvement over debugger code, and the built-in options see no performance improvements.
In my case, switching to anything but the one that isn't an option for me will really hurt performance.
No real surprises here. Xojo.Data is able to keep pace with JSONItem_MTC because both use Xojo code to perform the final processing. MBS, being a plugin, once again has the clear performance advantage, and the classic JSONItem is just awful.
As I wrote earlier, for new projects that will need JSON, can use plugins, and afford the MBS plugins, JSONMBS is hands-down the right choice. In every test it outperformed every other option by a large margin.
For existing projects looking to gain some speed over JSONItem, switch to JSONItem_MTC. It consistently outperforms JSONItem, and refactoring work is minimal.
Those willing to suffer the new framework where MBS is not an option should use the Xojo.Data methods. They perform exceptionally well, but have a significant convenience cost. You'll need to constantly swap between
String to ensure that your performance gains aren't wiped out by the downright awful
Text performance on Windows.
And the classic framework JSONItem has no use-case at all.
( 173.0 KB )