3v4l.org

run code in 300+ PHP versions simultaneously
<?php trait CastableBehavior { public static function getFromContext($obj) { foreach (get_object_vars($obj) as $key => $value) { $this->$key = $value; } } } interface UserTypes { const USER = 1; const ADMIN = 2; const MODERATOR = 3; } class User { private $id; private $name; private $type; public function __construct($id, $name, $type) { $this->id = $id; $this->name = $name; $this->type = $type; } public function getID() { return $this->id; } public function getName() { return $this->name; } public function getType() { return $this->type; } } class Admin { use CastableBehavior; private $id; private $name; private $type; } $user = new User(2, 'John', UserTypes::ADMIN); if ($user->getType() === UserTypes::ADMIN) { $admin = Admin::getFromContext($foo); } var_dump($admin);

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.0070.00717.00
8.3.50.0100.00922.05
8.3.40.0140.00718.84
8.3.30.0150.00019.25
8.3.20.0000.00820.38
8.3.10.0090.00021.69
8.3.00.0080.00019.51
8.2.180.0080.00816.88
8.2.170.0070.00722.96
8.2.160.0120.00920.38
8.2.150.0080.00024.18
8.2.140.0090.00024.66
8.2.130.0000.00726.16
8.2.120.0080.00019.48
8.2.110.0070.00320.38
8.2.100.0120.00617.73
8.2.90.0040.00419.21
8.2.80.0090.00017.97
8.2.70.0060.00617.75
8.2.60.0040.00417.80
8.2.50.0000.00818.07
8.2.40.0030.00518.28
8.2.30.0040.00418.04
8.2.20.0080.00017.68
8.2.10.0030.00517.96
8.2.00.0040.00417.76
8.1.280.0120.00325.92
8.1.270.0000.01020.55
8.1.260.0040.00426.35
8.1.250.0040.00428.09
8.1.240.0060.00323.98
8.1.230.0040.00819.01
8.1.220.0030.00617.74
8.1.210.0040.00418.77
8.1.200.0070.00317.35
8.1.190.0000.00817.22
8.1.180.0000.00818.10
8.1.170.0030.00520.32
8.1.160.0070.00021.98
8.1.150.0040.00418.92
8.1.140.0080.00017.33
8.1.130.0040.00417.85
8.1.120.0030.00517.44
8.1.110.0030.00517.50
8.1.100.0000.00717.36
8.1.90.0000.00717.43
8.1.80.0030.00317.39
8.1.70.0040.00417.54
8.1.60.0050.00517.53
8.1.50.0060.00317.54
8.1.40.0060.00317.55
8.1.30.0080.00017.63
8.1.20.0060.00317.59
8.1.10.0080.00017.49
8.1.00.0000.00717.46
8.0.300.0020.00518.77
8.0.290.0040.00416.75
8.0.280.0000.00718.52
8.0.270.0040.00317.25
8.0.260.0060.00017.25
8.0.250.0040.00417.03
8.0.240.0070.00017.07
8.0.230.0070.00016.91
8.0.220.0030.00317.00
8.0.210.0040.00416.98
8.0.200.0080.00016.95
8.0.190.0060.00317.04
8.0.180.0000.00816.90
8.0.170.0070.00016.91
8.0.160.0050.00317.05
8.0.150.0040.00416.82
8.0.140.0040.00416.93
8.0.130.0060.00013.47
8.0.120.0050.00316.98
8.0.110.0000.00817.00
8.0.100.0000.00716.76
8.0.90.0050.00216.96
8.0.80.0060.01016.96
8.0.70.0000.00816.93
8.0.60.0040.00417.02
8.0.50.0050.00216.87
8.0.30.0120.00917.25
8.0.20.0120.01117.40
8.0.10.0000.00817.01
8.0.00.0090.01216.83
7.4.330.0030.00315.03
7.4.320.0040.00416.68
7.4.300.0030.00616.61
7.4.290.0030.00316.67
7.4.280.0070.00016.62
7.4.270.0000.00716.61
7.4.260.0050.00216.58
7.4.250.0000.00716.61
7.4.240.0020.00516.55
7.4.230.0070.00016.70
7.4.220.0040.01416.69
7.4.210.0070.01016.49
7.4.200.0040.00416.72
7.4.160.0120.00316.59
7.4.150.0060.01217.40
7.4.140.0140.01217.86
7.4.130.0080.01316.54
7.4.120.0110.00516.55
7.4.110.0070.01816.58
7.4.100.0090.00916.59
7.4.90.0090.00916.81
7.4.80.0120.00619.39
7.4.70.0120.00416.57
7.4.60.0090.00916.72
7.4.50.0040.00416.49
7.4.40.0120.00916.57
7.4.30.0070.01316.56
7.4.00.0110.00015.05
7.3.330.0050.00013.25
7.3.320.0130.00013.41
7.3.310.0000.00816.48
7.3.300.0040.00416.23
7.3.290.0090.00916.42
7.3.280.0090.00816.36
7.3.270.0140.00317.40
7.3.260.0130.01316.35
7.3.250.0130.00816.39
7.3.240.0140.00316.55
7.3.230.0110.00716.39
7.3.210.0040.01316.35
7.3.200.0110.00619.39
7.3.190.0100.00616.45
7.3.180.0100.00516.44
7.3.170.0120.00616.53
7.3.160.0060.01016.47
7.3.10.0170.00916.48
7.3.00.0180.00516.18
7.2.330.0130.01016.75
7.2.320.0080.00816.84
7.2.310.0140.00516.38
7.2.300.0090.00916.81
7.2.290.0110.00716.71
7.2.130.0210.00616.82
7.2.120.0170.00916.71
7.2.110.0120.00916.60
7.2.100.0190.00016.96
7.2.90.0110.00716.88
7.2.80.0150.00416.95
7.2.70.0070.01016.82
7.2.60.0090.00916.82
7.2.50.0100.00616.58
7.2.40.0090.00916.82
7.2.30.0090.00616.97
7.2.20.0120.00816.64
7.2.10.0100.01016.61
7.2.00.0120.00718.06
7.1.250.0170.00415.49
7.1.100.0030.01318.16
7.1.70.0000.00717.03
7.1.60.0070.01819.50
7.1.50.0000.01116.93
7.1.00.0100.07022.32
7.0.200.0190.00316.43
7.0.140.0130.06322.00
7.0.60.0070.07020.04
7.0.50.0070.06317.88
7.0.40.0100.04020.24
7.0.30.0330.07720.30
7.0.20.0330.07020.22
7.0.10.0270.05320.30
7.0.00.0130.08320.20
5.6.280.0070.07021.00
5.6.210.0130.04020.46
5.6.200.0170.07318.29
5.6.190.0100.08020.41
5.6.180.0300.06720.58
5.6.170.0230.06720.50
5.6.160.0030.08720.48
5.6.150.0100.07718.21
5.6.140.0130.08018.26
5.6.130.0030.08718.14
5.6.120.0030.07020.99
5.6.110.0170.07720.99
5.6.100.0100.07721.11
5.6.90.0070.08320.93
5.6.80.0030.04020.43
5.6.70.0200.07020.37
5.5.350.0270.08720.46
5.5.340.0130.04318.01
5.5.330.0030.04020.34
5.5.320.0030.07320.25
5.5.310.0170.04720.34
5.5.300.0030.04017.98
5.5.290.0100.07718.07
5.5.280.0030.04020.67
5.5.270.0030.05020.81
5.5.260.0170.07020.74
5.5.250.0070.06320.55
5.5.240.0170.06020.29
5.4.450.0570.05719.58
5.4.440.0670.07019.59
5.4.430.0670.06019.63
5.4.420.0500.05719.69
5.4.410.0330.09019.49
5.4.400.0230.04718.83
5.4.390.0200.06018.80
5.4.380.0230.04718.76
5.4.370.0170.05018.47
5.4.360.0270.06318.57
5.4.350.0130.06718.79
5.4.340.0100.06018.79
5.4.320.0200.05318.83
5.4.310.0130.05718.62
5.4.300.0200.05318.51
5.4.290.0170.06018.59
5.4.280.0170.05718.54
5.4.270.0200.06018.55
5.4.260.0170.05018.72
5.4.250.0100.06018.60
5.4.240.0100.06318.57
5.4.230.0130.05318.65
5.4.220.0070.06318.77
5.4.210.0270.04318.72
5.4.200.0200.04316.80
5.4.190.0200.04718.77
5.4.180.0270.04718.82
5.4.170.0200.05318.52
5.4.160.0130.05718.78
5.4.150.0200.05718.60
5.4.140.0170.05716.28
5.4.130.0200.05316.25
5.4.120.0200.05716.48
5.4.110.0300.04016.26
5.4.100.0030.06316.18
5.4.90.0170.05716.46
5.4.80.0300.04716.29
5.4.70.0200.05716.21
5.4.60.0130.05316.27
5.4.50.0100.05716.18
5.4.40.0270.04716.29
5.4.30.0070.05716.23
5.4.20.0130.05316.19
5.4.10.0230.06316.27
5.4.00.0070.08015.75
5.3.290.0230.04714.64
5.3.280.0130.05314.62
5.3.270.0200.05314.60
5.3.260.0200.06314.50
5.3.250.0100.05714.52
5.3.240.0330.04014.58
5.3.230.0200.05014.67
5.3.220.0200.05714.60
5.3.210.0230.05014.51
5.3.200.0170.05014.53
5.3.190.0070.07014.62
5.3.180.0170.05714.47
5.3.170.0130.05714.56
5.3.160.0200.05014.52
5.3.150.0200.04714.66
5.3.140.0230.04314.50
5.3.130.0030.07714.62
5.3.120.0170.06314.46
5.3.110.0130.06314.64
5.3.100.0170.05314.11
5.3.90.0230.06013.98
5.3.80.0170.06713.92
5.3.70.0200.05013.92
5.3.60.0230.04314.00
5.3.50.0300.03713.91
5.3.40.0200.05013.98
5.3.30.0100.05313.89
5.3.20.0170.05013.62
5.3.10.0170.05313.64
5.3.00.0130.06013.63
5.2.170.0270.04311.20
5.2.160.0100.04311.11
5.2.150.0170.03311.17
5.2.140.0200.03711.29
5.2.130.0200.04711.07
5.2.120.0100.04011.14
5.2.110.0200.04311.14
5.2.100.0000.05011.14
5.2.90.0070.04311.02
5.2.80.0130.04311.13
5.2.70.0100.04311.08
5.2.60.0100.04311.10
5.2.50.0130.03711.16
5.2.40.0030.04710.97
5.2.30.0100.04310.94
5.2.20.0230.04311.01
5.2.10.0130.03711.01
5.2.00.0070.04710.77
5.1.60.0100.0339.98
5.1.50.0030.0409.99
5.1.40.0130.02710.01
5.1.30.0170.04310.43
5.1.20.0070.04010.40
5.1.10.0000.04310.18
5.1.00.0070.04310.13
5.0.50.0070.0308.61
5.0.40.0170.0178.44
5.0.30.0070.0438.34
5.0.20.0070.0278.21
5.0.10.0170.0308.26
5.0.00.0100.0438.18
4.4.90.0100.0175.88
4.4.80.0070.0235.86
4.4.70.0030.0235.86
4.4.60.0030.0235.86
4.4.50.0130.0175.88
4.4.40.0030.0375.82
4.4.30.0100.0205.88
4.4.20.0200.0075.97
4.4.10.0000.0275.93
4.4.00.0030.0375.96
4.3.110.0130.0175.83
4.3.100.0100.0175.81
4.3.90.0000.0305.91
4.3.80.0030.0375.81
4.3.70.0070.0205.91
4.3.60.0130.0135.89
4.3.50.0030.0275.87
4.3.40.0070.0375.88
4.3.30.0070.0234.58
4.3.20.0070.0274.54
4.3.10.0030.0304.49
4.3.00.0100.0236.79

preferences:
53.73 ms | 401 KiB | 5 Q