3v4l.org

run code in 300+ PHP versions simultaneously
$value = null; $executed = false; return function () use ($producer, & $value, & $executed) { if (!$executed) { $value = $producer(); $executed = true; } return $value; }; <?php class Connection {} class Context { public function get_instance(){ static $i; $i ?: $i = new Connection(); return $i; } } class A extends Context {} class B extends A {} class Context2 { protected $conn; public function __constructor() { $this->conn = new Connection(); // Should be lazily created but imagine we have once(). } public function get_instance(){ return $this->conn; } } class A2 extends Context2 {} class B2 extends A2 {} $a = new A(); $b = new B(); $a2 = new A2(); $b2 = new B2(); var_dump($a->get_instance()); var_dump($b->get_instance()); var_dump($a2->get_instance()); var_dump($b2->get_instance());

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.3.60.0100.00618.18
8.3.50.0120.01022.05
8.3.40.0040.01118.87
8.3.30.0110.00419.13
8.3.20.0050.00220.16
8.3.10.0040.00423.66
8.3.00.0080.00019.19
8.2.180.0130.00316.88
8.2.170.0070.00722.96
8.2.160.0100.00322.18
8.2.150.0080.00024.18
8.2.140.0030.00524.66
8.2.130.0000.00826.16
8.2.120.0080.00019.67
8.2.110.0000.01020.85
8.2.100.0080.00419.64
8.2.90.0040.00417.91
8.2.80.0000.00817.97
8.2.70.0030.00618.03
8.2.60.0000.01018.03
8.2.50.0000.00818.10
8.2.40.0030.00521.18
8.2.30.0040.00419.21
8.2.20.0030.00617.62
8.2.10.0070.00017.96
8.2.00.0030.00617.71
8.1.280.0100.00625.92
8.1.270.0040.00418.68
8.1.260.0050.00326.35
8.1.250.0030.00628.09
8.1.240.0060.00323.77
8.1.230.0080.00422.69
8.1.220.0040.00417.77
8.1.210.0050.00319.03
8.1.200.0100.00017.36
8.1.190.0000.00817.35
8.1.180.0040.00418.10
8.1.170.0040.00418.64
8.1.160.0040.00418.94
8.1.150.0000.00818.87
8.1.140.0030.00517.36
8.1.130.0060.00317.85
8.1.120.0000.00717.50
8.1.110.0080.00017.38
8.1.100.0040.00417.39
8.1.90.0080.00017.54
8.1.80.0040.00417.38
8.1.70.0070.00017.30
8.1.60.0040.00417.45
8.1.50.0040.00417.50
8.1.40.0080.00017.47
8.1.30.0060.00317.59
8.1.20.0030.00517.57
8.1.10.0000.00717.53
8.1.00.0040.00417.53
8.0.300.0020.00519.65
8.0.290.0040.00416.63
8.0.280.0000.00818.46
8.0.270.0040.00417.28
8.0.260.0060.00017.33
8.0.250.0000.00816.97
8.0.240.0050.00216.96
8.0.230.0080.00016.93
8.0.220.0080.00016.91
8.0.210.0000.00716.79
8.0.200.0060.00016.98
8.0.190.0070.00016.85
8.0.180.0030.00316.94
8.0.170.0000.00816.90
8.0.160.0050.00316.81
8.0.150.0080.00016.96
8.0.140.0040.00416.91
8.0.130.0030.00313.29
8.0.120.0030.00616.84
8.0.110.0040.00416.80
8.0.100.0070.00016.91
8.0.90.0050.00216.97
8.0.80.0060.01016.89
8.0.70.0040.00416.90
8.0.60.0050.00316.94
8.0.50.0000.00716.93
8.0.30.0080.01117.17
8.0.20.0070.01217.40
8.0.10.0000.00816.87
8.0.00.0080.01316.78
7.4.330.0000.00515.08
7.4.320.0060.00016.58
7.4.300.0060.00016.57
7.4.290.0000.00716.45
7.4.280.0030.00516.47
7.4.270.0000.00716.58
7.4.260.0030.00616.59
7.4.250.0040.00416.60
7.4.240.0010.00616.58
7.4.230.0000.00716.32
7.4.220.0030.01616.52
7.4.210.0060.00916.58
7.4.200.0030.00316.52
7.4.160.0120.00416.58
7.4.150.0130.00717.40
7.4.140.0080.00917.86
7.4.130.0100.00916.46
7.4.120.0110.00616.56
7.4.110.0130.01016.50
7.4.100.0060.01316.56
7.4.90.0100.00716.60
7.4.80.0140.00419.39
7.4.70.0100.00616.33
7.4.60.0040.01216.55
7.4.50.0000.00816.43
7.4.40.0140.00516.39
7.4.30.0140.00416.38
7.4.10.0080.01215.02
7.4.00.0050.01014.88
7.3.330.0070.00013.10
7.3.320.0050.00013.24
7.3.310.0070.00316.16
7.3.300.0030.00316.24
7.3.290.0080.00816.33
7.3.280.0100.01016.33
7.3.270.0130.00317.40
7.3.260.0070.01116.51
7.3.250.0050.01216.41
7.3.240.0100.00716.37
7.3.230.0100.00616.39
7.3.210.0030.01416.59
7.3.200.0080.01419.39
7.3.190.0120.00916.31
7.3.180.0110.01216.48
7.3.170.0100.00616.41
7.3.160.0060.01016.33
7.3.130.0030.01614.77
7.3.120.0090.00914.49
7.3.110.0060.01214.83
7.3.100.0030.01214.76
7.3.90.0070.01114.77
7.3.80.0000.00814.86
7.3.70.0120.00414.89
7.3.60.0060.00314.82
7.3.50.0060.00914.77
7.3.40.0040.00814.53
7.3.30.0060.00914.65
7.3.20.0060.00616.66
7.3.10.0030.01016.60
7.3.00.0050.00516.72
7.2.330.0030.01416.82
7.2.320.0100.01316.65
7.2.310.0170.00016.45
7.2.300.0120.00616.38
7.2.290.0140.00916.69
7.2.260.0100.01014.62
7.2.250.0080.00614.83
7.2.240.0040.01115.04
7.2.230.0130.00315.25
7.2.220.0130.00315.07
7.2.210.0060.00314.63
7.2.200.0040.01114.93
7.2.190.0030.01015.01
7.2.180.0060.00915.02
7.2.170.0000.01214.98
7.2.160.0030.01215.21
7.2.150.0030.01316.89
7.2.140.0120.00616.74
7.2.130.0040.00817.13
7.2.120.0070.00716.93
7.2.110.0060.00917.14
7.2.100.0120.00017.00
7.2.90.0110.00716.81
7.2.80.0060.00316.63
7.2.70.0060.00917.11
7.2.60.0060.01017.02
7.2.50.0000.01116.97
7.2.40.0060.00816.93
7.2.30.0000.01316.68
7.2.20.0070.01116.64
7.2.10.0090.00917.11
7.2.00.0100.00518.11
7.1.330.0080.00615.50
7.1.320.0000.01015.79
7.1.310.0000.01315.35
7.1.300.0060.00915.64
7.1.290.0110.00415.83
7.1.280.0070.00715.40
7.1.270.0030.01015.80
7.1.260.0060.00915.77
7.1.250.0090.00615.60
7.1.240.0000.01315.55
7.1.230.0120.00415.79
7.1.220.0000.00815.71
7.1.210.0090.00015.75
7.1.200.0000.00815.80
7.1.190.0060.00915.64
7.1.180.0000.00815.86
7.1.170.0030.01315.70
7.1.160.0050.00815.78
7.1.150.0060.00315.80
7.1.140.0090.00615.64
7.1.130.0100.00715.54
7.1.120.0030.00715.52
7.1.110.0070.01115.95
7.1.100.0050.00616.94
7.1.90.0040.01115.80
7.1.80.0000.00915.89
7.1.70.0080.00516.43
7.1.60.0050.00816.53
7.1.50.0010.01016.47
7.1.40.0070.00615.80
7.1.30.0040.00715.50
7.1.20.0030.00915.77
7.1.10.0090.00415.64
7.1.00.0030.04319.00
7.0.330.0030.01315.40
7.0.320.0030.01015.47
7.0.310.0040.00815.40
7.0.300.0070.00715.46
7.0.290.0000.01115.32
7.0.280.0000.01315.50
7.0.270.0070.01115.38
7.0.260.0030.01015.21
7.0.250.0030.00615.34
7.0.240.0070.00715.50
7.0.230.0060.00615.23
7.0.220.0070.00715.40
7.0.210.0040.01115.50
7.0.200.0060.00516.01
7.0.190.0060.00615.31
7.0.180.0090.00615.48
7.0.170.0070.00715.43
7.0.160.0030.01015.13
7.0.150.0030.01015.32
7.0.140.0050.03418.67
7.0.130.0040.00815.45
7.0.120.0070.00715.51
7.0.110.0060.00915.25
7.0.100.0030.00615.48
7.0.90.0040.00715.50
7.0.80.0060.00315.52
7.0.70.0070.00715.54
7.0.60.0050.04717.67
7.0.50.0050.04216.55
7.0.40.0040.04516.71
7.0.30.0120.02316.75
7.0.20.0210.03816.73
7.0.10.0040.02916.83
7.0.00.0060.04916.82
5.6.400.0090.00914.38
5.6.390.0000.01514.36
5.6.380.0110.00414.32
5.6.370.0060.01014.37
5.6.360.0000.01514.33
5.6.350.0070.00414.34
5.6.340.0050.00513.86
5.6.330.0060.00714.32
5.6.320.0030.00714.19
5.6.310.0070.00714.25
5.6.300.0060.00614.27
5.6.290.0090.00614.58
5.6.280.0070.04117.68
5.6.270.0000.01714.33
5.6.260.0060.00614.19
5.6.250.0030.00914.43
5.6.240.0060.00314.29
5.6.230.0030.00614.16
5.6.220.0080.00014.42
5.6.210.0140.03717.53
5.6.200.0010.03916.14
5.6.190.0030.02517.53
5.6.180.0230.03517.32
5.6.170.0210.04017.34
5.6.160.0080.04517.58
5.6.150.0080.04516.16
5.6.140.0020.02416.28
5.6.130.0060.04616.18
5.6.120.0110.03217.76
5.6.110.0100.02217.70
5.6.100.0130.01517.65
5.6.90.0050.04917.61
5.6.80.0030.02517.43
5.6.70.0030.00914.12
5.6.60.0000.01214.21
5.6.50.0070.01014.11
5.6.40.0030.00914.31
5.6.30.0130.00314.17
5.6.20.0040.01514.18
5.6.10.0070.00714.48
5.6.00.0000.01414.28
5.5.380.0040.00814.14
5.5.370.0040.00414.53
5.5.360.0040.00414.37
5.5.350.0170.03717.31
5.5.340.0050.04115.97
5.5.330.0050.02617.20
5.5.320.0090.04117.32
5.5.310.0260.03317.30
5.5.300.0100.04016.27
5.5.290.0130.04116.13
5.5.280.0080.04017.66
5.5.270.0080.03217.50
5.5.260.0070.04517.50
5.5.250.0070.04117.54
5.5.240.0080.03617.23
5.5.230.0000.01113.96
5.5.220.0030.00614.06
5.5.210.0060.00614.08
5.5.200.0080.00614.08
5.5.190.0000.01614.23
5.5.180.0100.00714.06
5.5.170.0030.01313.86
5.5.160.0070.00314.29
5.5.150.0000.01214.25
5.5.140.0040.01014.19
5.5.130.0060.00613.94
5.5.120.0000.01114.07
5.5.110.0060.00614.49
5.5.100.0030.01014.45
5.5.90.0000.01214.44
5.5.80.0040.00414.10
5.5.70.0040.01114.07
5.5.60.0070.00414.29
5.5.50.0060.00914.09
5.5.40.0060.00314.17
5.5.30.0040.01114.16
5.5.20.0110.00313.96
5.5.10.0030.00914.00
5.5.00.0030.01014.26
5.4.450.0170.03816.44
5.4.440.0310.03516.51
5.4.430.0300.03316.30
5.4.420.0400.02616.51
5.4.410.0320.03716.39
5.4.400.0390.02516.14
5.4.390.0250.03616.27
5.4.380.0200.02516.07
5.4.370.0130.03215.96
5.4.360.0180.02515.98
5.4.350.0240.02715.95
5.4.340.0220.02016.05
5.4.330.0030.00913.39
5.4.320.0140.03116.00
5.4.310.0170.03115.92
5.4.300.0120.03416.00
5.4.290.0200.02315.97
5.4.280.0130.03016.07
5.4.270.0200.03516.07
5.4.260.0200.02516.07
5.4.250.0220.02415.93
5.4.240.0130.03215.95
5.4.230.0170.02816.00
5.4.220.0150.03916.06
5.4.210.0150.02716.06
5.4.200.0170.02314.99
5.4.190.0200.02315.99
5.4.180.0180.02815.97
5.4.170.0130.03216.10
5.4.160.0170.03216.07
5.4.150.0150.03016.04
5.4.140.0180.02814.83
5.4.130.0120.03014.82
5.4.120.0150.03014.87
5.4.110.0120.03014.84
5.4.100.0170.03314.86
5.4.90.0150.03214.84
5.4.80.0180.02714.91
5.4.70.0120.03014.87
5.4.60.0230.02014.83
5.4.50.0230.02014.91
5.4.40.0100.03114.84
5.4.30.0150.02714.89
5.4.20.0170.03014.82
5.4.10.0050.03214.80
5.4.00.0120.02814.57
5.3.290.0300.04714.71
5.3.280.0330.04714.66
5.3.270.0470.04714.67
5.3.260.0300.07014.64
5.3.250.0400.07014.80
5.3.240.0330.07714.82
5.3.230.0430.06014.59
5.3.220.0330.07014.68
5.3.210.0370.06714.68
5.3.200.0370.07314.76
5.3.190.0230.07014.69
5.3.180.0370.06014.59
5.3.170.0400.06014.68
5.3.160.0270.04714.81
5.3.150.0270.05314.76
5.3.140.0330.04714.63
5.3.130.0270.05314.60
5.3.120.0330.05014.69
5.3.110.0170.08314.73
5.3.100.0400.06314.03
5.3.90.0400.05014.07
5.3.80.0430.06714.06
5.3.70.0330.08014.01
5.3.60.0330.06714.05
5.3.50.0430.05714.13
5.3.40.0430.05314.08
5.3.30.0400.06313.97
5.3.20.0370.06313.74
5.3.10.0270.06713.79
5.3.00.0200.06313.78
5.2.170.0230.05011.37
5.2.160.0200.04311.27
5.2.150.0400.03711.20
5.2.140.0200.04311.14
5.2.130.0230.04711.14
5.2.120.0370.03711.10
5.2.110.0130.05011.09
5.2.100.0330.03311.18
5.2.90.0230.04311.32
5.2.80.0300.04011.21
5.2.70.0370.05311.20
5.2.60.0370.05711.09
5.2.50.0230.05011.14
5.2.40.0270.03711.04
5.2.30.0070.05011.08
5.2.20.0130.05011.09
5.2.10.0330.04010.91
5.2.00.0270.05010.82
5.1.60.0370.03310.02
5.1.50.0270.03310.17
5.1.40.0330.04010.11
5.1.30.0200.05710.36
5.1.20.0370.04310.39
5.1.10.0200.05010.10
5.1.00.0270.05310.21
5.0.50.0230.0338.65
5.0.40.0130.0278.40
5.0.30.0100.0438.37
5.0.20.0100.0338.39
5.0.10.0170.0278.37
5.0.00.0070.0508.37
4.4.90.0230.0338.37
4.4.80.0170.0238.37
4.4.70.0230.0238.37
4.4.60.0070.0238.37
4.4.50.0070.0278.37
4.4.40.0230.0408.37
4.4.30.0170.0278.37
4.4.20.0170.0238.37
4.4.10.0100.0338.37
4.4.00.0130.0338.37
4.3.110.0130.0238.37
4.3.100.0100.0238.37
4.3.90.0130.0208.37
4.3.80.0130.0378.37
4.3.70.0130.0238.37
4.3.60.0200.0178.37
4.3.50.0100.0238.37
4.3.40.0070.0408.37
4.3.30.0130.0208.37
4.3.20.0030.0278.37
4.3.10.0070.0208.37
4.3.00.0030.0237.57

preferences:
47.5 ms | 401 KiB | 5 Q