Advertisement
Danack

ElapsedTimeAtExit

Nov 4th, 2014
255
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.59 KB | None | 0 0
  1. <?php
  2.  
  3. require_once(realpath(__DIR__).'/../vendor/autoload.php');
  4.  
  5. $reactor = Amp\reactor();
  6. $client = new \Amp\Artax\Client($reactor);
  7. $client->setOption(\Amp\Artax\Client::OP_MS_KEEP_ALIVE_TIMEOUT, 3000);
  8.  
  9. $callbackTime = null;
  10. $callback = function () use (&$callbackTime) {
  11.     echo "I r callback!!\n";
  12.     $callbackTime = microtime(true);
  13. };
  14.  
  15. $promise = $client->request("http://www.bing.com/asdasdasdsd");
  16. $promise->when($callback);
  17.  
  18. echo "Running reactor: \n";
  19. $reactor->run();
  20.  
  21. $elapsed = microtime(true) - $callbackTime;
  22. printf("elapsed: %5.2f\n", $elapsed);
  23.  
  24. echo "Fin.";
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement