Well that is odd. As always I appreciate your help. I'm using ImageMagick 6.8.3-7 compiled from source under Cygwin on a Windows 7 laptop. Looks like the version of libxml2 I have is 2.9.0-1.
I did some more testing, first using
http://www.imagemagick.org/MagickStudio ... wizard.jpg and alternating the test programs. Sometimes it's fast, sometimes it's very slow with really long delays.
MagickReadImage(): 16094, 132, 18062, 112, 110, 8571, 90, 101, 5641
curl + MagickReadImageBlob() + MagickWriteImage(): 2860, 110, 810, 340, 510, 2440, 70, 70, 2671
This is over a very congested wifi network then satellite internet connection in Afghanistan so there's definitely some other factors outside the code. But MagickReadImage() is consistently slower than curl + MagickReadImageBlob() + MagickWriteImage() over a bunch of iterations.
Code: Select all
pgg@g550 ~/test
$ ./test3
Image retrieved in 16094 milliseconds.
pgg@g550 ~/test
$ ./test4
Image read and written to file in 2860 milliseconds.
pgg@g550 ~/test
$ ./test3
Image retrieved in 132 milliseconds.
pgg@g550 ~/test
$ ./test4
Image read and written to file in 110 milliseconds.
pgg@g550 ~/test
$ ./test3
Image retrieved in 18062 milliseconds.
pgg@g550 ~/test
$ ./test4
Image read and written to file in 810 milliseconds.
pgg@g550 ~/test
$ ./test3
Image retrieved in 112 milliseconds.
pgg@g550 ~/test
$ ./test4
Image read and written to file in 340 milliseconds.
pgg@g550 ~/test
$ ./test3
Image retrieved in 110 milliseconds.
pgg@g550 ~/test
$ ./test4
Image read and written to file in 510 milliseconds.
pgg@g550 ~/test
$ ./test3
Image retrieved in 8571 milliseconds.
pgg@g550 ~/test
$ ./test4
Image read and written to file in 2440 milliseconds.
pgg@g550 ~/test
$ ./test3
Image retrieved in 90 milliseconds.
pgg@g550 ~/test
$ ./test4
Image read and written to file in 70 milliseconds.
pgg@g550 ~/test
$ ./test3
Image retrieved in 101 milliseconds.
pgg@g550 ~/test
$ ./test4
Image read and written to file in 70 milliseconds.
pgg@g550 ~/test
$ ./test3
Image retrieved in 5641 milliseconds.
pgg@g550 ~/test
$ ./test4
Image read and written to file in 2761 milliseconds.
Then I did the same test with the local image source. Again this is an ethernet cable direct from the computer to the IP camera. No network congestion issues, caching, speed-of-light delay issues with geosynch satellite comms, etc. Nothing else running in the background, other than the usual Windows garbage.
MagickReadImage(): 26786, 540, 280, 288, 282, 612, 26825, 260, 230, 281, 290, 250
curl + MagickReadImageBlob() + MagickWriteImage(): 330, 320, 340, 310, 650, 660, 311, 510, 330, 320, 610, 321
Usually fast, but sometimes there's a huge delay.
Code: Select all
pgg@g550 ~/test
$ ./test3
Image retrieved in 26786 milliseconds.
pgg@g550 ~/test
$ ./test4
Image read and written to file in 330 milliseconds.
pgg@g550 ~/test
$ ./test3
Image retrieved in 540 milliseconds.
pgg@g550 ~/test
$ ./test4
Image read and written to file in 320 milliseconds.
pgg@g550 ~/test
$ ./test3
Image retrieved in 280 milliseconds.
pgg@g550 ~/test
$ ./test4
Image read and written to file in 340 milliseconds.
pgg@g550 ~/test
$ ./test3
Image retrieved in 288 milliseconds.
pgg@g550 ~/test
$ ./test4
Image read and written to file in 310 milliseconds.
pgg@g550 ~/test
$ ./test3
Image retrieved in 282 milliseconds.
pgg@g550 ~/test
$ ./test4
Image read and written to file in 650 milliseconds.
pgg@g550 ~/test
$ ./test3
Image retrieved in 612 milliseconds.
pgg@g550 ~/test
$ ./test4
Image read and written to file in 660 milliseconds.
pgg@g550 ~/test
$ ./test3
Image retrieved in 26825 milliseconds.
pgg@g550 ~/test
$ ./test4
Image read and written to file in 311 milliseconds.
pgg@g550 ~/test
$ ./test3
Image retrieved in 260 milliseconds.
pgg@g550 ~/test
$ ./test4
Image read and written to file in 510 milliseconds.
pgg@g550 ~/test
$ ./test3
Image retrieved in 230 milliseconds.
pgg@g550 ~/test
$ ./test4
Image read and written to file in 330 milliseconds.
pgg@g550 ~/test
$ ./test3
Image retrieved in 281 milliseconds.
pgg@g550 ~/test
$ ./test4
Image read and written to file in 320 milliseconds.
pgg@g550 ~/test
$ ./test3
Image retrieved in 290 milliseconds.
pgg@g550 ~/test
$ ./test4
Image read and written to file in 610 milliseconds.
pgg@g550 ~/test
$ ./test3
Image retrieved in 250 milliseconds.
pgg@g550 ~/test
$ ./test4
Image read and written to file in 321 milliseconds.
The first retrieval with MagickReadImage() is always slow, even if I run the curl + MagickReadImageBlob() test program first:
Code: Select all
pgg@g550 ~/test
$ ./test4
Image read and written to file in 340 milliseconds.
pgg@g550 ~/test
$ ./test3
Image retrieved in 26823 milliseconds.
Moreover, if I space out the test runs by a minute, the MagickReadImage() is ALWAYS slow:
Code: Select all
$ ./test3; sleep 60; ./test3; sleep 60; ./test3; sleep 60; ./test3; sleep 60; ./test3; sleep 60; ./test3
Image retrieved in 26788 milliseconds.
Image retrieved in 26824 milliseconds.
Image retrieved in 26810 milliseconds.
Image retrieved in 26785 milliseconds.
Image retrieved in 26775 milliseconds.
Image retrieved in 26765 milliseconds.
And the curl + MagickReadImageBlob() + MagickWriteImage() is always fast:
Code: Select all
pgg@g550 ~/test
$ ./test4; sleep 60; ./test4; sleep 60; ./test4; sleep 60; ./test4; sleep 60; ./test4; sleep 60; ./test4
Image read and written to file in 680 milliseconds.
Image read and written to file in 330 milliseconds.
Image read and written to file in 350 milliseconds.
Image read and written to file in 340 milliseconds.
Image read and written to file in 330 milliseconds.
Image read and written to file in 320 milliseconds.
And just for grins:
Code: Select all
pgg@g550 ~/test
$ ./test3; ./test3; ./test3; ./test3; ./test3; ./test3; ./test3; ./test3; ./test3; ./test3; ./test3;
Image retrieved in 26804 milliseconds.
Image retrieved in 282 milliseconds.
Image retrieved in 260 milliseconds.
Image retrieved in 240 milliseconds.
Image retrieved in 300 milliseconds.
Image retrieved in 300 milliseconds.
Image retrieved in 300 milliseconds.
Image retrieved in 260 milliseconds.
Image retrieved in 300 milliseconds.
Image retrieved in 260 milliseconds.
Image retrieved in 310 milliseconds.
I don't have any idea why the first iteration is always so slow.