3v4l.org

run code in 300+ PHP versions simultaneously
<?php function x($o) { return get_object_vars($o);} 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)) { $this->columns = array_keys(x($this)); 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.2.00.0000.06219.10
7.1.70.0100.07617.03
7.1.60.0100.10519.25
7.1.50.0070.06716.91
7.1.00.0200.14322.32
7.0.200.0000.05816.84
7.0.140.0070.15022.21
7.0.60.0030.11019.96
7.0.50.0100.13717.84
7.0.40.0030.10320.13
7.0.30.0270.10020.11
7.0.20.0230.13720.15
7.0.10.0100.09020.15
7.0.00.0130.14020.16
5.6.280.0070.26721.05
5.6.210.0100.22320.52
5.6.200.0030.16018.17
5.6.190.0000.16320.49
5.6.180.0170.15720.61
5.6.170.0170.17720.50
5.6.160.0100.16320.62
5.6.150.0100.20718.18
5.6.140.0030.16718.21
5.6.130.0000.16318.23
5.6.120.0030.16721.02
5.6.110.0070.19021.02
5.6.100.0030.16721.03
5.6.90.0000.21320.89
5.6.80.0170.19720.40
5.6.70.4500.16320.41
5.5.350.0130.18320.45
5.5.340.0170.22318.07
5.5.330.0100.21020.35
5.5.320.0230.19720.31
5.5.310.0330.22320.25
5.5.300.0030.24717.98
5.5.290.0030.17317.97
5.5.280.0130.21320.76
5.5.270.0030.21020.78
5.5.260.0130.25320.80
5.5.250.0170.22020.63
5.5.240.0370.21720.34
5.4.450.0730.29719.59
5.4.440.0470.31019.29
5.4.430.0130.37719.19
5.4.420.0930.35019.47
5.4.410.0170.31018.73
5.4.400.0300.33318.86
5.4.390.0330.30718.74
5.4.380.0270.29018.61
5.4.370.0100.25018.73
5.4.360.0130.27018.79
5.4.350.0110.42212.03
5.4.340.0070.27012.02
5.4.320.0080.25212.52
5.4.310.0050.24412.51
5.4.300.0050.25012.52
5.4.290.0060.22812.51
5.4.280.0040.24512.41
5.4.270.0060.24812.41
5.4.260.0100.27312.41
5.4.250.0080.25012.41
5.4.240.0060.24312.41
5.4.230.0070.23812.41
5.4.220.0070.27612.41
5.4.210.0080.36712.41
5.4.200.0030.24912.41
5.4.190.0070.25712.41
5.4.180.0110.28712.41
5.4.170.0100.23612.41
5.4.160.0050.24812.41
5.4.150.0060.22812.41
5.4.140.0040.27912.09
5.4.130.0060.24212.07
5.4.120.0050.25712.03
5.4.110.0080.27212.02
5.4.100.0080.26112.03
5.4.90.0070.33312.02
5.4.80.0070.27612.03
5.4.70.0050.26312.02
5.4.60.0060.29812.03
5.4.50.0050.28412.02
5.4.40.0070.24512.01
5.4.30.0090.31912.00
5.4.20.0130.29012.00
5.4.10.0110.29612.01
5.4.00.0070.26911.50
5.3.290.0030.05012.80
5.3.280.0070.04012.71
5.3.270.0070.04012.72
5.3.260.0090.04312.72
5.3.250.0100.03912.72
5.3.240.0070.04712.72
5.3.230.0090.04712.71
5.3.220.0140.05112.68
5.3.210.0080.05512.68
5.3.200.0070.03712.68
5.3.190.0060.04112.68
5.3.180.0100.03712.67
5.3.170.0150.04812.67
5.3.160.0170.02812.68
5.3.150.0070.04412.67
5.3.140.0090.04012.66
5.3.130.0070.04312.66
5.3.120.0120.05912.66
5.3.110.0090.05012.66
5.3.100.0130.06212.13
5.3.90.0110.04812.11
5.3.80.0100.06212.10
5.3.70.0170.05012.10
5.3.60.0080.04812.11
5.3.50.0110.04712.03
5.3.40.0110.05112.03
5.3.30.0090.04911.99
5.3.20.0120.06011.78
5.3.10.0060.03711.75
5.3.00.0120.04311.72
5.2.170.0070.0409.23
5.2.160.0170.0409.23
5.2.150.0090.0369.23
5.2.140.0040.0329.22
5.2.130.0020.0339.18
5.2.120.0040.0349.19
5.2.110.0030.0309.19
5.2.100.0050.0329.19
5.2.90.0050.0329.18
5.2.80.0070.0339.18
5.2.70.0080.0379.18
5.2.60.0050.0309.14
5.2.50.0070.0279.11
5.2.40.0070.0299.08
5.2.30.0080.0389.05
5.2.20.0060.0289.05
5.2.10.0060.0378.95
5.2.00.0040.0368.81
5.1.60.0090.0298.11
5.1.50.0050.0248.10
5.1.40.0060.0338.08
5.1.30.0020.0358.43
5.1.20.0090.0348.45
5.1.10.0050.0288.18
5.1.00.0030.0278.18
5.0.50.0050.0196.66
5.0.40.0030.0206.52
5.0.30.0050.0296.32
5.0.20.0020.0256.29
5.0.10.0030.0216.27
5.0.00.0010.0326.27
4.4.90.0030.0164.78
4.4.80.0050.0134.76
4.4.70.0040.0144.76
4.4.60.0030.0174.76
4.4.50.0040.0154.77
4.4.40.0020.0264.71
4.4.30.0020.0174.76
4.4.20.0010.0184.84
4.4.10.0030.0164.84
4.4.00.0040.0254.76
4.3.110.0010.0184.67
4.3.100.0040.0154.66
4.3.90.0050.0134.64
4.3.80.0020.0254.58
4.3.70.0040.0134.63
4.3.60.0010.0174.63
4.3.50.0030.0154.62
4.3.40.0030.0254.54
4.3.30.0030.0153.30
4.3.20.0020.0163.29
4.3.10.0040.0143.24
4.3.00.0130.0207.13

preferences:
31.14 ms | 400 KiB | 5 Q