3v4l.org

run code in 300+ PHP versions simultaneously
<?php class TestFixedArray extends SplFixedArray { private $_elements; public function __sleep() { $arr = (array)$this; unset($arr["\0TestFixedArray\0_elements"]); $this->_elements = $arr; $this->setSize(0); $arr = null; return array('_elements'); } public function __wakeup() { $size = count($this->_elements); $this->setSize($size); for($i = 0; $i < $size; $i++) { $this[(int)$i] = (int)$this->_elements[$i]; } $this->_elements = null; unset($this->_elements); } } $n = 100000; $t = microtime(true); $m = memory_get_usage(true); if(file_exists('cache.txt')) { echo 'Unserialize' . PHP_EOL; $content = file_get_contents('cache.txt'); $a = igbinary_unserialize($content); //$a = unserialize($content); $content = null; } else { echo 'Serialize' . PHP_EOL; //$a = new SplFixedArray($n); $a = new TestFixedArray($n); //$a = array(); for($i = 0; $i < $n; $i++) { $a[(int)$i] = (int)$i; } if(!file_exists('cache.txt')) { var_dump('serialize'); //file_put_contents('cache.txt', serialize($a)); file_put_contents('cache.txt', igbinary_serialize($a)); } } echo 'Peak: ' . memory_get_peak_usage(true) . PHP_EOL; echo 'Usage: ' . (memory_get_usage(true) - $m) . PHP_EOL; echo 'Time: ' . (microtime(true) - $t) . PHP_EOL;

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.0070.02117.76
7.4.00.0150.00917.92
7.3.130.0150.00417.50
7.3.120.0130.01217.57
7.3.110.0030.01617.67
7.3.100.0070.01717.95
7.3.90.0040.01217.53
7.3.80.0000.01517.50
7.3.70.0040.01617.78
7.3.60.0070.01317.96
7.3.50.0120.00617.94
7.3.40.0030.01617.53
7.3.30.0100.01017.88
7.3.20.0000.01819.93
7.3.10.0000.01719.93
7.3.00.0120.00620.11
7.2.260.0100.01417.80
7.2.250.0060.01617.91
7.2.240.0090.01517.72
7.2.230.0070.01317.78
7.2.220.0100.01017.95
7.2.210.0070.01017.68
7.2.200.0100.01017.71
7.2.190.0000.02017.73
7.2.180.0060.01517.73
7.2.170.0080.01217.69
7.2.160.0000.02017.92
7.2.150.0080.00820.27
7.2.140.0060.01620.21
7.2.130.0070.01020.18
7.2.120.0000.01920.13
7.2.110.0060.01220.18
7.2.100.0070.01120.26
7.2.90.0100.01020.38
7.2.80.0040.01620.28
7.2.70.0060.00920.29
7.2.60.0140.00720.26
7.2.50.0000.02320.16
7.2.40.0070.01420.36
7.2.30.0060.01220.27
7.2.20.0060.01620.29
7.2.10.0000.01920.35
7.2.00.0050.01620.62
7.1.330.0070.02019.39
7.1.320.0000.01919.45
7.1.310.0100.01019.41
7.1.300.0040.01419.30
7.1.290.0120.01219.35
7.1.280.0030.02319.34
7.1.270.0030.02219.34
7.1.260.0030.02018.99
7.1.250.0040.01419.15
7.1.240.0070.01619.27
7.1.230.0060.01619.20
7.1.220.0070.01719.19
7.1.210.0070.01419.32
7.1.200.0100.01319.16
7.1.190.0070.01719.09
7.1.180.0070.01019.23
7.1.170.0070.01719.14
7.1.160.0070.01519.11
7.1.150.0150.00919.38
7.1.140.0100.01019.21
7.1.130.0070.01419.27
7.1.120.0070.01719.18
7.1.110.0030.01319.32
7.1.100.0030.01719.43
7.1.90.0060.01219.23
7.1.80.0000.01619.14
7.1.70.0050.01219.09
7.1.60.0100.01619.35
7.1.50.0030.01618.97
7.1.40.0030.01619.24
7.1.30.0030.02019.26
7.1.20.0070.01019.27
7.1.10.0060.01319.29
7.1.00.0100.04521.72
7.0.330.0070.01418.94
7.0.320.0070.01619.17
7.0.310.0030.01719.01
7.0.300.0060.01618.79
7.0.290.0030.02018.78
7.0.280.0070.01418.96
7.0.270.0070.01518.67
7.0.260.0070.01618.93
7.0.250.0090.01219.17
7.0.240.0030.02019.00
7.0.230.0090.00918.93
7.0.220.0000.02019.10
7.0.210.0090.01219.12
7.0.200.0000.01818.77
7.0.190.0060.00918.86
7.0.180.0080.01519.02
7.0.170.0070.01719.06
7.0.160.0060.01619.02
7.0.150.0060.01219.26
7.0.140.0120.00919.10
7.0.130.0090.00918.96
7.0.120.0040.01819.05
7.0.110.0000.01919.14
7.0.100.0000.02118.75
7.0.90.0030.01619.12
7.0.80.0000.02018.95
7.0.70.0070.01519.09
7.0.60.0110.04120.12
7.0.50.0180.03520.34
7.0.40.0150.04018.23
7.0.30.0180.04518.30
7.0.20.0100.04018.30
7.0.10.0130.03618.29
7.0.00.0110.04118.39
5.6.400.0100.02621.51
5.6.390.0100.02921.46
5.6.380.0070.03521.45
5.6.370.0160.02221.43
5.6.360.0070.03421.40
5.6.350.0070.03021.32
5.6.340.0060.02921.44
5.6.330.0070.03321.75
5.6.320.0070.02421.73
5.6.310.0070.03121.72
5.6.300.0120.02521.49
5.6.290.0140.02121.38
5.6.280.0050.06323.75
5.6.270.0070.02821.63
5.6.260.0030.03521.37
5.6.250.0070.03021.22
5.6.240.0000.03421.43
5.6.230.0070.03621.32
5.6.220.0100.02921.49
5.6.210.0150.04923.89
5.6.200.0170.05024.01
5.6.190.0070.05823.93
5.6.180.0180.04823.90
5.6.170.0200.06823.98
5.6.160.0080.05823.88
5.6.150.0200.04323.91
5.6.140.0150.05023.86
5.6.130.0210.04624.00
5.6.120.0130.05023.95
5.6.110.0170.05324.07
5.6.100.0230.05423.82
5.6.90.0350.05823.94
5.6.80.0200.06323.42
5.6.70.0180.05323.65
5.6.60.0220.05023.55
5.6.50.0240.05623.67
5.6.40.0270.05023.54
5.6.30.0270.05023.61
5.6.20.0220.05723.61
5.6.10.0230.05223.50
5.6.00.0280.04923.64
5.5.380.0140.02121.46
5.5.370.0030.04221.36
5.5.360.0100.02421.33
5.5.350.0120.05323.56
5.5.340.0150.05023.76
5.5.330.0130.05123.79
5.5.320.0080.05523.69
5.5.310.0120.05023.92
5.5.300.0130.04923.83
5.5.290.0080.05923.80
5.5.280.0070.05423.69
5.5.270.0270.05023.80
5.5.260.0270.04523.80
5.5.250.0270.05823.73
5.5.240.0200.05123.39
5.5.230.0250.05123.38
5.5.220.0200.04923.41
5.5.210.0200.04823.44
5.5.200.0250.05123.51
5.5.190.0270.05323.31
5.5.180.0230.05323.36
5.5.170.0130.02621.26
5.5.160.0200.05523.44
5.5.150.0230.05023.48
5.5.140.0230.05223.32
5.5.130.0270.04623.54
5.5.120.0220.05823.24
5.5.110.0230.05423.46
5.5.100.0230.05123.26
5.5.90.0320.05423.28
5.5.80.0170.05223.42
5.5.70.0100.04923.45
5.5.60.0080.06023.37
5.5.50.0200.05523.37
5.5.40.0320.04423.41
5.5.30.0200.05323.44
5.5.20.0320.04523.36
5.5.10.0250.05023.46
5.5.00.0250.04823.39

preferences:
33.85 ms | 403 KiB | 5 Q