3v4l.org

run code in 300+ PHP versions simultaneously
<?php if (substr(PHP_VERSION, 0, 5) !== '7.1.5') die('Meh'); function test($label = '') { global $t; $t2 = microtime(1); if ($label) echo str_pad($label . ': ', 32, '.', STR_PAD_RIGHT) . ' ' . 1000 * ($t2 - $t) . 'ms' . "\n"; $t = $t2; } class A { protected $_val = 123; function getVal() { return $this->_val; } function setVal($val) { $this->_val = $val; } } class A2 { protected $_val = 123; function getVal() { return $this->_val; } function setVal($val) { $this->_val = $val; } function __get($name) { return $this->{'__get_' . $name}($name); } function __set($name, $value) { $this->{'__set_' . $name}($value); } } class B { protected $val = 123; function __get($name) { return $this->{'__get_' . $name}($name); } function __set($name, $value) { $this->{'__set_' . $name}($value); } function __get_val() { return $this->val; } function __set_val($val) { $this->val = $val; } } class C { protected $val = 123; function __get($name) { return $this->val; } function __set($name, $value) { $this->val = $value; } } class D { public $val; function __construct() { $this->val = new Prop(123); } } class D2 { public $val; protected $_val = 123; function __construct() { $this->val = new Prop2(function () { return $this->_val; }, function ($value) { $this->_val = $value; }); } } class Prop { protected $_val = 123; function __construct($val) { $this->_val = $val; } function get() { return $this->_val; } function set($val) { $this->_val = $val; } } class Prop2 { protected $get; protected $set; function __construct($get, $set) { $this->get = $get; $this->set = $set; } function get() { return ($this->get)(); } function set($val) { ($this->set)($val); } } class E { public $val = 123; } $c = 1000000; test(); $x = new A(); for ($i = $c; $i--;) { $a = $x->getVal(); $x->setVal(321); } test('methods'); $x = new A2(); for ($i = $c; $i--;) { $a = $x->getVal(); $x->setVal(321); } test('methods + passive magic'); $x = new B(); for ($i = $c; $i--;) { $a = $x->val; $x->val = 321; } test('magic'); $x = new C(); for ($i = $c; $i--;) { $a = $x->val; $x->val = 321; } test('light magic'); $x = new D(); for ($i = $c; $i--;) { $a = $x->val->get(); $x->val->set(321); } test('nested object'); $x = new D2(); for ($i = $c; $i--;) { $a = $x->val->get(); $x->val->set(321); } test('nested proxy'); $x = new E(); for ($i = $c; $i--;) { $a = $x->val; $x->val = 321; } test('property');

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.2.00.0070.00719.14
7.1.70.0050.00216.94
7.1.60.1760.00315.24
7.1.50.0771.57232.78
7.1.40.0400.01732.58
7.1.30.0530.02032.64
7.1.20.0430.01732.68
7.1.10.0370.01014.55
7.1.00.0400.00714.67
7.0.200.0160.00616.64
7.0.190.0470.00714.65
7.0.180.0430.00314.34
7.0.170.0500.00714.25
7.0.160.0570.01014.45
7.0.150.0400.00314.32
7.0.140.0500.00714.56
7.0.130.0370.00714.57
7.0.120.0330.01014.48
7.0.110.0330.01014.41
7.0.100.0400.00314.35
7.0.90.0330.01014.52
7.0.80.0300.01014.42
7.0.70.0300.01014.54
7.0.60.0330.01314.24
7.0.50.0400.01314.23
7.0.40.0330.00714.59
7.0.30.0970.01014.50
7.0.20.0300.00714.48
7.0.10.0300.01014.45
7.0.00.0330.01014.54

preferences:
29.36 ms | 401 KiB | 5 Q