List Info

Thread: Magick::Image::read speed




Magick::Image::read speed
country flaguser name
United States
2007-11-02 13:54:46
Is there any way to make Image::read a bit faster?  In my
test program 
(code below) the timings come out around a half-second for
each run. 
Here is the line I'm currently using to configure GM:

./configure 
	CFLAGS="-O3" 
	CXXFLAGS="-O3" 
	CPPFLAGS="-I/opt/local/include
-I/usr/local/include" 
	LDFLAGS="-L/opt/local/lib -L/usr/local/lib" 
	--without-perl 
	--disable-installed 
	--without-dps --without-fpx --without-jbig --without-jp2 
	--without-lcms --without-trio --without-ttf --without-wmf

I am on a Core 2 Duo MacBook Pro for these tests.  The last
two lines of 
the configure command are an effort to remove things I don't
need, but 
they have not sped things up significantly.  Adding -O3 to
CFLAGS and 
CXXFLAGS increased speed by about 0.3 seconds.

I don't think this is a platform specific issue, as GM is
universally 
slower than other solutions (I believe CoreImage on Macs and
Paintlib on 
Windows).  I'm committed to using GM but really need to find
a way to 
speed things up.  Any ideas?

Thanks,

Richard

Aaaaaaand, the code:

#include <Magick++.h>
#include <stdio.h>
#include <string>

using namespace std;
using namespace Magick;

// Fake gettimeofday on Windows
#ifdef XP_WIN
// Omitted for brevity
#else
#include <sys/time.h>
#endif

// Cheesy code timing
struct timeval first;
struct timeval last;
void start_timer() {
	gettimeofday(&first, 0);
}
double stop_timer() {
	gettimeofday(&last, 0);
	return ((double)last.tv_sec + (double)last.tv_usec /
1000000) -
		((double)first.tv_sec + (double)first.tv_usec / 1000000);
}

int main(int argc, char * * argv) {

	// Must have one argument, which is a file path
	if (2 == argc) {
		char * path = *(argv + 1);
		try {

			// Time opening an image
			string path_s(path);
			start_timer();
			Image img(path_s);
			double open = stop_timer();
			printf("%s: %fn", path, open);

		} catch (Exception & e) {
			printf("Error trying to open %s (%s).n", path,
e.what());
			return 1;
		}
	} else {
		printf("Usage: %s <image-file>n",
*argv);
		return 1;
	}

	return 0;
}

------------------------------------------------------------
-------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and
a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
Graphicsmagick-help mailing list
Graphicsmagick-helplists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gra
phicsmagick-help

Re: Magick::Image::read speed
country flaguser name
United States
2007-11-02 15:55:05
On Fri, 2 Nov 2007, Richard Crowley wrote:

> Is there any way to make Image::read a bit faster?  In
my test program
> (code below) the timings come out around a half-second
for each run.
> Here is the line I'm currently using to configure GM:
>
> ./configure 
> 	CFLAGS="-O3" 
> 	CXXFLAGS="-O3" 
> 	CPPFLAGS="-I/opt/local/include
-I/usr/local/include" 
> 	LDFLAGS="-L/opt/local/lib -L/usr/local/lib"

> 	--without-perl 
> 	--disable-installed 
> 	--without-dps --without-fpx --without-jbig
--without-jp2 
> 	--without-lcms --without-trio --without-ttf
--without-wmf
>
> I am on a Core 2 Duo MacBook Pro for these tests.  The
last two lines of

Image read performance is very dependent on the file format
being 
read, disk speed, how much RAM there is, and if the file is
read more 
than one time.  Full color images are handled more
efficiently than 
are low-color or bilevel images.

What formats are you most interested in?  If there is
something 
specific which is slow I will be happy to to work with an
image sample 
you provide in order to see why it is slow and try to make
it faster.

Processor-specific optimizations may help considerably if
you are 
blessed with a recent CPU and can afford to depend on it.

If you are reading JPEG files, then the speed is primarily
determined 
by the speed of libjpeg.  I understand that Intel offers a
replacement 
for libjpeg which is specially optimized for Intel CPUs.

When Postscript and PDF files are read, speed is primarily
determined 
by Ghostscript.

If you are using the latest GraphicsMagick release (1.1.10),
there is 
a 'benchmark' command you can use to test read performance. 
For 
example

   gm benchmark -duration 10 convert infile.jpg null:

or

   gm benchmark -iterations 10 convert infile.jpg null:

% gm identify  bike.jpg
bike.jpg JPEG 1536x1920+0+0 DirectClass 8-bit 542.7k 0.000u
0:01
% gm benchmark -duration 10 convert bike.jpg null:
Results: 89 iter 10.00s user 10.06s total 8.847 iter/s

Image read performance is often faster in development GM 1.2
than in 
the 1.1.X versions.

Bob
======================================
Bob Friesenhahn
bfriesensimple.dallas.tx.us, http://w
ww.simplesystems.org/users/bfriesen/
GraphicsMagick Maintainer,    http://www.GraphicsMag
ick.org/


------------------------------------------------------------
-------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and
a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
Graphicsmagick-help mailing list
Graphicsmagick-helplists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gra
phicsmagick-help

[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )