Advertisement
Guest User

Untitled

a guest
Aug 23rd, 2012
267
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.22 KB | None | 0 0
  1. <?php
  2. $headers = array (
  3.     'X-EBAY-API-COMPATIBILITY-LEVEL: 507',
  4.     'X-EBAY-API-DEV-NAME: ABCD',
  5.     'X-EBAY-API-APP-NAME: EFGH',
  6.     'X-EBAY-API-CERT-NAME: IJKL',
  7.     'X-EBAY-API-SITEID: 0',
  8. );
  9. $accessToken = "AAACEdEose0cBAAAB8qnMVCmfNRQSNT2CCCTZBB90eMl7UpaFZBuYTAqWvYkhP9gJsoFd7ZAfAWxe6yTfh7jZBpaixhPHR6TO3n1xLiItM0FlccuVEy9x";
  10. $url = "https://graph.facebook.com/me?access_token=" . $accessToken;
  11.  
  12. $repeat = 3;
  13.  
  14. /**
  15.  * verbose
  16.  **/
  17. $start = microtime(true);
  18. for ($i = 0; $i < $repeat; $i++) {
  19.     $session = curl_init();
  20.     curl_setopt($session, CURLOPT_URL, $url); // Oops - wrong URL for API
  21.     curl_setopt($session, CURLOPT_HTTPHEADER, $headers); // Set headers to above array
  22.     curl_setopt($session, CURLOPT_HEADER, true); // Display headers
  23.     curl_setopt($session, CURLOPT_VERBOSE, true); // Display communication with server
  24.     curl_setopt($session, CURLOPT_RETURNTRANSFER, true); // Return data instead of display to std out
  25.     curl_exec($session);
  26.     curl_close($session);
  27. }
  28. echo "Verbose time: " . (microtime(true) - $start) . " seconds.\n";
  29.  
  30. /**
  31.  * fgc
  32.  **/
  33. $start = microtime(true);
  34. for ($i = 0; $i < $repeat; $i++) {
  35.     file_get_contents($url);
  36. }                                                                                                                                                                       echo "File get contents time: " . (microtime(true) - $start) . " seconds.\n";
  37.  
  38. /**
  39.  * andrewF
  40.  **/
  41. $start = microtime(true);
  42. for ($i = 0; $i < $repeat; $i++) {
  43.     $ch = curl_init();
  44.     curl_setopt($ch, CURLOPT_URL, $url);
  45.     //curl_setopt($ch, CURLOPT_HEADER, 1);
  46.     curl_setopt($ch, CURLOPT_HEADER, 0);  // Return contents only
  47.     //curl_setopt($ch, CURLOPT_VERBOSE, 1); // Display communication with server
  48.     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);  // return results instead of outputting
  49.     curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10); // Give up after connecting for 10 seconds
  50.     curl_setopt($ch, CURLOPT_TIMEOUT, 60);  // Only execute 60s at most
  51.     curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);  // Don't verify SSL cert
  52.     $response = curl_exec($ch);
  53.     curl_close($ch);
  54. }
  55. echo "AndrewF time: " . (microtime(true) - $start) . " seconds.\n";
  56. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement