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; $start = microtime(true); for($i = 0; $i < $numReps; $i++) { $o = new A(1, 2, 3); $res = $o->toArray(); if ($res !== $expected) { throw new Exception("Not same"); } } $end = microtime(true); $mem = memory_get_peak_usage(true); echo number_format($end-$start, 8) . "\t$mem\n";

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.4.10.0130.10716.58
7.4.00.0100.07216.70
7.3.130.0070.08316.55
7.3.120.0030.12116.48
7.3.110.0100.07116.62
7.3.100.0030.09516.56
7.3.90.0070.09816.43
7.3.80.0070.07216.38
7.3.70.0030.08516.52
7.3.60.0070.08116.61
7.3.50.0070.08016.59
7.3.40.0000.08516.49
7.3.30.0030.08816.48
7.3.20.0130.08218.25
7.3.10.0070.07518.25
7.3.00.0030.10318.26
7.2.260.0190.11116.86
7.2.250.0100.12616.69
7.2.240.0070.08416.89
7.2.230.0000.11416.43
7.2.220.0070.08316.83
7.2.210.0030.08716.59
7.2.200.0030.09116.64
7.2.190.0070.09116.68
7.2.180.0060.07816.64
7.2.170.0000.12516.72
7.2.160.0070.08816.54
7.2.150.0030.08818.61
7.2.140.0100.08218.59
7.2.130.0030.08918.50
7.2.120.0070.09718.67
7.2.110.0000.08618.71
7.2.100.0070.07718.59
7.2.90.0030.09218.55
7.2.80.0000.11118.68
7.2.70.0030.09418.37
7.2.60.0070.09018.38
7.2.50.0070.08418.51
7.2.40.0130.09818.55
7.2.30.0100.08218.50
7.2.20.0070.11818.42
7.2.10.0000.09618.57
7.2.00.0050.07318.89
7.1.330.0130.14017.64
7.1.320.0030.14217.52
7.1.310.0030.12017.43
7.1.300.0060.13517.52
7.1.290.0070.12217.43
7.1.280.0100.17117.30
7.1.270.0070.12117.42
7.1.260.0030.14017.33
7.1.250.0100.12217.42
7.1.240.0030.13917.38
7.1.230.0000.12517.38
7.1.220.0070.13817.41
7.1.210.0000.13217.26
7.1.200.0100.15417.41
7.1.190.0060.12417.33
7.1.180.0070.13617.58
7.1.170.0030.12517.40
7.1.160.0070.13917.45
7.1.150.0030.12817.40
7.1.140.0070.12117.39
7.1.130.0000.16617.28
7.1.120.0070.16217.39
7.1.110.0030.17817.42
7.1.100.0000.15017.32
7.1.90.0070.13817.50
7.1.80.0070.12417.49
7.1.70.0030.10417.37
7.1.60.0080.12518.32
7.1.50.0100.11917.16
7.1.40.0070.15117.33
7.1.30.0030.12217.41
7.1.20.0030.14917.61
7.1.10.0100.16417.43
7.1.00.0070.14519.90
7.0.330.0070.12617.11
7.0.320.0070.13417.14
7.0.310.0070.13317.07
7.0.300.0030.13617.20
7.0.290.0000.18017.18
7.0.280.0030.16917.12
7.0.270.0030.12917.11
7.0.260.0070.17017.27
7.0.250.0070.13817.14
7.0.240.0030.12417.06
7.0.230.0070.12716.98
7.0.220.0070.13517.18
7.0.210.0030.12717.02
7.0.200.0030.09916.94
7.0.190.0030.12617.00
7.0.180.0070.13517.09
7.0.170.0000.17517.17
7.0.160.0100.14117.00
7.0.150.0030.14917.07
7.0.140.0070.16719.54
7.0.130.0070.12317.13
7.0.120.0030.14317.11
7.0.110.0000.14717.20
7.0.100.0030.14617.11
7.0.90.0030.14117.07
7.0.80.0000.17017.10
7.0.70.0000.15417.04
7.0.60.0080.13618.55
7.0.50.0080.13217.49
7.0.40.0080.15417.74
7.0.30.0250.13517.73
7.0.20.0080.15617.58
7.0.10.0080.11317.60
7.0.00.0070.13917.63
5.6.400.0070.30116.22
5.6.390.0030.31815.97
5.6.380.0130.30816.20
5.6.370.0030.26716.16
5.6.360.0030.33716.16
5.6.350.0070.24716.10
5.6.340.0070.29216.00
5.6.330.0030.31516.19
5.6.320.0030.28416.14
5.6.310.0000.26416.18
5.6.300.0070.28116.33
5.6.290.0030.27415.97
5.6.280.0030.26118.53
5.6.270.0030.30116.18
5.6.260.0070.26216.21
5.6.250.0030.34916.31
5.6.240.0030.28816.09
5.6.230.0070.24016.13
5.6.220.0030.24516.18
5.6.210.0030.23018.31
5.6.200.0070.26217.10
5.6.190.0030.24918.16
5.6.180.0100.22018.39
5.6.170.0080.22618.27
5.6.160.0050.24218.56
5.6.150.0030.25917.03
5.6.140.0100.27317.18
5.6.130.0030.20617.18
5.6.120.0080.25518.50
5.6.110.0050.28818.65
5.6.100.0030.27518.71
5.6.90.0070.24018.61
5.6.80.0000.25818.20
5.6.70.2300.23918.26
5.6.60.0030.24816.00
5.6.50.0070.29016.02
5.6.40.0100.25316.02
5.6.30.0030.36516.15
5.6.20.0030.36415.98
5.6.10.0030.33416.03
5.6.00.0030.26516.05
5.5.380.0070.28515.82
5.5.370.0100.24215.94
5.5.360.0070.28515.94
5.5.350.0150.25418.23
5.5.340.0030.24116.98
5.5.330.0020.25318.22
5.5.320.0250.23018.30
5.5.310.0200.21218.21
5.5.300.0100.25217.00
5.5.290.0050.25217.12
5.5.280.0070.22518.51
5.5.270.0030.24018.36
5.5.260.0080.28318.37
5.5.250.0050.25918.34
5.5.240.2050.24017.99
5.5.230.0000.29416.03
5.5.220.0100.32216.03
5.5.210.0070.27315.93
5.5.200.0100.34316.04
5.5.190.0070.31715.86
5.5.180.0070.33516.22
5.5.170.0030.31916.06
5.5.160.0030.27215.86
5.5.150.0030.30316.16
5.5.140.0000.25015.81
5.5.130.0070.27915.94
5.5.120.0070.27815.86
5.5.110.0070.34515.92
5.5.100.0100.27516.29
5.5.90.0070.27216.04
5.5.80.0100.29616.09
5.5.70.0070.25316.12
5.5.60.0070.28716.09
5.5.50.0030.29716.06
5.5.40.0030.27816.05
5.5.30.0030.25016.13
5.5.20.0070.35615.97
5.5.10.0000.28016.15
5.5.00.0030.25316.20
5.4.450.0170.22616.09
5.4.440.0630.23616.15
5.4.430.0030.29516.29
5.4.420.0070.33616.28
5.4.410.0130.30716.12
5.4.400.0070.37015.97
5.4.390.0020.32415.74
5.4.380.0030.29515.83
5.4.370.0100.26815.68
5.4.360.0070.32115.73
5.4.350.0070.35112.48
5.4.340.0090.28912.50
5.4.330.0000.31012.88
5.4.320.0060.25712.71
5.4.310.0060.24612.82
5.4.300.0040.25812.64
5.4.290.0070.24512.68
5.4.280.0050.26912.70
5.4.270.0060.29112.63
5.4.260.0040.27112.63
5.4.250.0040.24612.61
5.4.240.0060.26212.61
5.4.230.0050.27312.69
5.4.220.0040.26512.58
5.4.210.0030.24812.66
5.4.200.0070.25612.68
5.4.190.0050.26712.69
5.4.180.0020.30312.63
5.4.170.0030.27712.63
5.4.160.0080.29712.55
5.4.150.0070.27012.51
5.4.140.0040.28612.57
5.4.130.0040.25212.50
5.4.120.0050.25612.42
5.4.110.0080.31112.46
5.4.100.0100.33712.60
5.4.90.0060.29312.52
5.4.80.0060.24612.52
5.4.70.0100.32912.51
5.4.60.0040.24612.36
5.4.50.0080.24412.41
5.4.40.0050.24712.51
5.4.30.0020.26912.52
5.4.20.0050.26012.46
5.4.10.0070.24412.45
5.4.00.0070.26612.25
5.3.290.0020.02612.75
5.3.280.0050.02312.64
5.3.270.0060.02312.74
5.3.260.0050.02212.77
5.3.250.0040.02212.72
5.3.240.0050.02112.61
5.3.230.0040.02112.70
5.3.220.0070.01812.76
5.3.210.0020.02412.68
5.3.200.0060.02112.68
5.3.190.0050.02312.77
5.3.180.0030.02312.76
5.3.170.0040.02212.77
5.3.160.0060.02212.76
5.3.150.0060.02012.76
5.3.140.0070.02012.73
5.3.130.0040.02512.73
5.3.120.0040.02112.73
5.3.110.0060.02112.78
5.3.100.0040.02312.43
5.3.90.0070.02312.48
5.3.80.0020.02212.36
5.3.70.0080.02412.41
5.3.60.0070.02212.57
5.3.50.0080.02512.40
5.3.40.0060.02612.35
5.3.30.0050.02412.34
5.3.20.0050.02612.27
5.3.10.0050.02012.12
5.3.00.0050.02112.11
5.2.170.0070.0389.22
5.2.160.0050.0319.23
5.2.150.0070.0309.23
5.2.140.0090.0279.22
5.2.130.0050.0299.18
5.2.120.0040.0299.18
5.2.110.0040.0299.18
5.2.100.0080.0259.19
5.2.90.0040.0299.18
5.2.80.0060.0289.18
5.2.70.0050.0299.18
5.2.60.0070.0279.14
5.2.50.0040.0309.10
5.2.40.0030.0309.08
5.2.30.0050.0359.05
5.2.20.0060.0279.05
5.2.10.0050.0288.95
5.2.00.0070.0278.82
5.1.60.0050.0238.10
5.1.50.0030.0258.10
5.1.40.0030.0268.07
5.1.30.0050.0258.43
5.1.20.0030.0288.45
5.1.10.0040.0268.18
5.1.00.0060.0348.18
5.0.50.0030.0286.65
5.0.40.0030.0276.52
5.0.30.0060.0366.32
5.0.20.0020.0216.29
5.0.10.0030.0206.27
5.0.00.0050.0296.26
4.4.90.0000.0184.78
4.4.80.0050.0134.76
4.4.70.0020.0164.75
4.4.60.0040.0154.75
4.4.50.0030.0154.77
4.4.40.0030.0254.71
4.4.30.0050.0154.76
4.4.20.0020.0174.85
4.4.10.0030.0154.84
4.4.00.0020.0254.75
4.3.110.0010.0174.67
4.3.100.0020.0154.67
4.3.90.0030.0144.63
4.3.80.0010.0264.58
4.3.70.0030.0154.63
4.3.60.0040.0144.63
4.3.50.0020.0164.63
4.3.40.0030.0244.54
4.3.30.0010.0173.30
4.3.20.0010.0173.28
4.3.10.0010.0173.23
4.3.00.0070.01715.25

preferences:
37.17 ms | 401 KiB | 5 Q