A Productive weekend - Saving now 3-4 times faster
February 03, 2013
This week we discussed saving times on the KPhotoAlbum IRC channel, which made me give it a shot at rewriting the saving code from QDom to QXmlStreamWritter. I had a hunch that it would give quite some nice improvement in saving speed.
Now, if you have ever participated in one of my Qt training classes, you will likely have heard me say something like NEVER EVER trust your own hunches on where time is spend in your applications, USE A PROFILER!. Rewriting the code resulted in a disappointing 10% time reduction on saving, not the 50% or more I had hoped for. Sigh! Why do I never listen to myself?!
OK, so when I had callgrind and kcachgrind in action anyway, I could just as well look at what made it relatively slow at saving, and I found, not surprisingly, that it spend quite a bit of time in places I wouldn't have guessed in a million years. I got an impression 18% reduction simply by caching whether the XML file should be in compressed or readable format.
In total, depending on format used, and whether your KPhotoAlbum is build in debug or release mode, I got a reduction of time spend when saving between 62% and 73%, which means a speed up of 3-4.
Saving now takes less than 400ms on my database with 13800 images (of which more than 95% are tagged). I guess it will be a while before I need to revisit the speed of saving :-)