only accept ports in range
[hiphop-php.git] / hphp / test / slow / program_functions / repo_contention.php
blobe55c165dc80337489c91624a5c37289254a9e180
1 <?php
3 function foobar($i) {
4 usleep(500*1000);
7 function main($num) {
8 $cmd = file_get_contents("/proc/self/cmdline");
9 $cmd = str_replace("\000", " ", $cmd);
10 $start = microtime(true);
12 echo "Starting $num procs\n";
13 for ($i = 0;
14 $i < $num;
15 $i++) {
16 $handles[] = proc_open($cmd." $i", array(), $pipes);
18 while ($handles) {
19 foreach ($handles as $i => $handle) {
20 $status = proc_get_status($handle);
21 if (!$status['running']) {
22 proc_close($handle);
23 unset($handles[$i]);
27 echo "Done $num procs\n";
28 return microtime(true) - $start;
30 if (count($argv) > 1) {
31 foobar($argv[1]);
33 else {
34 $x10 = main(10);
35 $x200 = main(200);
36 echo $x10 * 20 < $x200 ? "Failed" : "Passed", "\n";