Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Which is faster? Using PHP's cUrl library or invoking curl utility form shell_exec()

For a PHP project i have to access RESTful API. I was using curl to get familiar with the API. I can access the said API using both PHP's cUrl library and invoking the curl utility using PHP's shell_exec() function. Performance wise, which option would be better and why??

PS: I have my own server with root privilege.

like image 417
Vipin Parakkat Avatar asked Jun 28 '11 00:06

Vipin Parakkat


2 Answers

My cautious guess would be not too useful test snippets shows that the curl library is more performant.

Edit: A little test shows, that the library is faster, but not by much. Also, if you fetch millions of URLs, network latency will more likely be a bigger problem.

like image 157
miku Avatar answered Oct 19 '22 19:10

miku


Performance is pretty much exactly the same, because the same stuff is being executed internally. But you should use the API because it is cleaner.

like image 27
Otto Allmendinger Avatar answered Oct 19 '22 18:10

Otto Allmendinger