Last active
March 24, 2016 23:15
-
-
Save mentos1386/5635122cb54718b4f881 to your computer and use it in GitHub Desktop.
Demo presentation of new Async
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use OpenCrest\OpenCrest; | |
// -------------- | |
// NEW Async mode | |
// We will monitor time | |
$asyncStart = microtime(true); | |
// Make use of new Async | |
OpenCrest::$async = True; | |
// Create 150 requests | |
for($i = 0; $i < 150; $i++) | |
{ | |
OpenCrest::Alliances()->get(); | |
} | |
// Vardump time that it took to create 150 requests | |
$timeAsync = microtime(true) - $asyncStart; | |
var_dump("Async time: ", $timeAsync); | |
// Make those requests | |
OpenCrest::asyncRun(); | |
// Vardump time it took to make those 150 requests | |
$timeAsync = microtime(true) - $asyncStart; | |
var_dump("Async time after run: ", $timeAsync); | |
// Vardump successes and rejections | |
var_dump(sizeof(OpenCrest::$asyncResponsesPublic["success"])); | |
var_dump(sizeof(OpenCrest::$asyncResponsesPublic["rejected"])); | |
// ------------------- | |
// OLD Synchronus mode | |
// We will monitor time | |
$asyncStart = microtime(true); | |
// Set mode back to Synchronous | |
OpenCrest::$async = False; | |
// Create 150 requests | |
for($i = 0; $i < 150; $i++) | |
{ | |
OpenCrest::Alliances()->get(); | |
} | |
// Vardump time that it took to make 150 requests | |
$timeAsync = microtime(true) - $asyncStart; | |
var_dump("Async time: ", $timeAsync); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment