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->value; } public function getHex() : string { return bin2hex($this->value); } public function getBase64() : string { return base64_encode($this->value); } 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'; } 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.0100.01318.81
8.3.50.0110.00316.36
8.3.40.0110.00418.79
8.3.30.0080.00818.89
8.3.20.0050.00320.21
8.3.10.0000.00823.66
8.3.00.0000.00819.68
8.2.180.0100.01018.14
8.2.170.0070.00722.96
8.2.160.0040.01119.21
8.2.150.0040.00424.18
8.2.140.0080.00024.66
8.2.130.0040.00420.91
8.2.120.0040.00426.35
8.2.110.0000.01020.58
8.2.100.0080.00417.84
8.2.90.0040.00419.22
8.2.80.0030.00618.03
8.2.70.0090.00017.60
8.2.60.0040.00418.04
8.2.50.0050.00318.10
8.2.40.0000.00820.42
8.2.30.0040.00419.42
8.2.20.0050.00218.00
8.2.10.0080.00018.02
8.2.00.0000.00718.07
8.1.280.0120.00625.92
8.1.270.0000.00822.04
8.1.260.0040.00426.35
8.1.250.0040.00428.09
8.1.240.0030.00622.58
8.1.230.0040.00819.23
8.1.220.0000.00817.79
8.1.210.0030.00518.77
8.1.200.0030.00617.23
8.1.190.0060.00317.23
8.1.180.0000.00818.10
8.1.170.0040.00418.46
8.1.160.0040.00418.99
8.1.150.0030.00518.97
8.1.140.0040.00419.65
8.1.130.0030.00319.02
8.1.120.0000.00817.36
8.1.110.0000.00817.32
8.1.100.0050.00317.49
8.1.90.0060.00317.47
8.1.80.0070.00017.50
8.1.70.0070.00017.49
8.1.60.0030.00617.63
8.1.50.0000.00817.50
8.1.40.0030.00517.48
8.1.30.0080.00017.59
8.1.20.0040.00417.61
8.1.10.0000.00817.61
8.1.00.0030.00617.55
8.0.300.0000.00818.77
8.0.290.0060.00316.88
8.0.280.0030.00318.54
8.0.270.0030.00317.15
8.0.260.0000.00816.78
8.0.250.0000.00617.01
8.0.240.0080.00017.11
8.0.230.0050.00317.05
8.0.220.0030.00316.89
8.0.210.0030.00316.87
8.0.200.0060.00016.91
8.0.190.0040.00416.93
8.0.180.0070.00017.02
8.0.170.0050.00216.93
8.0.160.0050.00216.95
8.0.150.0040.00417.02
8.0.140.0040.00416.93
8.0.130.0000.00813.36
8.0.120.0030.00616.96
8.0.110.0000.00716.98
8.0.100.0030.00516.85
8.0.90.0000.00717.00
8.0.80.0090.00917.02
8.0.70.0020.00516.85
8.0.60.0080.00016.80
8.0.50.0040.00416.86
8.0.30.0070.01017.04
8.0.20.0110.01017.43
8.0.10.0030.00516.88
8.0.00.0210.00316.82
7.4.330.0050.00015.55
7.4.320.0030.00316.63
7.4.300.0060.00016.45
7.4.290.0070.00316.48
7.4.280.0000.00816.52
7.4.270.0030.00316.60
7.4.260.0040.00416.59
7.4.250.0040.00416.53
7.4.240.0000.00816.46
7.4.230.0000.00716.63
7.4.220.0120.00616.59
7.4.210.0090.00616.49
7.4.200.0000.00716.72
7.4.160.0090.00816.56
7.4.150.0060.01217.40
7.4.140.0090.00917.86
7.4.130.0090.00916.59
7.4.120.0100.00816.51
7.4.110.0080.00816.52
7.4.100.0090.01516.64
7.4.90.0110.00716.67
7.4.80.0150.00819.39
7.4.70.0050.01116.46
7.4.60.0130.00316.57
7.4.50.0050.00916.63
7.4.40.0090.00616.52
7.4.30.0100.01216.52
7.4.00.0070.01014.86
7.3.330.0000.00613.24
7.3.320.0000.00513.45
7.3.310.0030.00316.27
7.3.300.0030.00316.29
7.3.290.0090.00416.48
7.3.280.0080.00916.48
7.3.270.0130.00917.40
7.3.260.0120.00516.54
7.3.250.0150.00816.38
7.3.240.0110.00616.68
7.3.230.0090.00916.66
7.3.210.0080.00816.59
7.3.200.0100.00716.30
7.3.190.0060.01516.48
7.3.180.0060.01116.42
7.3.170.0110.00616.52
7.3.160.0060.00916.50
7.3.120.0070.00714.73
7.3.110.0040.01114.91
7.3.100.0090.00614.91
7.3.90.0070.01114.72
7.3.80.0100.00315.15
7.3.70.0000.01014.65
7.3.60.0000.01014.87
7.3.50.0000.00914.93
7.3.40.0100.00615.00
7.3.30.0030.01014.79
7.3.20.0120.00416.75
7.3.10.0050.00516.74
7.3.00.0030.00816.64
7.2.330.0070.01116.58
7.2.320.0000.01716.56
7.2.310.0030.01316.57
7.2.300.0030.01316.56
7.2.290.0090.01216.72
7.2.250.0100.01015.32
7.2.240.0120.00915.14
7.2.230.0030.01315.11
7.2.220.0070.01114.83
7.2.210.0100.00315.19
7.2.200.0000.01415.04
7.2.190.0040.01115.21
7.2.180.0100.00314.88
7.2.170.0040.00715.04
7.2.90.0090.00915.02
7.2.80.1980.00614.76
7.2.70.0120.00615.31
7.2.60.0120.00615.04
7.2.50.1740.00715.09
7.2.40.1460.01315.03
7.2.30.1290.00715.05
7.2.20.0180.00315.17
7.2.10.0250.01215.23
7.2.00.0120.00914.96
7.1.330.0090.00616.00
7.1.320.0040.00415.69
7.1.310.0040.00415.43
7.1.300.0000.01415.68
7.1.290.0040.00715.99
7.1.280.0040.00715.67
7.1.270.0080.00815.77
7.1.260.0040.00415.90
7.1.210.0580.00614.11
7.1.200.0400.01213.88
7.1.190.0740.00314.15
7.1.180.0030.01613.88
7.1.170.0070.00714.12
7.1.160.1940.00914.01
7.1.150.2130.00714.16
7.1.140.0850.00313.72
7.1.130.0100.00614.00
7.1.120.3580.01013.92
7.1.110.2210.00613.82
7.1.100.0480.01014.01
7.1.90.0530.01213.71
7.1.80.0150.00014.06
7.1.70.0540.00413.81
7.1.60.0280.00632.10
7.1.50.0320.00331.95
7.1.40.0330.01231.93
7.1.30.0300.01531.90
7.1.20.1660.02631.66
7.1.10.1630.01014.01
7.1.00.1240.00613.98
7.0.310.0040.00813.70
7.0.300.0070.00713.55
7.0.290.2070.00013.56
7.0.280.0810.00713.61
7.0.270.0610.01013.64
7.0.260.2030.01113.41
7.0.250.1570.00313.62
7.0.240.0190.00413.75
7.0.230.0210.00713.53
7.0.220.0820.00713.39
7.0.210.1030.00313.68
7.0.200.0650.00713.55
7.0.190.0940.00413.70
7.0.180.0730.01013.61
7.0.170.0100.01413.43
7.0.160.0750.00713.51
7.0.150.0840.01313.69
7.0.140.1340.01313.71
7.0.130.0760.00713.52
7.0.120.0860.01013.59
7.0.110.0710.01313.66
7.0.100.1030.00713.49
7.0.90.0170.00913.79
7.0.80.0870.00413.40
7.0.70.1180.00713.64
7.0.60.0780.01613.73
7.0.50.0930.01013.69
7.0.40.1190.00413.85
7.0.30.0690.00913.82
7.0.20.0920.00613.75
7.0.10.0170.00713.60
7.0.00.0180.00513.54

preferences:
40.07 ms | 400 KiB | 5 Q