3v4l.org

run code in 300+ PHP versions simultaneously
<?php abstract class Hash { protected $algo; private $bytes; protected $data; public function __construct(string $data) { $this->bytes = strlen(hash($this->algo, '', true)); $this->data = $data; } public function getRaw() : string { return $this->data; } public function getHex() : string { return bin2hex($this->data); } public function getBase64() : string { return base64_encode($this->data); } public static function fromHex(string $data) : Hash { return new static(hex2bin($data)); } public static function fromBase64(string $data) : Hash { return new static(base64_decode($data)); } public static function getClass(string $algo) : string { $prefix = ucfirst(strtolower($algo)); $class = implode('\\', [__NAMESPACE__, "${prefix}Hash"]); return $class; } } final class Md5Hash extends Hash { protected $algo = 'md5'; } final class Sha256Hash extends Hash { protected $algo = 'sha256'; } final class Sha512Hash extends Hash { protected $algo = 'sha512'; } foreach(explode('|', 'md5|sha256|sha512') as $a){ $submitted[$a] = hash($a, 'foobar'); } foreach($submitted as $algo => $hexVal){ $hashes[] = (Hash::getClass($algo))::fromHex($hexVal); } var_dump($hashes);

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.0140.00318.56
8.3.50.0070.01116.66
8.3.40.0120.00918.76
8.3.30.0120.00318.90
8.3.20.0040.00420.16
8.3.10.0080.00021.78
8.3.00.0040.00419.81
8.2.180.0100.00718.25
8.2.170.0040.01122.96
8.2.160.0090.00919.13
8.2.150.0040.00424.18
8.2.140.0090.00024.66
8.2.130.0080.00019.30
8.2.120.0040.00426.35
8.2.110.0060.00319.45
8.2.100.0040.00717.97
8.2.90.0050.00317.97
8.2.80.0050.00319.29
8.2.70.0000.00817.63
8.2.60.0040.00417.50
8.2.50.0060.00318.05
8.2.40.0080.00018.16
8.2.30.0000.00819.32
8.2.20.0040.00418.16
8.2.10.0000.00718.25
8.2.00.0000.00718.03
8.1.280.0110.00425.92
8.1.270.0040.00423.82
8.1.260.0040.00426.35
8.1.250.0040.00428.09
8.1.240.0000.00922.18
8.1.230.0070.00420.97
8.1.220.0080.00017.76
8.1.210.0040.00418.88
8.1.200.0040.00417.13
8.1.190.0040.00417.23
8.1.180.0000.00818.10
8.1.170.0040.00417.62
8.1.160.0070.00019.04
8.1.150.0000.00718.82
8.1.140.0000.00921.35
8.1.130.0020.00518.97
8.1.120.0070.00017.50
8.1.110.0040.00417.46
8.1.100.0060.00317.48
8.1.90.0030.00617.52
8.1.80.0070.00017.37
8.1.70.0000.00717.53
8.1.60.0000.00817.60
8.1.50.0040.00417.58
8.1.40.0040.00417.41
8.1.30.0080.00017.69
8.1.20.0000.00717.69
8.1.10.0030.00617.59
8.1.00.0080.00017.49
8.0.300.0040.00419.93
8.0.290.0060.00316.59
8.0.280.0030.00318.47
8.0.270.0000.00717.22
8.0.260.0000.00616.85
8.0.250.0050.00316.95
8.0.240.0070.00016.96
8.0.230.0000.00716.93
8.0.220.0070.00016.90
8.0.210.0040.00416.82
8.0.200.0040.00416.94
8.0.190.0060.00316.88
8.0.180.0000.00716.97
8.0.170.0040.00416.84
8.0.160.0040.00416.92
8.0.150.0050.00216.92
8.0.140.0000.00816.86
8.0.130.0030.00313.32
8.0.120.0080.00016.87
8.0.110.0000.00716.79
8.0.100.0040.00416.95
8.0.90.0000.00816.81
8.0.80.0090.01216.89
8.0.70.0040.00416.72
8.0.60.0080.00016.76
8.0.50.0090.00016.98
8.0.30.0110.00617.02
8.0.20.0110.00817.42
8.0.10.0080.00017.15
8.0.00.0140.00317.02
7.4.330.0060.00015.55
7.4.320.0000.00716.54
7.4.300.0040.00416.50
7.4.290.0110.00016.63
7.4.280.0000.00816.55
7.4.270.0050.00316.62
7.4.260.0000.00716.61
7.4.250.0000.00716.49
7.4.240.0040.00416.68
7.4.230.0000.00716.32
7.4.220.0070.00016.69
7.4.210.0090.00516.48
7.4.200.0070.00016.64
7.4.160.0090.01116.43
7.4.150.0110.01117.40
7.4.140.0110.00817.86
7.4.130.0090.00916.64
7.4.120.0090.01216.60
7.4.110.0090.00916.59
7.4.100.0120.01516.40
7.4.90.0070.01016.48
7.4.80.0070.01619.39
7.4.70.0140.00316.61
7.4.60.0100.01016.70
7.4.50.0030.00716.52
7.4.40.0000.01716.62
7.4.30.0110.00516.30
7.4.10.0070.01016.35
7.4.00.0070.00915.77
7.3.330.0060.00013.39
7.3.320.0030.00313.25
7.3.310.0000.00716.38
7.3.300.0000.00716.25
7.3.290.0090.00516.38
7.3.280.0060.01116.40
7.3.270.0160.00417.40
7.3.260.0100.00716.33
7.3.250.0140.00616.61
7.3.240.0100.01116.44
7.3.230.0160.00316.62
7.3.210.0120.00416.35
7.3.200.0100.01016.58
7.3.190.0110.00716.58
7.3.180.0120.00616.30
7.3.170.0140.00316.62
7.3.160.0110.00516.57
7.3.130.0000.02116.58
7.3.120.0080.00816.53
7.3.110.0030.01316.59
7.3.100.0090.00616.65
7.3.90.0000.01416.36
7.3.80.0030.01016.42
7.3.70.0070.00716.34
7.3.60.0070.00716.45
7.3.50.0080.00616.31
7.3.40.0000.00916.31
7.3.30.0030.01016.45
7.3.20.0070.01018.16
7.3.10.0000.01018.07
7.3.00.0000.01218.21
7.2.330.0160.00316.91
7.2.320.0060.01616.83
7.2.310.0030.01316.66
7.2.300.0060.01116.43
7.2.290.0120.00916.86
7.2.260.0060.01216.68
7.2.250.0000.02116.70
7.2.240.0030.01016.72
7.2.230.0090.00616.41
7.2.220.0030.00716.50
7.2.210.0080.00416.42
7.2.200.0000.01516.65
7.2.190.0040.01116.68
7.2.180.0060.00616.53
7.2.170.0040.01116.62
7.2.160.0100.00716.51
7.2.150.0070.01118.40
7.2.140.0130.00618.43
7.2.130.0080.00818.49
7.2.120.0100.01018.37
7.2.110.0060.00618.38
7.2.100.0030.01018.39
7.2.90.0000.02118.40
7.2.80.0040.01118.47
7.2.70.0070.00718.40
7.2.60.0440.01016.79
7.2.50.0100.00718.57
7.2.40.0100.00618.52
7.2.30.0070.00718.39
7.2.20.0100.00718.29
7.2.10.0090.00618.55
7.2.00.0000.01018.95
7.1.330.0090.00417.34
7.1.320.0000.01017.30
7.1.310.0030.00617.53
7.1.300.0070.00717.34
7.1.290.0090.00317.53
7.1.280.0030.00717.46
7.1.270.0040.01117.36
7.1.260.0070.00717.38
7.1.250.0100.00717.34
7.1.240.0060.00917.27
7.1.230.0030.01017.33
7.1.220.0040.00817.29
7.1.210.0100.00617.34
7.1.200.0050.00816.48
7.1.190.0030.01017.29
7.1.180.0060.00917.22
7.1.170.0040.00817.51
7.1.160.0030.00717.16
7.1.150.0070.00717.38
7.1.140.0000.01417.33
7.1.130.0030.00817.23
7.1.120.0040.00717.19
7.1.110.0080.00617.39
7.1.100.0020.01017.83
7.1.90.0070.00717.50
7.1.80.0100.00717.21
7.1.70.0180.00616.41
7.1.60.0240.00825.28
7.1.50.0800.01125.21
7.1.40.0130.01424.89
7.1.30.0140.01324.94
7.1.20.0230.01325.00
7.1.10.0150.00916.16
7.1.00.0110.00915.98
7.0.330.0100.00716.99
7.0.320.0130.00017.05
7.0.310.0100.00316.86
7.0.300.0090.00616.96
7.0.290.0070.00717.06
7.0.280.0030.00617.04
7.0.270.0040.01116.97
7.0.260.0060.00616.88
7.0.250.0090.00017.00
7.0.240.0030.01017.12
7.0.230.0070.00417.15
7.0.220.0060.00317.00
7.0.210.0000.01617.00
7.0.200.0160.01215.99
7.0.190.0150.01015.89
7.0.180.0090.00815.90
7.0.170.0130.00815.87
7.0.160.0140.01115.61
7.0.150.0110.01115.74
7.0.140.0090.01115.79
7.0.130.0120.00815.87
7.0.120.0120.00915.88
7.0.110.0090.01215.88
7.0.100.0090.00915.68
7.0.90.0120.00815.88
7.0.80.0100.00915.77
7.0.70.0180.00515.69
7.0.60.0090.01115.71
7.0.50.0220.01015.82
7.0.40.0090.01314.70
7.0.30.0180.00514.85
7.0.20.0140.00614.79
7.0.10.0090.01114.80
7.0.00.0130.00815.00
5.6.400.0070.01015.57
5.6.390.0060.01215.49
5.6.380.0070.00715.67
5.6.370.0060.01015.54
5.6.360.0080.00415.26
5.6.350.0070.00715.70
5.6.340.0070.00715.58
5.6.330.0080.00815.43
5.6.320.0070.00715.39
5.6.310.0030.00915.96
5.6.300.0120.00615.68
5.6.290.0060.00915.81
5.6.280.0060.01015.72
5.6.270.0030.01215.75
5.6.260.0100.00315.66
5.6.250.0070.01015.59
5.6.240.0060.01015.79
5.6.230.0030.01015.42
5.6.220.0040.01115.69
5.6.210.0060.00615.43
5.6.200.0060.00915.50
5.6.190.0100.00315.44
5.6.180.0030.00715.60
5.6.170.0030.01015.44
5.6.160.0100.00315.63
5.6.150.0090.01215.69
5.6.140.0030.01615.48
5.6.130.0110.00415.78
5.6.120.0050.00515.54
5.6.110.0000.01215.75
5.6.100.0110.00415.67
5.6.90.0070.00715.50
5.6.80.0060.01015.45
5.6.70.0040.01115.46
5.6.60.0080.00815.55
5.6.50.0070.01015.50
5.6.40.0180.00015.61
5.6.30.0060.01215.60
5.6.20.0060.00315.55
5.6.10.0040.00915.44
5.6.00.0070.00715.66

preferences:
29.75 ms | 401 KiB | 5 Q