3v4l.org

run code in 300+ PHP versions simultaneously
<?php // Instantiate object as singleton with private constructor class Test1 { protected static $instance; private function __construct() {} public function getInstance() { return isset(static::$instance) ? static::$instance : static::$instance = new static; } } // Instantiate object from caller class Test2 { public function __construct() {} } for ($t = 0; $t < 10000; $t++) { $s = microtime(true); $obj = Test1::getInstance(); $s = microtime(true) - $s; $tests['Test1'][] = $s; } for ($t = 0; $t < 10000; $t++) { $s = microtime(true); $obj = new Test2; $s = microtime(true) - $s; $tests['Test2'][] = $s; } printf("Test1 first result: %.6f s\n", array_shift($tests['Test1'])); printf("Test1 last result: %.6f s\n", array_pop($tests['Test1'])); printf("Test2 first result: %.6f s\n", array_shift($tests['Test2'])); printf("Test2 last result: %.6f s\n", array_pop($tests['Test2'])); printf("\nTest1 avg result: %.6f s\n", array_sum($tests['Test1']) / count($tests['Test1'])); printf("\nTest2 avg result: %.6f s\n", array_sum($tests['Test2']) / count($tests['Test2']));

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.3.10.0120.00816.21
7.3.00.0210.00516.44
7.2.130.0150.00916.39
7.2.120.0170.00816.34
7.2.110.0070.01016.18
7.2.100.0150.00316.52
7.2.90.0100.00616.31
7.2.80.0120.00616.55
7.2.70.0060.01216.99
7.2.60.0090.00616.29
7.2.50.0100.00716.84
7.2.40.0130.00716.67
7.2.30.0100.00716.94
7.2.20.0040.00816.58
7.2.10.0190.00016.71
7.2.00.0100.00817.82
7.1.250.0080.00815.18
7.1.70.0030.00917.00
7.1.60.0090.01619.32
7.1.50.0070.01416.86
7.1.00.0130.06722.36
7.0.200.0040.00416.43
7.0.140.0030.07321.95
7.0.110.0570.07320.09
7.0.100.0570.07320.00
7.0.90.0670.08020.04
7.0.80.0600.08720.03
7.0.70.0600.07019.96
7.0.60.0770.06319.93
7.0.50.0130.08719.91
7.0.40.0130.07319.89
7.0.30.0100.06719.74
7.0.20.0070.05719.70
7.0.10.0030.07719.86
7.0.00.0070.07319.59
5.6.280.0030.07721.21
5.6.260.0070.04720.71
5.6.250.0070.08020.71
5.6.240.0130.08020.72
5.6.230.0070.08320.61
5.6.220.0070.08320.72
5.6.210.0230.06720.77
5.6.200.0030.08320.62
5.6.190.0070.08320.67
5.6.180.0070.08020.71
5.6.170.0030.07320.75
5.6.160.0070.08020.74
5.6.150.0030.07320.59
5.6.140.0100.06720.71
5.6.130.0070.08320.70
5.6.120.0130.08020.61
5.6.110.0070.07720.75
5.6.100.0070.08720.60
5.6.90.0030.07720.50
5.6.80.0130.07320.29
5.6.70.0070.08320.12
5.6.60.0030.08019.99
5.6.50.0200.07019.98
5.6.40.0200.06720.06
5.6.30.0100.07720.02
5.6.20.0130.07019.96
5.6.10.0070.08019.96
5.6.00.0000.08720.26
5.5.380.0000.05717.52
5.5.370.0070.07017.71
5.5.360.0070.08717.61
5.5.350.0070.08717.73
5.5.340.0070.08318.07
5.5.330.0130.07718.00
5.5.320.0030.08318.15
5.5.310.0100.08018.13
5.5.300.0100.08018.19
5.5.290.0030.07717.96
5.5.280.0070.08017.96
5.5.270.0070.08317.82
5.5.260.0130.07018.12
5.5.250.0070.07717.96
5.5.240.0130.06717.54
5.5.230.0170.07017.37
5.5.220.0030.08017.24
5.5.210.0030.06017.48
5.5.200.0070.08017.23
5.5.190.0070.07717.42
5.5.180.0100.07317.51
5.5.160.0070.08717.51
5.5.150.0100.06017.50
5.5.140.0130.07017.31
5.5.130.0200.06717.45
5.5.120.0100.07717.28
5.5.110.0070.07717.31
5.5.100.0000.08317.25
5.5.90.0030.07717.14
5.5.80.0030.08017.40
5.5.70.0130.07317.31
5.5.60.0030.08017.25
5.5.50.0000.08017.28
5.5.40.0170.06717.34
5.5.30.0070.08317.37
5.5.20.0100.07017.20
5.5.10.0070.07317.40
5.5.00.0100.06017.38
5.4.450.0100.07319.34
5.4.440.0100.08019.38
5.4.430.0070.08019.37
5.4.420.0030.06319.66
5.4.410.0100.07319.16
5.4.400.0100.07019.34
5.4.390.0070.07719.26
5.4.380.0130.08019.13
5.4.370.0070.07318.99
5.4.360.0030.08319.04
5.4.350.0030.07718.97
5.4.340.0170.07019.01
5.4.320.0030.08018.95
5.4.310.0030.04318.94
5.4.300.0130.07018.98
5.4.290.0130.07319.06
5.4.280.0100.07319.09
5.4.270.0170.06319.02
5.4.260.0070.03319.04
5.4.250.0070.08018.98
5.4.240.0070.07718.95
5.4.230.0070.07719.15
5.4.220.0100.07719.09
5.4.210.0070.04318.96
5.4.200.0070.07719.24
5.4.190.0100.07319.01
5.4.180.0100.07719.04
5.4.170.0100.07018.95
5.4.160.0030.08319.12
5.4.150.0070.07718.96
5.4.140.0030.08016.58
5.4.130.0000.08316.57
5.4.120.0070.07016.50
5.4.110.0100.07016.43
5.4.100.0070.07016.69
5.4.90.0070.06016.49
5.4.80.0030.07716.50
5.4.70.0030.07316.52
5.4.60.0100.06316.34
5.4.50.0030.07016.61
5.4.40.0100.07016.27
5.4.30.0070.07316.48
5.4.20.0000.07716.38
5.4.10.0100.07316.39
5.4.00.0100.06315.92

preferences:
30.92 ms | 400 KiB | 5 Q