SFML community forums

Help => Graphics => Topic started by: slotdev on May 15, 2011, 10:45:26 pm

Title: Image::LoadFromFile very slow
Post by: slotdev on May 15, 2011, 10:45:26 pm
Hi

I've just started implementing SFML and so far, VERY IMPRESSED!

I'm loading 5x 2048x2048 PNG images, then creating sprites from them. It works just fine, but loading the actual files is very slow (~12 seconds for all 5). On the "other" library I used to use, this was very fast, maybe 3 seconds total for all 5 files. The files are between 650k and 3.3mb (some are almost empty files).

I guess it's not the actual loading, but the decompression into memory that takes the time?

Can someone help?

Many Thanks
Ed
Title: Image::LoadFromFile very slow
Post by: Laurent on May 15, 2011, 10:47:32 pm
Can you upload these images so that I can test them and see which part is slow?
Title: Image::LoadFromFile very slow
Post by: slotdev on May 15, 2011, 10:48:45 pm
Sure - can I email them to you, as they're for work and shouldn't be public :D
Title: Image::LoadFromFile very slow
Post by: Laurent on May 15, 2011, 10:57:07 pm
Sure, no problem.
Title: Image::LoadFromFile very slow
Post by: slotdev on May 15, 2011, 10:57:54 pm
Ah sorry - I uploaded them to my dropbox and PM'd you the link

Thanks
Ed
Title: Image::LoadFromFile very slow
Post by: slotdev on May 17, 2011, 11:35:15 am
Update: I had to recompile the SFML libs to minimize CRT dependancies, and after doing so, then recompiling my game, the delay has gone!

It now takes ~3 seconds to load all 5 PNGs, which is about right, I think.

So I guess there might be something strange in the libraries and maybe it's doing some crazy loading/unloading of DLLs for every image. No idea. But for now, it works for me :)
Title: Image::LoadFromFile very slow
Post by: Laurent on May 17, 2011, 11:39:42 am
That's really strange :shock:
Title: Image::LoadFromFile very slow
Post by: Groogy on May 17, 2011, 01:03:24 pm
Could be there are still some debug code in there? I know that for me to load my .obj model in debug takes like a million years while in release there is no loading time at all, I mean absolutely none! (I think there's somewhere around 10 000 faces in that model)
Title: Image::LoadFromFile very slow
Post by: slotdev on May 17, 2011, 01:37:06 pm
Hmm!

There is something strange - in Release mode, it's very fast, in Debug, it's very slow. I am confused :S
Title: Image::LoadFromFile very slow
Post by: Laurent on May 17, 2011, 01:47:05 pm
Quote
There is something strange - in Release mode, it's very fast, in Debug, it's very slow. I am confused :S

This is not strange at all, debug mode is always slower because the compiler doesn't optimize at all.
Title: Image::LoadFromFile very slow
Post by: slotdev on May 17, 2011, 02:10:13 pm
I wouldn't think it was 5x slower due to having the optimization disable, but I'll check my project settings - thanks :)
Title: Image::LoadFromFile very slow
Post by: Nexus on May 17, 2011, 02:35:18 pm
It is not only the optimizations that are turned off. Debug informations and additional runtime checks lead to further overhead.