-
Notifications
You must be signed in to change notification settings - Fork 426
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Expected speed? #179
Comments
Hi, 4x slower is not expected, however it could also depend on settings: For compiler settings: do you compile with optimizations enabled, such as with the -O2 or -O3 flag? Or if you use an IDE, are there any optimization settings or debug vs release compile settings that can be tuned for speed in there? For PNG encoding itself: there are various compression related settings, such as windowsize, nicematch and lazymatching, see those values in lodepng.h. Tuning these values may make the encoding faster but the compression worse. How does the image size compare to what you get out of the C# library? Thanks! |
Thank you for your replay. Yes, the optimization was enabled. Meanwhile I checked FPNG-test that compresses and decompresses PNGs using different libraries and the results are different too:
This led me to enabling different instruction sets but it did not affect the results that much. By the way, WUFFS's loading seems to be slightly faster then C# - maybe about 25%.
Thanks again! |
Thanks for testing! Which platform are you using? When I run the fpng_test benchmark, I get:
For the compression, note that lodepng produces a much smaller result in bytes than the others, compressing harder is slower. lodepng doesn't use SIMD instructions (directly) which is why FPNG is much faster. QOI is a different image format. |
My home CPU is AMD Ryzen 5 3600 (6 cores, 12 threads). I believe Intel would produce different ratios of measured times because I already noticed that while measuring my apps. I'll try to run this test on my office computer too.
I noticed that =) but for my current project is more important speed. Better compression might be useful next time. =) |
I would actually expect your CPU to do faster on all codecs (I'd even expect 10x faster for decoding/encoding for most of them) here, I'm not sure what could be going wrong though if optimizations are enabled. I also measured on AMD above, from the Ryzen 7xxx series. Unless it's a very special image? But I don't know what kind of pixel pattern could make encoding and decoding 10x slower either. |
Weeell, I think I pasted by mistake a log from debug version of FPNG-test. It was just an illustration of ratios so I did not notice the absolute values are too high. Sorry for that. =} These two are from release build (with "default optimize"):
|
Today I used LodePNG in my little tool for blending images. It works as expected but I am quite surprised by its relative slowness compared to C# libraries.
I have a few similar tools written in C# and I though converting them to C/C++ could make them faster (I run them on thousands of files) but the first test with optimized .exes is rather bad. The first tool is very simple and quick (the others are more complicated) so the time of calculation has improved only from 31 ms to 23 ms. However, the time needed for PNG manipulation has increased much more - from 100 ms to 511 ms.
The differences are caused by these three lines:
Is it expected behaviour or can I make LodePNG faster by some less obvious compiler options? I am really surprised that the .NET functions are so much faster. What kind of sorcery could Microsoft use?
The text was updated successfully, but these errors were encountered: