Advertisement
Guest User

Untitled

a guest
Sep 20th, 2016
7
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.38 KB | None | 0 0
  1. <?php
  2.         $start = microtime(true);
  3.         $ch = curl_init();
  4.         curl_setopt($ch, CURLOPT_URL, "http://packagist.org/p/provider-archived%24d200c2188ebf214eb87e520e3d81d46ea83c9564cb862c87f61095636ecb5d5c.json");
  5.         curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  6.         $output = curl_exec($ch);
  7.         curl_close($ch);
  8.         echo "curl: " . (microtime(true) - $start) . "\n";
  9.  
  10.         $start = microtime(true);
  11.         $context = stream_context_create(array('http' => array('timeout'=> 5)));
  12.         file_get_contents("http://packagist.org/p/provider-archived%24d200c2188ebf214eb87e520e3d81d46ea83c9564cb862c87f61095636ecb5d5c.json", false, $context);
  13.         echo "file_get_contents (w/ timeout): " . (microtime(true) - $start) . "\n";
  14.  
  15.         $start = microtime(true);
  16.         file_get_contents("http://packagist.org/p/provider-archived%24d200c2188ebf214eb87e520e3d81d46ea83c9564cb862c87f61095636ecb5d5c.json");
  17.         echo "file_get_contents: " . (microtime(true) - $start) . "\n";
  18.  
  19.         $start = microtime(true);
  20.         $context = stream_context_create(array('http' => array('header'=>'Connection: close\r\n')));
  21.         file_get_contents("http://packagist.org/p/provider-archived%24d200c2188ebf214eb87e520e3d81d46ea83c9564cb862c87f61095636ecb5d5c.json", false, $context);
  22.         echo "file_get_contents (w/ context): " . (microtime(true) - $start) . "\n";
  23. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement