3v4l.org

run code in 300+ PHP versions simultaneously
<?php trait CastableBehavior { public static function getFromContext($obj) { $casted = new static; foreach (get_object_vars($obj) as $key => $value) { $casted->$key = $value; } return $casted; } } 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($user); } 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.40.0040.01418.61
8.3.30.0150.00319.22
8.3.20.0000.00720.15
8.3.10.0000.00921.66
8.3.00.0030.00519.13
8.2.170.0110.00422.96
8.2.160.0000.01420.29
8.2.150.0050.00324.18
8.2.140.0090.00024.66
8.2.130.0080.00026.16
8.2.120.0080.00019.25
8.2.110.0030.00619.39
8.2.100.0060.00617.63
8.2.90.0000.00919.21
8.2.80.0040.00417.97
8.2.70.0000.00917.63
8.2.60.0050.00317.80
8.2.50.0030.00618.07
8.2.40.0050.00319.95
8.2.30.0000.00718.03
8.2.20.0080.00017.61
8.2.10.0000.00718.13
8.2.00.0000.00717.70
8.1.270.0030.00620.77
8.1.260.0000.00826.35
8.1.250.0050.00328.09
8.1.240.0030.00623.86
8.1.230.0040.00717.66
8.1.220.0060.00317.74
8.1.210.0030.00518.77
8.1.200.0050.00517.48
8.1.190.0060.00317.35
8.1.180.0040.00418.10
8.1.170.0040.00418.71
8.1.160.0050.00222.04
8.1.150.0050.00218.90
8.1.140.0040.00417.42
8.1.130.0040.00417.75
8.1.120.0040.00417.42
8.1.110.0030.00617.51
8.1.100.0040.00417.49
8.1.90.0050.00217.38
8.1.80.0070.00017.38
8.1.70.0000.00717.43
8.1.60.0030.00617.62
8.1.50.0060.00317.54
8.1.40.0060.00317.54
8.1.30.0000.00817.60
8.1.20.0050.00217.64
8.1.10.0050.00517.45
8.1.00.0030.00617.45
8.0.300.0040.00418.77
8.0.290.0050.00316.75
8.0.280.0040.00418.40
8.0.270.0000.00717.18
8.0.260.0030.00317.34
8.0.250.0070.00017.01
8.0.240.0070.00016.94
8.0.230.0000.00716.85
8.0.220.0070.00016.93
8.0.210.0080.00016.78
8.0.200.0030.00316.84
8.0.190.0040.00417.01
8.0.180.0070.00016.95
8.0.170.0050.00216.86
8.0.160.0000.00816.79
8.0.150.0030.00416.87
8.0.140.0040.00416.76
8.0.130.0000.00513.38
8.0.120.0000.00816.91
8.0.110.0000.00816.75
8.0.100.0040.00416.77
8.0.90.0040.00416.89
8.0.80.0060.01016.89
8.0.70.0040.00416.88
8.0.60.0000.00816.90
8.0.50.0070.00016.91
8.0.30.0090.01117.03
8.0.20.0140.00517.40
8.0.10.0030.00516.93
8.0.00.0110.00816.91
7.4.330.0000.00515.04
7.4.320.0070.00016.53
7.4.300.0040.00416.66
7.4.290.0070.00016.59
7.4.280.0060.00316.45
7.4.270.0030.00316.47
7.4.260.0030.00316.57
7.4.250.0040.00416.59
7.4.240.0020.00516.53
7.4.230.0000.00716.55
7.4.220.0100.01016.53
7.4.210.0060.00916.41
7.4.200.0050.00216.70
7.4.160.0070.01016.27
7.4.150.0170.00417.40
7.4.140.0150.01017.86
7.4.130.0110.00716.56
7.4.120.0100.00716.47
7.4.110.0160.00616.63
7.4.100.0120.00616.38
7.4.90.0080.00816.59
7.4.80.0070.01119.39
7.4.70.0070.01316.45
7.4.60.0080.00816.48
7.4.50.0040.00416.60
7.4.40.0070.01316.45
7.4.30.0080.01316.46
7.4.10.0120.00315.09
7.4.00.0100.00814.92
7.3.330.0050.00013.18
7.3.320.0000.01313.32
7.3.310.0030.00316.31
7.3.300.0040.00416.32
7.3.290.0130.00416.30
7.3.280.0090.00816.30
7.3.270.0110.00817.40
7.3.260.0120.01216.34
7.3.250.0120.00816.41
7.3.240.0130.00316.27
7.3.230.0070.01316.39
7.3.210.0070.01016.30
7.3.200.0140.00319.39
7.3.190.0030.01416.47
7.3.180.0100.00716.47
7.3.170.0060.01216.54
7.3.160.0110.00616.61
7.3.130.0030.01614.88
7.3.120.0050.01314.82
7.3.110.0080.01114.71
7.3.100.0040.01114.96
7.3.90.0060.01014.94
7.3.80.0040.00914.71
7.3.70.0000.01114.70
7.3.60.0050.00714.80
7.3.50.0040.01014.69
7.3.40.0060.00514.70
7.3.30.0020.00914.81
7.3.20.0060.00916.79
7.3.10.0050.00816.52
7.3.00.0050.00816.67
7.2.330.0040.01316.76
7.2.320.0060.01216.77
7.2.310.0170.00816.68
7.2.300.0100.01016.46
7.2.290.0030.01516.80
7.2.260.0030.01315.35
7.2.250.0070.01214.94
7.2.240.0050.01115.10
7.2.230.0050.00714.83
7.2.220.0050.01214.96
7.2.210.0070.00814.98
7.2.200.0050.00515.22
7.2.190.0030.01015.02
7.2.180.0080.00514.97
7.2.170.0120.00414.97
7.2.160.0100.00015.02
7.2.150.0080.00816.90
7.2.140.0060.00616.68
7.2.130.0060.00316.92
7.2.120.0100.00616.96
7.2.110.0140.00416.91
7.2.100.0000.01017.02
7.2.90.0060.00916.95
7.2.80.0100.00717.00
7.2.70.0100.00716.89
7.2.60.0080.00817.05
7.2.50.0000.01216.83
7.2.40.0070.01117.12
7.2.30.0090.00616.88
7.2.20.0060.01016.89
7.2.10.0120.00417.03
7.2.00.0090.00617.83
7.1.330.0070.00815.51
7.1.320.0060.00815.63
7.1.310.0050.00715.88
7.1.300.0020.01215.77
7.1.290.0040.00815.57
7.1.280.0080.00615.75
7.1.270.0050.00615.84
7.1.260.0070.00715.83
7.1.250.0000.01315.40
7.1.240.0100.00315.54
7.1.230.0110.00415.87
7.1.220.0030.00716.02
7.1.210.0030.00915.61
7.1.200.0050.00915.61
7.1.190.0080.00815.79
7.1.180.0070.00715.92
7.1.170.0100.00315.62
7.1.160.0030.00915.70
7.1.150.0040.00415.83
7.1.140.0040.00815.63
7.1.130.0040.00815.50
7.1.120.0030.01015.63
7.1.110.0110.00415.70
7.1.100.0060.00816.99
7.1.90.0000.01415.82
7.1.80.0000.01015.98
7.1.70.0050.00716.54
7.1.60.0090.00617.68
7.1.50.0070.00616.31
7.1.40.0080.00315.74
7.1.30.0040.01115.62
7.1.20.0090.00315.73
7.1.10.0050.00515.79
7.1.00.0000.04519.05
7.0.330.0090.00615.36
7.0.320.0040.00815.52
7.0.310.0030.01315.21
7.0.300.0080.00315.34
7.0.290.0000.00815.42
7.0.280.0000.01115.23
7.0.270.0080.00415.36
7.0.260.0040.01415.43
7.0.250.0040.00815.29
7.0.240.0040.00715.42
7.0.230.0000.01115.36
7.0.220.0100.00715.40
7.0.210.0050.00815.42
7.0.200.0130.00816.04
7.0.190.0000.00815.54
7.0.180.0000.01315.27
7.0.170.0040.00415.50
7.0.160.0030.01015.49
7.0.150.0040.00715.36
7.0.140.0040.03218.66
7.0.130.0030.01015.16
7.0.120.0050.00315.54
7.0.110.0030.00715.26
7.0.100.0100.00315.39
7.0.90.0000.00815.25
7.0.80.0090.00615.38
7.0.70.0000.01115.34
7.0.60.0050.04717.67
7.0.50.0030.03316.69
7.0.40.0080.02216.85
7.0.30.0130.02816.76
7.0.20.0190.02816.65
7.0.10.0150.04516.80
7.0.00.0080.04716.85
5.6.400.0040.01114.32
5.6.390.0100.00614.46
5.6.380.0030.01014.60
5.6.370.0100.00614.39
5.6.360.0080.00414.05
5.6.350.0030.01014.38
5.6.340.0040.00714.67
5.6.330.0090.00614.76
5.6.320.0040.01114.17
5.6.310.0090.00014.34
5.6.300.0080.00814.40
5.6.290.0000.01414.55
5.6.280.0020.04217.74
5.6.270.0100.00714.69
5.6.260.0070.00714.24
5.6.250.0120.00614.57
5.6.240.0040.00414.19
5.6.230.0080.00314.62
5.6.220.0070.01014.57
5.6.210.0070.03317.52
5.6.200.0050.02516.39
5.6.190.0070.04917.61
5.6.180.0110.02917.46
5.6.170.0180.03217.46
5.6.160.0020.04417.47
5.6.150.0110.04216.22
5.6.140.0140.03516.28
5.6.130.0090.04016.34
5.6.120.0090.02417.85
5.6.110.0080.03717.67
5.6.100.0080.03117.81
5.6.90.0120.04317.72
5.6.80.0050.02017.47
5.6.70.0150.03617.42
5.6.60.0030.01314.39
5.6.50.0000.00814.25
5.6.40.0060.00614.24
5.6.30.0120.00314.27
5.6.20.0040.00814.17
5.6.10.0000.00914.63
5.6.00.0000.01114.21
5.5.380.0030.00914.32
5.5.370.0040.00414.59
5.5.360.0040.01114.03
5.5.350.0150.03517.35
5.5.340.0070.02316.28
5.5.330.0030.02517.22
5.5.320.0000.03117.37
5.5.310.0080.03017.27
5.5.300.0050.02316.03
5.5.290.0100.03016.19
5.5.280.0050.02717.62
5.5.270.0050.03017.54
5.5.260.0080.04317.55
5.5.250.0070.03417.50
5.5.240.0170.03517.39
5.5.230.0030.00814.06
5.5.220.0000.01314.30
5.5.210.0030.00714.28
5.5.200.0060.00814.18
5.5.190.0040.00414.21
5.5.180.0060.00614.22
5.5.170.0030.01014.27
5.5.160.0060.00914.04
5.5.150.0070.00714.27
5.5.140.0100.00714.41
5.5.130.0030.01014.21
5.5.120.0130.00014.26
5.5.110.0120.00314.31
5.5.100.0030.00914.18
5.5.90.0040.00414.24
5.5.80.0040.00814.17
5.5.70.0040.00413.94
5.5.60.0100.00714.13
5.5.50.0040.00814.56
5.5.40.0040.00414.35
5.5.30.0060.00313.80
5.5.20.0090.00314.13
5.5.10.0030.00814.38
5.5.00.0000.01014.20
5.4.450.0080.03215.81
5.4.440.0540.02815.86
5.4.430.0550.03415.92
5.4.420.0470.04415.92
5.4.410.0400.03515.85
5.4.400.0130.02715.55
5.4.390.0100.03215.54
5.4.380.0150.02515.50
5.4.370.0170.02415.53
5.4.360.0150.02615.51
5.4.350.0100.03015.39
5.4.340.0130.02815.52
5.4.330.0000.00712.24
5.4.320.0140.02715.44
5.4.310.0080.03315.49
5.4.300.0110.03115.52
5.4.290.0110.03015.38
5.4.280.0100.03215.43
5.4.270.0170.02515.42
5.4.260.0100.03315.50
5.4.250.0100.03415.37
5.4.240.0180.02315.51
5.4.230.0120.03015.50
5.4.220.0120.03315.51
5.4.210.0080.03515.49
5.4.200.0120.02714.41
5.4.190.0130.03015.49
5.4.180.0160.04115.38
5.4.170.0150.02915.48
5.4.160.0140.02815.47
5.4.150.0130.02815.47
5.4.140.0160.02414.35
5.4.130.0100.03014.29
5.4.120.0060.03314.24
5.4.110.0100.03314.35
5.4.100.0150.02314.25
5.4.90.0160.02814.26
5.4.80.0150.03014.22
5.4.70.0120.03314.20
5.4.60.0180.02214.33
5.4.50.0100.03014.22
5.4.40.0090.03014.34
5.4.30.0090.03014.25
5.4.20.0130.03014.25
5.4.10.0100.03214.24
5.4.00.0170.03314.00
5.3.290.0400.06714.61
5.3.280.0230.05714.51
5.3.270.0270.06714.70
5.3.260.0230.06014.50
5.3.250.0300.04314.52
5.3.240.0300.06314.64
5.3.230.0300.06714.67
5.3.220.0200.07714.48
5.3.210.0270.06014.54
5.3.200.0230.05314.56
5.3.190.0330.05014.55
5.3.180.0270.04714.61
5.3.170.0170.06014.57
5.3.160.0300.07014.47
5.3.150.0200.06014.66
5.3.140.0270.05714.56
5.3.130.0170.07014.50
5.3.120.0370.05314.60
5.3.110.0330.06714.55
5.3.100.0130.06313.96
5.3.90.0170.05714.11
5.3.80.0270.05014.00
5.3.70.0270.05014.01
5.3.60.0170.05313.89
5.3.50.0270.05713.98
5.3.40.0200.05713.91
5.3.30.0200.05713.86
5.3.20.0230.05313.60
5.3.10.0400.05013.73
5.3.00.0170.05713.57
5.2.170.0200.04311.17
5.2.160.0130.05311.07
5.2.150.0230.04311.15
5.2.140.0300.04311.11
5.2.130.0130.04711.13
5.2.120.0200.05311.23
5.2.110.0070.05011.05
5.2.100.0200.04311.14
5.2.90.0230.03711.14
5.2.80.0200.04011.15
5.2.70.0300.04311.07
5.2.60.0200.04310.96
5.2.50.0200.05011.04
5.2.40.0230.03710.94
5.2.30.0200.03711.00
5.2.20.0170.05311.09
5.2.10.0170.03710.89
5.2.00.0170.04710.81
5.1.60.0200.02710.01
5.1.50.0130.0379.98
5.1.40.0130.03310.03
5.1.30.0130.03710.38
5.1.20.0070.04310.32
5.1.10.0100.04710.05
5.1.00.0070.04310.04
5.0.50.0100.0278.57
5.0.40.0030.0338.45
5.0.30.0070.0438.33
5.0.20.0100.0278.17
5.0.10.0030.0338.28
5.0.00.0170.0378.17
4.4.90.0100.0205.89
4.4.80.0070.0235.81
4.4.70.0130.0205.90
4.4.60.0070.0235.81
4.4.50.0070.0275.88
4.4.40.0030.0405.88
4.4.30.0030.0275.86
4.4.20.0030.0235.95
4.4.10.0070.0235.91
4.4.00.0070.0335.88
4.3.110.0030.0275.89
4.3.100.0030.0275.79
4.3.90.0100.0235.82
4.3.80.0100.0305.91
4.3.70.0030.0275.77
4.3.60.0030.0235.80
4.3.50.0170.0135.91
4.3.40.0070.0435.74
4.3.30.0130.0204.59
4.3.20.0100.0274.54
4.3.10.0100.0204.54
4.3.00.0170.0176.63

preferences:
44.73 ms | 400 KiB | 5 Q