tags:

views:

60

answers:

1

May I know whether C++ or PHP is more efficient on running PCA (Principal Component Analysis)?

I'm developing a web based system which get uploaded image with php, and then process the image so that I can analyse the image with PCA to find out whether the image match with another image which already stored in database.

But I'm wondering which language to use (C++ or PHP or any other better alternative) for a better performance to complete the PCA task.

tq~

A: 

Generally speaking, in computationally intensive projects, code doing the same steps is 100 times faster in C (or C++ for that matter) compared to PHP. Optimizing your C will give another 2-10 times increase, depending on the time, effort and knowledge you put in.

The point is that PHP is interpreted, and C runs, loosely speaking, almost directly on your cpu. If you really want to get the most out of it, in C you can go down the SSE1/2/3/4 road.

You could of course use or write a library (or call it "extension") for PHP in C, which in my experience is a good match to achieve high speed at the right points while keeping the benefits of PHP.

mvds
okay, means that your recommendation for these case is writing a php extension in c right? tq.
jihchuan
yes. It sounds hard, and it looks hard, but once you get going it is really easy. I think this number 1 google hit showed me how: `http://devzone.zend.com/article/1021`, up and running within a day. Don't run on a production webserver since you will make apache sigsegv a lot...
mvds
hehe, yea i ady bookmarked tht page, sounds hard, cz my php/c skills r so limited, somehow gonna dev PCA which im stil blur on it.. >.< hope its reali goin for me after days/weeks..
jihchuan