Created
May 17, 2010 11:25
-
-
Save pcdinh/403660 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| #!/usr/local/php5-fcgi/bin/php | |
| <?php | |
| $client = new GearmanClient(); | |
| $client->addServer('127.0.0.1'); | |
| echo "Sending 1000 job\n"; | |
| do | |
| { | |
| $start = microtime(true); | |
| for ($i = 0; $i < 1000; $i++) | |
| { | |
| $result = $client->doBackground("reverse", "Hello!"); | |
| } | |
| echo "Elapsed time: ".(microtime(true) - $start)."\n"; | |
| // Check for various return packets and errors. | |
| switch ($client->returnCode()) | |
| { | |
| case GEARMAN_WORK_DATA: | |
| echo "Data: $result\n"; | |
| break; | |
| case GEARMAN_WORK_STATUS: | |
| list($numerator, $denominator) = $client->doStatus(); | |
| echo "Status: $numerator/$denominator complete\n"; | |
| break; | |
| case GEARMAN_WORK_FAIL: | |
| echo "Failed\n"; | |
| exit; | |
| case GEARMAN_SUCCESS: | |
| break; | |
| default: | |
| echo "RET: " . $client->returnCode() . "\n"; | |
| exit; | |
| } | |
| } while ($client->returnCode() != GEARMAN_SUCCESS); | |
| ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment