I've been working on a CGI script which completes the following tasks:
1. Get an ID from the query string
2. Gets a filename associated with that ID using Win32::ODBC
3. Loads that filename, which happens to be a jpeg file, into a variable $image
4. Scales, crops, manipulates the image a bunch of different ways
5. Outputs it to the browser

I've been coding it on a 800Mhz test server, and have been generally displeased with the speed of the computations. However, knowing that I would eventually run it on a 2.4Ghz server, I felt reassured that it would run faster. I expected the sript to run 2-3 times faster than it originally had, since the processor in the new machine is 3 times as quick (and the other hardware is faster, too, see below). However, I installed the script on the quick machine, and found that I don't even get 2x speeds. What gives!?

I wrote some timing mechanisms to test individual parts of the script, and found that some of the non-ImageMagick parts hadn't sped up much. These include the DB call and parsing the querystring. Fine, these sections take only 0.05 seconds to execute, and are limited by more than code and hardware (meaning, they rely on more than just ImageMagick, my code, and the machine's hardware to run). Looking at the image manipulation code, though, shows an increase in speed, but again not even 2x. Beacuse these are large images (i.e. 3200x1200), I don't expect a run time of .5 seconds, but the same script that ran in 6 seconds on the old machine executes in a mildly superior 3.5 seconds.

I'm wondering what, in general, might keep this code from running even 2 times faster on a machine which is at least 3 times "better" than another. Below are some basic specs for the two machines:

Old:
PIII 800Mhz
512MB PC133 Ram
ATA100 7200RPM disks

New:
P4 2.4Ghz
512MB PC2100 DDR Ram
ATA133 7200RPM disks
They are both running Win2k server with the latest versions of ActiveState's perl and ImageMagick. Any ideas? Thanks

In reply to ImageMagick too slow by lpoht

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.