11. Interpolated Execution
The results are now consistently inconsistent
PHPBench will report a high standard deviation, and you will
know to start again.
12. We want more
● Concurrent scheduling (load tests)
● Parameter / data generation
● HTTP sampling
● Even better progress loggers
20. interface Iterator extends Traversable {
public function current();
public function next();
public function key();
public function valid();
public function rewind();
}
21. class PointlessIterator implements Iterator {
private $array;
public function __construct(array $array) {
$this->array = $array;
}
function rewind() {
return reset($this->array);
}
function current() {
return current($this->array);
}
function key() {
return key($this->array);
}
function next() {
return next($this->array);
}
function valid() {
return key($this->array) !== null;
}
22. $pointless = [ 'a' => 1, 'b' => 2 ];
$pointless = new ArrayIterator($pointless);
foreach ($pointless as $key => $value) {
echo "$key = $value";
}
// outputs
// a = 1
// b = 2
23. Generators are easy Iterators
That you cannot rewind
But that's OK, because they do cool stuff
24. final class Generator implements Iterator {
function rewind() {}
function valid() {}
function current() {}
function key() {}
function next() {}
function send($value) {}
function throw(Exception $exception) {}
function getReturn() {}
}
25. final class Generator implements Iterator {
function rewind() {}
function valid() {}
function current() {}
function key() {}
function next() {}
function send($value) {}
function throw(Exception $exception) {}
function getReturn() {}
}
Iterator
26. final class Generator implements Iterator {
function rewind() {}
function valid() {}
function current() {}
function key() {}
function next() {}
function send($value) {}
function throw(Exception $exception) {}
function getReturn() {}
}
Generator
34. final class Generator implements Iterator {
function rewind() {}
function valid() {}
function current() {}
function key() {}
function next() {}
function send($value) {}
function throw(Exception $exception) {}
function getReturn() {}
}
Generator
55. AMP
Amp is a non-blocking concurrency
framework for PHP. It provides an event
loop, promises and streams as a base for
asynchronous programming.
Promises in combination with generators
are used to build coroutines, which allow
writing asynchronous code just like
synchronous code, without any callbacks.
https://github.com/amphp/amp
56. AMP
Amp is a non-blocking concurrency
framework for PHP. It provides an event
loop, promises and streams as a base for
asynchronous programming.
Promises in combination with generators
are used to build coroutines, which allow
writing asynchronous code just like
synchronous code, without any callbacks.
https://github.com/amphp/amp
65. A pipeline is a sequence of stages.
Each stage has a specific job to do.
66. 1)Make each program do one thing well. To do a new job, build afresh
rather than complicate old programs by adding new "features".
2)Expect the output of every program to become the input to another, as yet
unknown, program. Don't clutter output with extraneous information. Avoid
stringently columnar or binary input formats. Don't insist on interactive
input.
3)Design and build software, even operating systems, to be tried early,
ideally within weeks. Don't hesitate to throw away the clumsy parts and
rebuild them.
4)Use tools in preference to unskilled help to lighten a programming task,
even if you have to detour to build the tools and expect to throw some of
them out after you've finished using them.
Unix Philosophy
67. 1)Make each program do one thing well. To do a new job, build afresh
rather than complicate old programs by adding new "features".
2)Expect the output of every program to become the input to another, as yet
unknown, program. Don't clutter output with extraneous information. Avoid
stringently columnar or binary input formats. Don't insist on interactive
input.
3)Design and build software, even operating systems, to be tried early,
ideally within weeks. Don't hesitate to throw away the clumsy parts and
rebuild them.
4)Use tools in preference to unskilled help to lighten a programming task,
even if you have to detour to build the tools and expect to throw some of
them out after you've finished using them.
Unix Philosophy
82. class TimesTwoStage {
public function __invoke($value) {
return $value * 2;
}
}
class AddOneStage {
public function __invoke($value) {
return $value + 1;
}
}
113. Videos
● Cooperative multitasking with Generators:
https://www.youtube.com/watch?v=cY8FUhZvK7w
● Pushing the limits of PHP with React:
https://www.youtube.com/watch?
v=fQxxm4vD8Ok&feature=youtu.be
● Herding Cats: https://vimeo.com/189755262
● What the heck is the event loop anyway?:
https://www.youtube.com/watch?v=8aGhZQkoFbQ