fx much slower with variable names longer than 2 chars

Questions and postings pertaining to the development of ImageMagick, feature enhancements, and ImageMagick internals. ImageMagick source code and algorithms are discussed here. Usage questions which are too arcane for the normal user list should also be posted here.
Post Reply
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

fx much slower with variable names longer than 2 chars

Post by fmw42 »

With regard to some latter posts regarding timing of -fx within viewtopic.php?f=2&t=11601&hilit=fx

I did some tests with command line IM 6.4.2-1 Q16 (non-hdri) and found that indeed -fx is an order of magnitude slower when variable names are more than 2 characters long. I think this is something that needs to be fixed for IM 7 if this is not a bug and can be fixed sooner.

Here are my tests in generating a radial gradient using rad=64

2 characters => 1.66 sec
time convert -size ${rad}x${rad} xc: -monitor \
-fx "xx=i-w/2; yy=j-h/2; rr=hypot(xx,yy); 2*rr/$rad" radius_rr.png

3 characters => 42 sec
time convert -size ${rad}x${rad} xc: -monitor \
-fx "xxx=i-w/2; yyy=j-h/2; rrr=hypot(xxx,yyy); 2*rrr/$rad" radius_rrr.png

4 characters => 42 sec
time convert -size ${rad}x${rad} xc: -monitor \
-fx "xxxx=i-w/2; yyyy=j-h/2; rrrr=hypot(xxxx,yyyy); 2*rrrr/$rad" radius_rrrr.png

10 characters => 43 sec
time convert -size ${rad}x${rad} xc: -monitor \
-fx "xxxxxxxxxx=i-w/2; yyyyyyyyyy=j-h/2; rrrrrrrrrr=hypot(xxxxxxxxxx,yyyyyyyyyy); 2*rrrrrrrrrr/$rad" radius_rrrrrrrrrr.png

Any chance this can be fixed.

I also want to point out that -fx does not allow alphanumeric characters, only alphabetic characters. Having a second numeral following an alphabetic character would allow some better loop scripting to set up variables for -fx.

Another feature that would be handy would be to allow -fx to access unix array elements. I tried this and it does not work.

Thanks for consideration of these enhancements.

Fred
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: fx much slower with variable names longer than 2 chars

Post by magick »

There is a patch for the problem you posted in the ImageMagick subversion trunk.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: fx much slower with variable names longer than 2 chars

Post by fmw42 »

Thanks

Does the patch include a fix for alphanumeric characters as well as the speed issue? or only the latter?
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: fx much slower with variable names longer than 2 chars

Post by magick »

The speed issue is a bug, the alphanumeric request is an enhancement. Enhancements are a lower priority. Its on our list of things to do with no current ETA.
Post Reply