3v4l.org

run code in 300+ PHP versions simultaneously
<?php class SingleInstance { private static $instances = []; public static function load($class, $args = null) { $checksum = md5($class.implode(', ', $args)); if (array_key_exists($checksum, self::$instances)) { echo "Hit!"; return self::$instances[$checksum]; } self::$instances[$checksum] = new $class(... $args); return self::$instances[$checksum]; } } class Words { private $word; private $word2; public function __construct($word, $word2) { $this->word = $word; $this->word2 = $word2; } public function show() { return $this->word." ".$this->word2; } } $a = SingleInstance::load('Words', ['Dog', 'Word1']); echo $a->show().PHP_EOL; $b = SingleInstance::load('Words', ['Cat', 'Word2']); echo $b->show().PHP_EOL; $c = SingleInstance::load('Words', ['Cat', 'Word2']); echo $c->show().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)
8.5.10.0120.00718.51
8.5.00.0070.01520.02
8.4.150.0020.00014.05
8.4.140.0120.00917.64
8.4.130.0140.00618.76
8.4.120.0070.00224.24
8.4.110.0110.00918.74
8.4.100.0110.01019.06
8.4.90.0140.00722.25
8.4.80.0090.01218.84
8.4.70.0020.00620.75
8.4.60.0130.00719.02
8.4.50.0150.00720.64
8.4.40.0090.00019.26
8.4.30.0030.00617.86
8.4.20.0070.01319.41
8.4.10.0030.00719.50
8.3.280.0100.00918.57
8.3.270.0130.00616.79
8.3.260.0120.00816.63
8.3.250.0100.00918.70
8.3.240.0120.00617.13
8.3.230.0110.00816.56
8.3.220.0050.00219.05
8.3.210.0080.01118.26
8.3.200.0050.00416.54
8.3.190.0080.01117.36
8.3.180.0090.00616.62
8.3.170.0090.00916.52
8.3.160.0110.00316.54
8.3.150.0120.00617.38
8.3.140.0040.00416.54
8.3.130.0040.00418.53
8.3.120.0040.01120.61
8.3.110.0080.00018.28
8.3.100.0100.01018.14
8.3.90.0000.00826.77
8.3.80.0080.00017.97
8.3.70.0100.01318.68
8.3.60.0000.01616.62
8.3.50.0100.00517.53
8.3.40.0120.00619.02
8.3.30.0130.00318.40
8.3.20.0030.00521.78
8.3.10.0040.00423.60
8.3.00.0040.00419.81
8.2.290.0090.01020.70
8.2.280.0100.00918.39
8.2.270.0120.00316.82
8.2.260.0090.00018.86
8.2.250.0100.01016.65
8.2.240.0090.00619.06
8.2.230.0170.00320.94
8.2.220.0000.00824.06
8.2.210.0060.00926.77
8.2.200.0030.00616.63
8.2.190.0070.01416.58
8.2.180.0170.00025.92
8.2.170.0060.00922.96
8.2.160.0200.00022.02
8.2.150.0080.00024.18
8.2.140.0000.00724.66
8.2.130.0000.00821.10
8.2.120.0040.00426.35
8.2.110.0060.00320.52
8.2.100.0090.00317.84
8.2.90.0050.00317.90
8.2.80.0000.00918.22
8.2.70.0030.00618.05
8.2.60.0030.00617.63
8.2.50.0040.00418.16
8.2.40.0040.00420.64
8.2.30.0000.00721.01
8.2.20.0070.00018.01
8.2.10.0000.00818.18
8.2.00.0040.00418.00
8.1.330.0080.01121.86
8.1.320.0090.01116.33
8.1.310.0030.00616.42
8.1.300.0060.00317.98
8.1.290.0100.00018.88
8.1.280.0120.00325.92
8.1.270.0070.00022.20
8.1.260.0070.00726.35
8.1.250.0070.00028.09
8.1.240.0030.00620.95
8.1.230.0080.00320.79
8.1.220.0000.00817.79
8.1.210.0000.00918.83
8.1.200.0000.00917.48
8.1.190.0040.00417.13
8.1.180.0060.00318.10
8.1.170.0000.00818.62
8.1.160.0060.00318.90
8.1.150.0040.00420.33
8.1.140.0000.00819.54
8.1.130.0030.00317.47
8.1.120.0040.00417.48
8.1.110.0080.00017.44
8.1.100.0000.00717.41
8.1.90.0030.00717.13
8.1.80.0020.00517.37
8.1.70.0000.00717.39
8.1.60.0040.00417.59
8.1.50.0050.00317.52
8.1.40.0030.00617.57
8.1.30.0000.00817.65
8.1.20.0000.00817.66
8.1.10.0040.00417.49
8.1.00.0040.00417.53
8.0.300.0000.00719.90
8.0.290.0060.00316.75
8.0.280.0000.00718.45
8.0.270.0000.00717.27
8.0.260.0000.00716.71
8.0.250.0040.00416.87
8.0.240.0030.00716.96
8.0.230.0080.00016.86
8.0.220.0040.00416.93
8.0.210.0000.00716.92
8.0.200.0070.00016.89
8.0.190.0030.00316.86
8.0.180.0000.00716.89
8.0.170.0000.01316.89
8.0.160.0000.00716.82
8.0.150.0040.00416.92
8.0.140.0000.00816.79
8.0.130.0030.00313.42
8.0.120.0030.00616.93
8.0.110.0070.00016.91
8.0.100.0040.00416.70
8.0.90.0040.00416.73
8.0.80.0030.01316.88
8.0.70.0040.00416.91
8.0.60.0070.00016.72
8.0.50.0030.00516.96
8.0.30.0060.01417.19
8.0.20.0110.00717.40
8.0.10.0000.00816.79
8.0.00.0130.00816.63
7.4.330.0030.00315.55
7.4.320.0050.00316.61
7.4.300.0070.00016.53
7.4.290.0030.00316.51
7.4.280.0000.00716.67
7.4.270.0030.00416.53
7.4.260.0030.00316.61
7.4.250.0050.00216.47
7.4.240.0000.00816.66
7.4.230.0040.00416.64
7.4.220.0030.00316.49
7.4.210.0070.01016.68
7.4.200.0070.00016.50
7.4.160.0080.01016.64
7.4.140.0090.01017.86
7.4.130.0070.01316.52
7.4.120.0150.00916.53
7.4.110.0120.00916.65
7.4.100.0070.01016.54
7.4.90.0110.00716.53
7.4.80.0120.01219.39
7.4.70.0100.00616.39
7.4.60.0060.01016.34
7.4.50.0090.00616.46
7.4.40.0030.01416.64
7.4.00.0000.01514.95
7.3.330.0050.00013.39
7.3.320.0000.00613.39
7.3.310.0030.00316.48
7.3.300.0030.00316.41
7.3.290.0090.00816.33
7.3.280.0100.00816.37
7.3.260.0150.00816.41
7.3.240.0060.01316.34
7.3.230.0130.00316.38
7.3.210.0070.01016.66
7.3.200.0150.00316.34
7.3.190.0090.00616.42
7.3.180.0100.00716.56
7.3.170.0140.00716.43
7.3.160.0080.00816.49
7.2.330.0030.01416.65
7.2.320.0060.01516.49
7.2.310.0110.00616.48
7.2.300.0130.00716.69
7.2.290.0070.01016.32
7.2.80.0040.00816.68
7.2.60.0130.00317.00
7.2.20.0190.00517.94
7.2.10.0140.01418.19
7.2.00.0470.01017.48
7.1.200.0100.00315.75
7.1.140.0120.00917.07
7.1.130.0160.01016.70
7.1.120.0210.00917.10
7.1.110.0150.01116.32
7.1.100.0130.01516.15
7.1.90.0130.01116.25
7.1.80.0140.01316.20
7.1.70.0150.01015.52
7.1.60.0380.01433.39
7.1.50.0300.01232.91
7.1.40.0240.01832.75
7.1.30.0300.01632.40
7.1.20.0360.02132.59
7.1.10.0110.00914.49
7.1.00.0430.01114.89

preferences:
160.77 ms | 403 KiB | 5 Q