3v4l.org

run code in 300+ PHP versions simultaneously
<?php //implementácia rozhrania Mediator //metoda odoslat() je volaná zamestnancom a slúži k odoslaniu správ interface Mediator { public function send($message, AbstractEmployee $employee); } //definovanie rozhrania abstraktnej triedy AbstractEmployee //trieda obsahuje jedinečný atribút - identifikátor ID, metódu pre čítanie a zápis atribútu //metóda send($message) volá metódu send() sprostredkovateľa na odosielanie správ //metóda receive($message) prijíma správy a je definovaná pre každého potomka triedy //AbstractEmployee abstract class AbstractEmployee { protected $ID; protected $mediator; public function __construct ($ID, Mediator $mediator) { $this -> SetID($ID); $this -> SetMediator($mediator); } public function SetID($ID) { $this -> ID = $ID; } public function GetID() { return $this -> ID; } public function SetMediator(Mediator $mediator) { $this -> mediator = $mediator; } public function GetMediator() { return $this -> mediator ; } public function send($message) { $this -> mediator -> send($message, $this); } public abstract function receive($message); } //trieda Mediator – zabezpečuje registráciu zamestnancov, odosielanie a prijímanie správ class NewMediator implements Mediator { protected $employee = array(); public function registerEmployee (AbstractEmployee $employee) { $this -> employees[] = $employee; } public function send($message, AbstractEmployee $sender) { foreach ($this -> employees as $employee) { if($employee !== $sender) { $employee ->receive($message); } } } } //potomok triedy AbstractEmployee – trieda Employee //metódou receive($message) sa volá sprostredkovateľ, ktorému sa odovzdá posielaná správa class Employee extends AbstractEmployee { public function receive($message) { printf("Prijatie správy: \n", $this -> GetID, $message); } } //testovací script $mediator = new NewMediator(); $employee1 = new Employee('Zamestnanec 1', $mediator); $employee2 = new Employee('Zamestnanec 2', $mediator); $employee3 = new Employee('Zamestnanec 3', $mediator); $employee3 = new Employee('Zamestnanec 4', $mediator); $mediator -> registerEmployee($employee1); $mediator -> registerEmployee($employee2); $mediator -> registerEmployee($employee3); $mediator -> registerEmployee($employee4); $employee3 -> send('Správa zaslaná od ZAM3'); $employee1 -> send('Správa prijatá od ZAM1'); } ?>

Here you find the average performance (time & memory) of each version. A grayed out version indicates it didn't complete successfully (based on exit-code).

VersionSystem time (s)User time (s)Memory (MiB)
5.6.150.0100.07718.19
5.6.140.0000.04718.15
5.6.130.0100.06718.14
5.6.120.0070.08021.02
5.6.110.0130.06321.00
5.6.100.0030.05321.01
5.6.90.0030.06721.12
5.6.80.0100.07720.43
5.5.300.0030.05318.01
5.5.290.0100.05717.98
5.5.280.0200.05720.90
5.5.270.0070.08020.82
5.5.260.0070.04020.91
5.5.250.0070.07320.63
5.5.240.0200.07720.09

preferences:
142.03 ms | 1394 KiB | 7 Q