On Apr 30, 2007, at 5:07 PM, Ashley M. Kirchner wrote:
I did a test running convert, single processor and got the following timing:
ImageMagick 'convert', 1 process, JPEG (command line) real 8m35.515s user 6m18.674s sys 1m46.344s
Then I wrote a small PHP script that does the same thing (read image, resize with constrain) and ran it through the command line, and got this:
PHP, 1 process, JPEG (through PHP CLI) real 36m17.260s user 35m38.972s sys 0m30.651s
Why oh why is it so much slower?! Is there something inheritedly slow within PHP that causes it to be so much slower (which in turn causes the Apache process to also take an incredible amount of time to finish the same task)?
Interesting. I'm not sure, as I don't use PHP. You might have better luck getting an answer if you post your test scripts to a PHP list.
A few things I might do if I were trying to diagnose this:
- throw in a few getrusage()s to see which section of the script is using the most time - maybe I'd get lucky and see one obviously wrong - ltrace shows all calls to shared libraries - maybe it could uncover something weird - use whatever profiling tool is available for profiling PHP scripts. (In Python, I'm fond of hotshot.) - find out what underlying library they're using and try it from a different language (Python, C, whatever) to see if the library or PHP is the problem. - compile the PHP interpreter itself with profiling and run it through gprof to where the time went.