3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Model { protected $comments; public function __construct() { $this->comments = new class { public function count() { $responses = [ 1, 2, 3, "Error: could not connect to database", 5 ]; $rand = rand(0, 4); if (is_string($responses[$rand])) { throw new Exception($responses[$rand]); } return $responses[$rand]; } }; } } class Post extends Model { public function commentCount() { static $cache; return $cache?: $cache = $this->comments->count(); } } $post = new Post(); var_dump($post->commentCount()); var_dump($post->commentCount()); var_dump($post->commentCount()); var_dump($post->commentCount()); var_dump($post->commentCount());

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.80.0130.00316.55
7.4.70.0120.00816.50
7.4.60.0120.00616.29
7.4.50.0130.00716.46
7.4.40.0060.01016.43
7.4.30.0090.00716.62
7.4.20.0050.01316.59
7.4.10.0100.00916.49
7.4.00.0100.00716.71
7.3.200.0040.01216.34
7.3.190.0110.00716.61
7.3.180.0060.00916.59
7.3.170.0100.00616.38
7.3.160.0100.00516.61
7.3.150.0030.01316.38
7.3.140.0050.01016.33
7.3.130.0100.00716.39
7.3.120.0080.00816.29
7.3.110.0020.01416.40
7.3.100.0090.01316.41
7.3.90.0080.00916.23
7.3.80.0040.01216.30
7.3.70.0100.01216.28
7.3.60.0070.00916.40
7.3.50.0090.00916.49
7.3.40.0080.00816.34
7.3.30.0110.00616.39
7.3.20.0060.01116.31
7.3.10.0090.00716.40
7.3.00.0120.00716.32
7.2.320.0120.00616.73
7.2.310.0130.00616.53
7.2.300.0120.00816.59
7.2.290.0090.00716.69
7.2.280.0090.00916.55
7.2.270.0060.01116.70
7.2.260.0080.00816.69
7.2.250.0050.01316.73
7.2.240.0100.00716.50
7.2.230.0140.00516.58
7.2.220.0130.00516.70
7.2.210.0100.00816.64
7.2.200.0120.01116.67
7.2.190.0090.00916.54
7.2.180.0090.00816.55
7.2.170.0060.01116.64
7.2.160.0150.00316.69
7.2.150.0090.00916.74
7.2.140.0090.01116.66
7.2.130.0100.01016.78
7.2.120.0420.01216.77
7.2.110.0090.00916.64
7.2.100.0120.00916.76
7.2.90.0130.00716.77
7.2.80.0070.01316.64
7.2.70.0070.01116.74
7.2.60.0090.00916.72
7.2.50.0160.00516.62
7.2.40.0110.01016.70
7.2.30.0420.00616.73
7.2.20.0130.01016.77
7.2.10.0120.01016.63
7.2.00.0130.00616.73
7.1.330.0190.00315.34
7.1.320.0090.01515.36
7.1.310.0130.00915.21
7.1.300.0110.01515.24
7.1.290.0040.01815.28
7.1.280.0150.01215.16
7.1.270.0170.00715.05
7.1.260.0160.00715.09
7.1.250.0220.00615.17
7.1.240.0130.00715.07
7.1.230.0080.01315.11
7.1.220.0170.00715.01
7.1.210.0100.01014.95
7.1.200.0150.01015.26
7.1.190.0110.01115.14
7.1.180.0090.01215.31
7.1.170.0130.00815.28
7.1.160.0200.00715.59
7.1.150.0180.01115.20
7.1.140.0220.01515.33
7.1.130.0110.01515.08
7.1.120.0140.00715.34
7.1.110.0120.01215.31
7.1.100.0130.01015.18
7.1.90.0090.01315.25
7.1.80.0160.01215.34
7.1.70.0150.00915.32
7.1.60.0130.00815.46
7.1.50.0070.01315.20
7.1.40.0190.00815.25
7.1.30.0140.00815.01
7.1.20.0190.00715.09
7.1.10.0200.00314.95
7.1.00.0130.01015.34
7.0.330.0160.01215.25
7.0.320.0170.01115.39
7.0.310.0190.00615.31
7.0.300.0190.01215.25
7.0.290.0220.00715.37
7.0.280.0180.01115.05
7.0.270.0280.00415.33
7.0.260.0190.01015.13
7.0.250.0280.01615.37
7.0.240.0270.00015.34
7.0.230.0270.00315.37
7.0.220.0240.00515.25
7.0.210.0120.01615.20
7.0.200.0480.00715.31
7.0.190.0190.01315.30
7.0.180.0190.01015.24
7.0.170.0290.01015.23
7.0.160.0140.01515.31
7.0.150.0200.01015.34
7.0.140.0210.01015.27
7.0.130.0280.00315.21
7.0.120.0140.01415.20
7.0.110.0190.01115.18
7.0.100.0280.00315.32
7.0.90.0110.01915.25
7.0.80.0260.00715.18
7.0.70.0270.01515.26
7.0.60.0280.00715.14
7.0.50.0250.00415.16
7.0.40.0350.01215.14
7.0.30.0180.01115.16
7.0.20.0280.01115.42
7.0.10.0230.00715.14
7.0.00.0200.01015.25
5.6.400.0170.01715.74
5.6.390.0240.00615.78
5.6.380.0190.01115.59
5.6.370.0120.01815.50
5.6.360.0270.00515.77
5.6.350.0210.00915.79
5.6.340.0120.01615.79
5.6.330.0200.00816.02
5.6.320.0220.01115.75
5.6.310.0150.01515.83
5.6.300.0230.00815.76
5.6.290.0280.00516.05
5.6.280.0190.01315.58
5.6.270.0220.01115.55
5.6.260.0230.00615.93
5.6.250.0220.00815.84
5.6.240.0200.01015.69
5.6.230.0230.00615.81
5.6.220.0280.01515.70
5.6.210.0300.00615.66
5.6.200.0280.00015.71
5.6.190.0200.01015.96
5.6.180.0230.01115.64
5.6.170.0230.00615.66
5.6.160.0220.01115.52
5.6.150.0190.01215.63
5.6.140.0200.01015.75
5.6.130.0220.01015.75
5.6.120.0250.00615.59
5.6.110.0180.01515.68
5.6.100.0210.01615.52
5.6.90.0190.01115.86
5.6.80.0170.01015.46
5.6.70.0160.01315.54
5.6.60.0210.01115.60
5.6.50.0150.01515.45
5.6.40.0170.01015.54
5.6.30.0220.01115.69
5.6.20.0260.01315.57
5.6.10.0130.01615.56
5.6.00.0210.01115.64
5.5.380.0230.00915.77
5.5.370.0160.01615.63
5.5.360.0220.00615.93
5.5.350.0230.00615.39
5.5.340.0190.01015.50
5.5.330.0230.00515.49
5.5.320.0180.01015.65
5.5.310.0190.00915.46
5.5.300.0170.01515.67
5.5.290.0180.01215.72
5.5.280.0280.00515.61
5.5.270.0130.01615.63
5.5.260.0190.01015.63
5.5.250.0270.00415.57
5.5.240.0190.01315.57
5.5.230.0210.00915.69
5.5.220.0210.01215.43
5.5.210.0230.01015.75
5.5.200.0230.00915.57
5.5.190.0170.01315.54
5.5.180.0220.01115.36
5.5.170.0240.01415.58
5.5.160.0190.01115.52
5.5.150.0150.01215.61
5.5.140.0230.01315.66
5.5.130.0190.01015.33
5.5.120.0270.00715.60
5.5.110.0200.01015.73
5.5.100.0220.00615.67
5.5.90.0070.02115.53
5.5.80.0190.01915.69
5.5.70.0220.01315.30
5.5.60.0090.01915.69
5.5.50.0250.00715.61
5.5.40.0170.01415.28
5.5.30.0210.01215.54
5.5.20.0240.00715.56
5.5.10.0180.00915.45
5.5.00.0250.00315.57
5.4.450.0110.01112.34
5.4.440.0170.01112.33
5.4.430.0180.00612.53
5.4.420.0120.01212.50
5.4.410.0140.00712.55
5.4.400.0160.00512.21
5.4.390.0160.00512.30
5.4.380.0090.01412.25
5.4.370.0110.01112.30
5.4.360.0200.00412.56
5.4.350.0140.01012.49
5.4.340.0240.00312.56
5.4.330.0180.00712.41
5.4.320.0190.00312.48
5.4.310.0100.01312.45
5.4.300.0230.00312.21
5.4.290.0140.00712.46
5.4.280.0140.00712.48
5.4.270.0240.00412.32
5.4.260.0130.00912.39
5.4.250.0170.00812.29
5.4.240.0140.01412.46
5.4.230.0200.00412.49
5.4.220.0180.00712.44
5.4.210.0190.00912.61
5.4.200.0160.01112.40
5.4.190.0190.00612.21
5.4.180.0230.00312.41
5.4.170.0170.01112.30
5.4.160.0110.01412.54
5.4.150.0180.00412.60
5.4.140.0170.01012.72
5.4.130.0210.00312.39
5.4.120.0130.00812.41
5.4.110.0140.00712.38
5.4.100.0160.00412.36
5.4.90.0120.00812.48
5.4.80.0160.00812.32
5.4.70.0140.01112.36
5.4.60.0140.01112.48
5.4.50.0200.00612.55
5.4.40.0090.01312.45
5.4.30.0150.00812.36
5.4.20.0230.00312.28
5.4.10.0170.00712.55
5.4.00.0160.00812.33
5.3.290.0150.01112.81
5.3.280.0220.00412.80
5.3.270.0160.00612.86
5.3.260.0110.01112.78
5.3.250.0200.00612.71
5.3.240.0130.01012.78
5.3.230.0180.00412.80
5.3.220.0120.01212.79
5.3.210.0190.00312.94
5.3.200.0170.00512.66
5.3.190.0190.00512.88
5.3.180.0100.01312.96
5.3.170.0170.00712.98
5.3.160.0220.00713.02
5.3.150.0190.00612.83
5.3.140.0120.01312.91
5.3.130.0120.01212.77
5.3.120.0220.00612.78
5.3.110.0150.01212.91
5.3.100.0040.01812.91
5.3.90.0160.00612.87
5.3.80.0170.00612.71
5.3.70.0130.01212.90
5.3.60.0140.00912.79
5.3.50.0150.00612.70
5.3.40.0190.00312.87
5.3.30.0160.00912.69
5.3.20.0150.00912.76
5.3.10.0140.00712.63
5.3.00.0160.00512.48
5.2.170.0070.01111.92
5.2.160.0110.00711.86
5.2.150.0100.01311.97
5.2.140.0120.00911.72
5.2.130.0200.00211.77
5.2.120.0180.00011.73
5.2.110.0150.00412.02
5.2.100.0070.01111.79
5.2.90.0090.00911.71
5.2.80.0160.00411.83
5.2.70.0150.00411.81
5.2.60.0090.01211.61
5.2.50.0070.01411.77
5.2.40.0100.01411.69
5.2.30.0060.01211.79
5.2.20.0180.00011.81
5.2.10.0080.01211.45
5.2.00.0150.00311.38
5.1.60.0110.00510.80
5.1.50.0120.00410.70
5.1.40.0100.00710.84
5.1.30.0130.00410.96
5.1.20.0070.01011.13
5.1.10.0130.00310.81
5.1.00.0110.00710.66
5.0.50.0070.00710.28
5.0.40.0080.0069.86
5.0.30.0090.0069.89
5.0.20.0090.0069.78
5.0.10.0170.0009.72
5.0.00.0100.0059.64
4.4.90.0080.0039.64
4.4.80.0040.0089.64
4.4.70.0100.0009.64
4.4.60.0080.0009.64
4.4.50.0090.0009.64
4.4.40.0040.0059.64
4.4.30.0040.0049.64
4.4.20.0060.0039.64
4.4.10.0070.0049.64
4.4.00.0060.0029.64
4.3.110.0060.0039.64
4.3.100.0050.0059.64
4.3.90.0100.0009.64
4.3.80.0050.0059.64
4.3.70.0060.0069.64
4.3.60.0080.0049.64
4.3.50.0120.0009.64
4.3.40.0060.0039.64
4.3.30.0050.0029.64
4.3.20.0040.0049.64
4.3.10.0000.0079.64
4.3.00.0070.0009.64

preferences:
38.73 ms | 403 KiB | 5 Q