3v4l.org

run code in 300+ PHP versions simultaneously
<?php class A { public $a; public $b; private $c; protected static $columnRegistry = array(); protected $columns = array(); public function __construct($a, $b, $c) { $this->a = $a; $this->b = $b; $this->c = $c; $this->setupColumns(); } public function toArray() { $ret = []; foreach ($this->columns as $column) { $ret[$column] = $this->$column; } return $ret; } protected function setupColumns() { $class = get_class($this); // Define columns for current row if (!array_key_exists($class, self::$columnRegistry)) { foreach ((new ReflectionClass($this))->getProperties(ReflectionProperty::IS_PUBLIC) as $property) { if (!$property->isStatic()) { $this->columns[] = $property->getName(); } } self::$columnRegistry[$class] = $this->columns; } else { $this->columns = self::$columnRegistry[$class]; } } } $expected = [ 'a' => 1, 'b' => 2, ]; $numReps = 100000; for($i = 0; $i < $numReps; $i++) { $o = new A(1, 2, 3); $res = $o->toArray(); if ($res !== $expected) { throw new Exception("Not same"); } } echo "OK";

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)
8.3.60.0130.04716.63
8.3.50.0080.04821.97
8.3.40.0070.04818.68
8.3.30.0100.06119.04
8.3.20.0070.02220.21
8.3.10.0060.02421.90
8.3.00.0070.02318.01
8.2.180.0130.06316.50
8.2.170.0170.05622.96
8.2.160.0030.05220.38
8.2.150.0100.02024.18
8.2.140.0070.02324.66
8.2.130.0030.02826.16
8.2.120.0030.02721.09
8.2.110.0090.04122.26
8.2.100.0070.04019.79
8.2.90.0030.04419.17
8.2.80.0070.04017.97
8.2.70.0000.04517.50
8.2.60.0040.04917.93
8.2.50.0070.03918.07
8.2.40.0070.03720.07
8.2.30.0030.04518.32
8.2.20.0060.04017.67
8.2.10.0030.04318.19
8.2.00.0000.04817.76
8.1.280.0100.04825.92
8.1.270.0030.04522.02
8.1.260.0030.02726.35
8.1.250.0070.02328.09
8.1.240.0030.04323.65
8.1.230.0100.03419.12
8.1.220.0030.04117.79
8.1.210.0000.04418.77
8.1.200.0030.04117.23
8.1.190.0000.04417.23
8.1.180.0030.03918.10
8.1.170.0030.04018.59
8.1.160.0030.03821.93
8.1.150.0070.03618.93
8.1.140.0000.04417.38
8.1.130.0000.04017.90
8.1.120.0030.04117.49
8.1.110.0030.04117.51
8.1.100.0000.04417.48
8.1.90.0070.03717.46
8.1.80.0000.04217.38
8.1.70.0000.04517.46
8.1.60.0130.03517.59
8.1.50.0040.04217.52
8.1.40.0070.03817.48
8.1.30.0070.04017.65
8.1.20.0070.04017.59
8.1.10.0030.04217.48
8.1.00.0060.03917.41
8.0.300.0070.03718.77
8.0.290.0030.04116.75
8.0.280.0030.04018.35
8.0.270.0000.04417.13
8.0.260.0060.04217.27
8.0.250.0030.04316.97
8.0.240.0030.04216.93
8.0.230.0030.04317.02
8.0.220.0030.05216.95
8.0.210.0000.04716.91
8.0.200.0030.04116.88
8.0.190.0000.04616.97
8.0.180.0030.04316.90
8.0.170.0070.04016.90
8.0.160.0070.03916.93
8.0.150.0000.04716.91
8.0.140.0030.05616.89
8.0.130.0060.03913.38
8.0.120.0070.04016.90
8.0.110.0060.03916.80
8.0.100.0030.04116.76
8.0.90.0070.04016.83
8.0.80.0100.06616.97
8.0.70.0030.04216.96
8.0.60.0030.04616.80
8.0.50.0030.04416.97
8.0.30.0100.06117.06
8.0.20.0110.06117.44
8.0.10.0060.04116.92
8.0.00.0060.07216.77
7.4.330.0030.04015.00
7.4.320.0060.03916.52
7.4.300.0000.04716.53
7.4.290.0100.03816.42
7.4.280.0030.04516.63
7.4.270.0030.04416.63
7.4.260.0070.04016.52
7.4.250.0000.04916.55
7.4.240.0050.04416.53
7.4.230.0030.04516.42
7.4.220.0000.08216.52
7.4.210.0070.07516.57
7.4.200.0000.04916.26
7.4.160.0140.07416.68
7.4.150.0100.08717.40
7.4.140.0080.08617.86
7.4.130.0120.07616.49
7.4.120.0080.07616.51
7.4.110.0100.07416.50
7.4.100.0120.06716.55
7.4.90.0130.06616.43
7.4.80.0270.11119.39
7.4.70.0100.06416.43
7.4.60.0070.07016.49
7.4.50.0030.05616.50
7.4.40.0120.11116.40
7.4.30.0070.06416.58
7.4.00.0070.08314.79
7.3.330.0070.05613.18
7.3.320.0030.04713.43
7.3.310.0030.04916.43
7.3.300.0030.04916.23
7.3.290.0060.06816.41
7.3.280.0100.07916.40
7.3.270.0060.08817.40
7.3.260.0100.07116.66
7.3.250.0080.08816.46
7.3.240.0060.07716.37
7.3.230.0060.07116.41
7.3.210.0130.07316.57
7.3.200.0100.13619.39
7.3.190.0060.14716.50
7.3.180.0070.06816.40
7.3.170.0060.09016.45
7.3.160.0030.07716.65
7.3.120.0070.07614.73
7.2.330.0100.07516.89
7.2.320.0060.08116.77
7.2.310.0130.12516.84
7.2.300.0070.07816.84
7.2.290.0060.07816.76
7.2.00.0030.04919.30
7.1.100.0000.10318.05
7.1.70.0100.05516.88
7.1.60.0100.10919.25
7.1.50.0130.08616.79
7.1.00.0070.16022.54
7.0.200.0030.05716.79
7.0.140.0070.15322.01
7.0.60.0070.12019.94
7.0.50.0030.14017.98
7.0.40.0030.10720.04
7.0.30.0230.13720.06
7.0.20.0300.15020.21
7.0.10.0100.11320.25
7.0.00.0030.16020.09
5.6.280.0000.27020.86
5.6.210.0200.20720.73
5.6.200.0070.18318.31
5.6.190.0100.20320.63
5.6.180.0400.19320.77
5.6.170.0170.16020.58
5.6.160.0070.21720.48
5.6.150.0030.18018.23
5.6.140.0130.21018.21
5.6.130.0030.18318.23
5.6.120.0070.23721.13
5.6.110.0070.23320.97
5.6.100.0030.23021.12
5.6.90.0070.18321.03
5.6.80.0100.25720.54
5.5.350.0200.21320.45
5.5.340.0030.23017.93
5.5.330.0070.24020.30
5.5.320.0370.21320.30
5.5.310.0300.27020.26
5.5.300.0070.17018.05
5.5.290.0030.18318.07
5.5.280.0030.23320.66
5.5.270.0070.23020.70
5.5.260.0030.18320.73
5.5.250.0030.19020.80
5.5.240.0300.21720.09
5.4.450.0170.35319.63
5.4.440.0070.31719.55
5.4.430.0130.30019.53
5.4.420.0100.31719.53
5.4.410.0100.51718.92
5.4.400.0230.38018.79
5.4.390.0200.31718.80
5.4.380.0100.32018.62
5.4.370.0270.32718.63
5.4.360.0170.37718.51
5.4.350.0080.30512.03
5.4.340.0070.22612.03
5.4.320.0050.25612.52
5.4.310.0070.25212.50
5.4.300.0070.27912.51
5.4.290.0080.32012.51
5.4.280.0080.23112.40
5.4.270.0090.25012.40
5.4.260.0070.23712.41
5.4.250.0040.24412.40
5.4.240.0070.24312.40
5.4.230.0100.26512.40
5.4.220.0080.23512.40
5.4.210.0110.25412.39
5.4.200.0060.23112.40
5.4.190.0040.25012.39
5.4.180.0090.24912.39
5.4.170.0070.24012.41
5.4.160.0080.25012.40
5.4.150.0070.23712.40
5.4.140.0070.26512.08
5.4.130.0080.22312.07
5.4.120.0040.24512.03
5.4.110.0060.26512.02
5.4.100.0080.22612.02
5.4.90.0080.25012.02
5.4.80.0060.24212.02
5.4.70.0050.23412.02
5.4.60.0110.26912.02
5.4.50.0060.28112.02
5.4.40.0090.23712.00
5.4.30.0070.25112.00
5.4.20.0070.24712.01
5.4.10.0060.24612.01
5.4.00.0080.23811.49
5.3.290.0050.03912.80
5.3.280.0050.03912.71
5.3.270.0040.04212.72
5.3.260.0080.03812.72
5.3.250.0090.03612.72
5.3.240.0060.03912.71
5.3.230.0070.03712.71
5.3.220.0060.03812.68
5.3.210.0070.04212.68
5.3.200.0070.04212.68
5.3.190.0050.03812.67
5.3.180.0080.03612.67
5.3.170.0050.04512.67
5.3.160.0070.03712.68
5.3.150.0080.04112.68
5.3.140.0040.03912.66
5.3.130.0070.03812.66
5.3.120.0030.04312.66
5.3.110.0080.03812.66
5.3.100.0100.03312.13
5.3.90.0040.03912.11
5.3.80.0090.03512.09
5.3.70.0060.03712.10
5.3.60.0090.03612.09
5.3.50.0070.04312.03
5.3.40.0090.04712.02
5.3.30.0070.03211.99
5.3.20.0080.03511.77
5.3.10.0090.03211.74
5.3.00.0060.03711.72
5.2.170.0040.0329.23
5.2.160.0070.0279.23
5.2.150.0040.0319.22
5.2.140.0080.0389.22
5.2.130.0080.0279.18
5.2.120.0030.0319.18
5.2.110.0070.0279.19
5.2.100.0060.0289.19
5.2.90.0070.0279.18
5.2.80.0060.0309.18
5.2.70.0080.0289.18
5.2.60.0030.0339.14
5.2.50.0050.0299.10
5.2.40.0030.0319.08
5.2.30.0060.0299.06
5.2.20.0060.0309.05
5.2.10.0050.0298.95
5.2.00.0060.0298.82
5.1.60.0070.0248.10
5.1.50.0040.0258.10
5.1.40.0060.0248.07
5.1.30.0060.0258.43
5.1.20.0140.0288.45
5.1.10.0120.0368.17
5.1.00.0050.0278.18
5.0.50.0040.0216.65
5.0.40.0020.0226.51
5.0.30.0040.0326.32
5.0.20.0060.0186.29
5.0.10.0030.0256.27
5.0.00.0060.0386.26
4.4.90.0040.0214.78
4.4.80.0050.0234.75
4.4.70.0060.0184.75
4.4.60.0020.0224.76
4.4.50.0020.0224.77
4.4.40.0050.0304.71
4.4.30.0020.0174.76
4.4.20.0020.0174.85
4.4.10.0030.0164.85
4.4.00.0030.0284.76
4.3.110.0030.0154.67
4.3.100.0000.0174.67
4.3.90.0030.0144.63
4.3.80.0020.0254.58
4.3.70.0010.0164.63
4.3.60.0040.0134.63
4.3.50.0030.0154.63
4.3.40.0030.0244.54
4.3.30.0010.0173.30
4.3.20.0020.0163.28
4.3.10.0030.0153.24
4.3.00.0100.0237.17

preferences:
39.01 ms | 401 KiB | 5 Q