3v4l.org

run code in 300+ PHP versions simultaneously
<?php $entity = makeEntity(null, 'SuperWidget', [ 'foo' => 'bar', 'baz' => 'bla', ], // false // Toggle these two line's comments. true // Leave off or false to not show logging. ); $entity->send(_m('propBoo', 'hoo')); $entity->send(_m('propOop', 'Php')); $entity->send(_m('propBaz', 'Apt')); $entity->send(_m('withProps', [ ['propBaz', 'Oth'], ['propOth', 'Win'], ])); $entity->send(_m('propGen', ['Era','Tor',])); // Erases the history, should we have it? $entity->send(_m('fromProps', [['propOof','Uhh']])); $props = $entity->send(_i()); foreach($props as $prop => $props) { echo sprintf('%s(%s=%s)%s', $entity->key(), $prop, \json_encode($props), PHP_EOL ); } function makeEntity( ?int $id = null, string $type, ?array $props = null, ?bool $log = null ) { $id = $id ?? random_int(1, 500000); $logger = _f(!$log ?: function($signal, $message = null, ?string $tmpl = null) use($id) { $tmpl = sprintf('Receiver(%d, Signal: %s)', $id, $tmpl ?? '[%s](%s)'); echo sprintf($tmpl, $signal, \json_encode($message)).PHP_EOL; }); $apply = function($changes, $for) use($logger) { foreach($changes as $set) { $action = array_shift($set); // First one is the method, PropertySet list($prop, $value) = $set; if (substr($prop, 0, 7) !== 'Stream:') $for[$prop] = $value; $logger(sprintf('Apply(%s=%s)', $action, \json_encode($set)), null, '%s'); } return $for; }; $propDecorator = function(array $changes, array $changeSet = []) { return array_reduce($changes, function($changeSet, array $change) { $propName = strtolower(substr($change[0], 4)); $changeSet[] = ['PropertySet', $propName, $change]; return $changeSet; }, $changeSet); }; $filterSignalOut = function($changeSet) { return array_filter($changeSet, function($change) { return substr($change[1], 0, 7) !== 'Stream:'; }); }; $filterSignalIn = function($changeSet) { return array_filter($changeSet, function($change) { return substr($change[1], 0, 7) === 'Stream:'; }); }; $changeSet = [ ['SIGINI', 'Stream:Init', microtime(),], ['SIGIID', 'Stream:InitId', $id], ['SIGBND', 'Stream:BindProps', $props,], // Initial state. ]; while (true) { list($signal, $message) = yield; $signal = preg_replace('/[^a-z\d]/i', '', (string) $signal); $logger($signal, $message); if (substr($signal, 0, 4) === 'prop') { $propName = strtolower(substr($signal, 4)); $changeSet[] = ['PropertySet', $propName, $message]; } if ($signal === 'withProps') { $changeSet = $propDecorator($message, $changeSet); } if ($signal === 'fromProps') { $changeSet[] = ['SIGFRM', 'Stream:From', microtime(),]; $changeSet[] = ['SIGIFO', 'Stream:PrunedHistory', \json_encode($filterSignalOut($changeSet)), ]; $changeSet = $propDecorator($message, $filterSignalIn($changeSet)); } if ($signal === 'iterator') { $changeSet[] = ['SIGEND', 'Stream:End', microtime(),]; yield $type => $apply($changeSet, $props); } } } function _f($F = null) {return is_callable($F) ? $F : function(){};} function _i() {return _m('iterator');} function _m($signal, $message = null) {return [$signal ?? 'iterator',$message];}

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)
7.3.10.0070.00716.80
7.3.00.0030.00717.02
7.2.130.0080.00417.06
7.2.120.0050.00517.08
7.2.110.0030.00917.16
7.2.100.0090.00617.13
7.2.90.0060.00617.04
7.2.80.0030.00817.08
7.2.70.0110.00317.20
7.2.60.0140.00017.12
7.2.50.0040.01117.04
7.2.40.0030.01017.34
7.2.30.0090.00917.95
7.2.20.0080.00917.66
7.2.10.0090.01117.83
7.2.00.0090.00817.70
7.1.250.0070.00315.80
7.1.150.0160.00517.30
7.1.140.0150.01517.25
7.1.130.0170.01317.27
7.1.120.0130.01016.86
7.1.110.0080.01316.68
7.1.100.0080.01516.71
7.1.90.0140.01016.42
7.1.80.0090.00816.45
7.1.70.0620.00915.49
7.1.60.0300.00833.70
7.1.50.0220.01533.06
7.1.40.0250.01333.04
7.1.30.0290.01233.00
7.1.20.0450.01233.22
7.1.10.0130.00714.96
7.1.00.0090.01215.09

preferences:
22.26 ms | 401 KiB | 5 Q