首頁我是相片相簿文字 » PHP curl vs file_get_contents
PHP curl vs file_get_contents2016-03-17
a comparison of time-consuming for curl() and file_get_contents()

1. Target: Google generated page

2. Programming: Basically string processing, apply preg_match, preg_replace, preg_split after retrieving HTML content.

3. RESULT
--
Result 1
$curl_info[size_download]: 542711

curl get contents timing => 0.5671, 0.5821, 0.7801
file_get_contents timing => 0.8851, 0.8641, 0.9081
--
Result 2
$curl_info[size_download]: 554880

curl get contents timing => 0.7771, 0.5741, 0.6331
file_get_contents timing => 0.9991, 1.2871, 0.9111
--
Result 3
$curl_info[size_download]: 561892

curl get contents timing => 0.7111, 0.7091, 0.6931
file_get_contents timing => 1.0921, 1.3880, 0.9640
--
Conclusion

Curl is 50percent faster than file_get_contents when getting a 550kb file size.
Leave a comment*required

Howdy, Leave a comment here :)