CCDictionary lame performance

NSDictionary takes ~400ms to load a plist with 160k lines while CCDictionary takes 4 seconds (in iOS)

Isn’t there anything that you can do to speed that up?

what a shame :stuck_out_tongue:

I think it’s very important to improve this… plists are used everywhere in cocos…

I have noticed that in the iOS simulator my dictionary loads pretty quick.
On Android and Win32 it takes much longer.
I’m very surprised that the Win32 is so slow, not so much the Android version.

This is using cocos2dx on all platforms btw.

Both my level list and the level info itself are in plist format so hard to get away from it.

It looks like the iOS uses an NSDictionary in the back end.
Win32 and android versions both use CCSAXParser as far as I can tell.

Adam, you cant trust the emulator speed…

BTW, iOS uses NSDictionary, but the worst is that it makes a copy of the NSDictionary to construct a CCDictionary, key by key, and that is very slow. It should not be that NSDictionary is 5 times faster than our CCDictionary… in cocos2d you need the plist almost mandatory for many things like: spritesheets, level design, localization, etc…

so I think a better CCDictionary is necessary, otherwise we will have to use NSDictionary on iOS and I don’t know what in Android… so then the engine is not cross platform at all… :frowning:

I would expect the win32 version (running native) to be faster than the iOS simulator version if the code was equal.

It looks like the NSDictionary is faster than SAXParser at reading XML files.

This prompted me to open source my working version of plist reader/writer : https://github.com/FrancoisDupayrat/PListPersist

It uses pugixml under the hood, which is a light-weight C++ xml processing library. I didn’t really benchmarked my implementation for speed, it may be faster than cocos2dx implementation if you wish to try it.

I just copy/pasted the code I use and remove most of the non-relevant code. It was not supposed to be used as a library originally, so the Android version is not functional out of the box (you just have to provide it the Activity to get the files directory). I assume porting it to other platform will be trivial since the only requirement is the path to where to save.

François Dupayrat wrote:

This prompted me to open source my working version of plist reader/writer : https://github.com/FrancoisDupayrat/PListPersist
>
It uses pugixml under the hood, which is a light-weight C++ xml processing library. I didn’t really benchmarked my implementation for speed, it may be faster than cocos2dx implementation if you wish to try it.
>
I just copy/pasted the code I use and remove most of the non-relevant code. It was not supposed to be used as a library originally, so the Android version is not functional out of the box (you just have to provide it the Activity to get the files directory). I assume porting it to other platform will be trivial since the only requirement is the path to where to save.

I appreciate this, but I think the solution should be an official high performance and cross platform CCDictionary

Any improvements on this yet? :slight_smile: