Slow image loading
Posted: 2007-02-02T12:18:09-07:00
I'v got about 10000 small jpg images (size 2 to 10 kb). I'v tested how fast they are loaded. Results of 3 test:
40360 ms, 42968 ms, 41184 ms
It is almoust 4 times slower than in other libraries:
FreeImage - 11170 ms, 10731 ms, 10768 ms
CxImage - 11468 ms, 11859 ms, 11374 ms
One of reasons of so slow loading is function SetImageInfo() - it has a lot of disc access - for example it calls several times GetPathComponent() witch access disc (more than once) - I think it's not necessary. So I'v replaced the function with one that only calls CopyMagickString(image_info->magick,"JPEG", MaxTextExtent);
New results:
27795 ms, 27302 ms, 27000 ms
I think there could be an option to allow pass image type to ReadImage or check type only based on file name extension.
I' also measured time with removed all code from ReadImage after
image=GetMagickDecoder(magick_info)(read_info,exception);
I was able to process and display resulting image.
Times with removed code (from ReadImage and SetImageInfo):
19468 ms, 18576 ms, 18981 ms
It is still slower than other libraries, but it's not 4 times slower.
40360 ms, 42968 ms, 41184 ms
It is almoust 4 times slower than in other libraries:
FreeImage - 11170 ms, 10731 ms, 10768 ms
CxImage - 11468 ms, 11859 ms, 11374 ms
One of reasons of so slow loading is function SetImageInfo() - it has a lot of disc access - for example it calls several times GetPathComponent() witch access disc (more than once) - I think it's not necessary. So I'v replaced the function with one that only calls CopyMagickString(image_info->magick,"JPEG", MaxTextExtent);
New results:
27795 ms, 27302 ms, 27000 ms
I think there could be an option to allow pass image type to ReadImage or check type only based on file name extension.
I' also measured time with removed all code from ReadImage after
image=GetMagickDecoder(magick_info)(read_info,exception);
I was able to process and display resulting image.
Times with removed code (from ReadImage and SetImageInfo):
19468 ms, 18576 ms, 18981 ms
It is still slower than other libraries, but it's not 4 times slower.