Advertisement
Azuuuuuuus

TL速度測るやつ(やっつけ)

Feb 27th, 2017
171
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.73 KB | None | 0 0
  1. <?php
  2. require_once('../lib/UserstreamPhirehose.php');
  3. $time_start = microtime(true);
  4. //その時歴史は動いた
  5. $twcount = 0;
  6. //メンタルリセット
  7. /**
  8.  * Barebones example of using UserstreamPhirehose.
  9.  */
  10. class MyUserConsumer extends UserstreamPhirehose
  11. {
  12.   public function enqueueStatus($status)
  13.   {
  14.     /*
  15.      * In this simple example, we will just display to STDOUT rather than enqueue.
  16.      * NOTE: You should NOT be processing tweets at this point in a real application, instead they
  17.      *  should be being enqueued and processed asyncronously from the collection process.
  18.      */
  19. global $time_start ,$twcount;
  20. //関数内に変数を引きずりこむ
  21. $time_end = microtime(true);
  22. //時間 今
  23. $times = $time_end - $time_start;
  24. //ビョースー計算
  25. $twcount++;
  26. //インクリ////
  27. $twsoku = ($twcount / $times) * 60;
  28. //(平均値)出すぞオラッ!!
  29. $twsoku = round($twsoku, 2);
  30. //まるくなぁれ
  31. echo "$twsoku Tweets/min(Total: $twcount Tweets)<BR>";
  32. //ドピュ
  33. flush();
  34.     ob_flush();
  35. //(途)中(だけど)出(力)し(ちゃう)
  36.   }
  37.  
  38. }
  39.  
  40. //This variable has been deletedXD
  41.  
  42. //These are the application key and secret
  43. //You can create an application, and then get this info, from https://dev.twitter.com/apps
  44. //(They are under OAuth Settings, called "Consumer key" and "Consumer secret")
  45. define('TWITTER_CONSUMER_KEY', '');
  46. define('TWITTER_CONSUMER_SECRET', '');
  47.  
  48. //These are the user's token and secret
  49. //You can get this from https://dev.twitter.com/apps, under the "Your access token"
  50. //section for your app.
  51.  
  52. define('OAUTH_TOKEN', '119207660-');
  53. define('OAUTH_SECRET', '');
  54.  
  55. // Start streaming
  56. $sc = new MyUserConsumer(OAUTH_TOKEN, OAUTH_SECRET);
  57. $sc->consume();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement