Loading from xml,
I can load one room in 2.1 seconds. (2 secs per room)
But when I add that same room again, load time is 5.7… (3 secs per room)
4 of these rooms takes 18.65, (4.5 secs per room)
8 rooms takes 65 seconds! (8 secs per room)
Things seem to happen the correct amount of times. The code does not seem to loop more times than it should…?
Is this normal for XML? does load time increase exponentially with size? I doubt…
Is this pure xml load or with game logic? If it is with the game logic then try to benchmark only xml load times. Only narrowing down the problem will show what is causing this.
I am instantiating objects from load… But that SHOULD only create linear increase in load times. Not exponential… But since I don’t know anything about XML, I don’t REALLY know if that is a feature of the XML format… One could imagine it being flexible, but not super scalable.
So yea. Since the answers I was looking for aren’t just being delivered right to my lap, I’m currently reworking the save/load system pretty much from scratch to see if I just had bad code… Google was no help. Every example is simple customer or product catalogs, and third party libraries
XML is just a data format. There’s nothing about it that will double every time you read it. Einis is right, you should benchmark parsing the file, instantiating objects, drawing objects, etc. to narrow down which part is taking longer.
I had a same kind of issue once. The problems happened due to bad design of how my systems worked toghether.
So the way it happened:
I deserialize a file into a certain class. Apparently that class was asking another system for some data. Now that system was defined as a singleton or a static class or something, I don’t remember100%. That same system was initialized by loading a big bunch of data.
Now what I think that would happen: the system loads once, and the other classes can request data from the loaded system.
But what happened: every time I deserialised a file into an object, the deserialization process would create a new instance of the system, thus loading the big bunch of data every time… and so making deserialisation a LOT (100x) longer than it should.
This might be the problem, or maybe it’s something totaly diffrent. Worth checking out anyway.
Hope this helps.
Thanks guys. I reworked the whole dang thing.
I can’t even explain what happened…
It was faulty code reading from xml. I was basically reading the whole xml doc from the beginning for every object, until I came across the object to load… So as the file size grew, more and more data had to be examined for each object.
What I mess… Now decreased file-size, and super-fast load times. Sometimes you just have to get off the internet, and sleep on your desk for a day or 2.
That O(n^2)… it’ll get ya!
Glad you got it figured out!