Last active
August 29, 2015 14:23
-
-
Save fezfez/bcc077d4f134c55c2786 to your computer and use it in GitHub Desktop.
Revisions
-
fezfez revised this gist
Jun 24, 2015 . 2 changed files with 0 additions and 11 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -42,16 +42,6 @@ public function valid() $processIterator = new ProcessIterator(__DIR__ . '/tmpeee.sh'); foreach ($processIterator as $i => $result) { echo "$i Time : " .(microtime(true) - $_SERVER["REQUEST_TIME_FLOAT"]) . ", result : " . $result . "\n"; if ($i == 9) { 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 charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,3 @@ echo '{"value":"first valuddddde"} sleep 2' sleep 2 -
fezfez created this gist
Jun 24, 2015 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,61 @@ <?php class ProcessIterator implements Iterator { private $stream; private $command; private $iteration = 0; public function __construct($command) { $this->command = $command; } public function rewind() { $this->stream = popen($this->command, 'r'); $this->iteration = 0; } public function current() { return fgets($this->stream); } public function key() { return $this->iteration; } public function next() { $this->iteration++; } public function valid() { return !feof($this->stream); } } $processIterator = new ProcessIterator(__DIR__ . '/tmpeee.sh'); foreach ($processIterator as $i => $result) { echo "$i Time : " .(microtime(true) - $_SERVER["REQUEST_TIME_FLOAT"]) . ", result : " . $result . "\n"; if ($i == 9) { echo "php sleeping for 8\n"; sleep(8); } } $processIterator = new ProcessIterator(__DIR__ . '/slowProcess.sh'); foreach ($processIterator as $i => $result) { echo "$i Time : " .(microtime(true) - $_SERVER["REQUEST_TIME_FLOAT"]) . ", result : " . $result . "\n"; if ($i == 9) { echo "php sleeping for 8\n"; sleep(8); } } 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,16 @@ echo '{"value":"first valuddddde"} sleep 2' sleep 2 echo '{"value":"first value"}' echo '{"value":"other value"}' echo '{"value":"new other value"} sleep 5' sleep 5 echo '{"value":"not value"}' echo '{"value":"end value"}'