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'; } 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.40.0040.01118.97
8.3.30.0090.00618.93
8.3.20.0080.00020.39
8.3.10.0080.00023.55
8.3.00.0040.00419.81
8.2.170.0090.00622.96
8.2.160.0060.00919.21
8.2.150.0030.00624.18
8.2.140.0070.00024.66
8.2.130.0080.00021.18
8.2.120.0080.00026.35
8.2.110.0050.00520.99
8.2.100.0030.01018.34
8.2.90.0060.00318.34
8.2.80.0000.00817.97
8.2.70.0030.00518.05
8.2.60.0000.00917.93
8.2.50.0040.00418.10
8.2.40.0030.00620.55
8.2.30.0050.00219.35
8.2.20.0000.00818.16
8.2.10.0080.00018.04
8.2.00.0040.00418.23
8.1.270.0080.00024.66
8.1.260.0040.00426.35
8.1.250.0080.00028.09
8.1.240.0030.00622.05
8.1.230.0090.00322.73
8.1.220.0080.00017.79
8.1.210.0060.00318.77
8.1.200.0030.00617.38
8.1.190.0030.00617.13
8.1.180.0080.00018.10
8.1.170.0000.00818.70
8.1.160.0050.00218.91
8.1.150.0000.00718.87
8.1.140.0040.00719.60
8.1.130.0040.00418.96
8.1.120.0030.00517.53
8.1.110.0000.00817.30
8.1.100.0040.00417.41
8.1.90.0030.00617.54
8.1.80.0040.00417.38
8.1.70.0040.00417.34
8.1.60.0040.00417.49
8.1.50.0040.00417.59
8.1.40.0040.00417.55
8.1.30.0030.00617.63
8.1.20.0000.00817.65
8.1.10.0030.00617.57
8.1.00.0040.00417.43
8.0.300.0000.00719.65
8.0.290.0060.00316.75
8.0.280.0050.00318.38
8.0.270.0070.00017.28
8.0.260.0060.00016.83
8.0.250.0030.00316.94
8.0.240.0000.00717.01
8.0.230.0040.00416.98
8.0.220.0000.00716.93
8.0.210.0040.00416.93
8.0.200.0030.00317.01
8.0.190.0000.00916.99
8.0.180.0030.00516.96
8.0.170.0050.00216.85
8.0.160.0070.00016.91
8.0.150.0060.00316.75
8.0.140.0040.00416.89
8.0.130.0000.00713.30
8.0.120.0030.00616.92
8.0.110.0040.00416.84
8.0.100.0040.00417.03
8.0.90.0070.00016.93
8.0.80.0100.01316.89
8.0.70.0040.00416.98
8.0.60.0040.00416.98
8.0.50.0040.00416.96
8.0.30.0130.00417.25
8.0.20.0090.01117.40
8.0.10.0070.00016.92
8.0.00.0150.00316.77
7.4.330.0000.00615.55
7.4.320.0030.00316.62
7.4.300.0030.00316.46
7.4.290.0030.00716.39
7.4.280.0040.00416.63
7.4.270.0040.00416.52
7.4.260.0000.00716.65
7.4.250.0040.00416.63
7.4.240.0000.00816.45
7.4.230.0030.00316.37
7.4.220.0070.01016.46
7.4.210.0110.00316.54
7.4.200.0070.00016.44
7.4.160.0140.00716.61
7.4.150.0090.00917.40
7.4.140.0100.00717.86
7.4.130.0090.00916.71
7.4.120.0090.00916.49
7.4.110.0080.00816.61
7.4.100.0120.00816.53
7.4.90.0070.01016.50
7.4.80.0070.01119.39
7.4.70.0100.00716.37
7.4.60.0080.00816.67
7.4.50.0100.00616.44
7.4.40.0100.00716.73
7.4.30.0070.01016.45
7.4.00.0040.01115.12
7.3.330.0030.00313.39
7.3.320.0000.00613.34
7.3.310.0080.00016.34
7.3.300.0000.00716.28
7.3.290.0070.00716.32
7.3.280.0090.00716.37
7.3.270.0060.01317.40
7.3.260.0130.00516.55
7.3.250.0100.01016.41
7.3.240.0090.01316.49
7.3.230.0090.01516.49
7.3.210.0060.00916.68
7.3.200.0070.01016.38
7.3.190.0120.00616.66
7.3.180.0100.00616.58
7.3.170.0060.01316.35
7.3.160.0040.01116.38
7.3.10.0080.00616.55
7.3.00.0080.00316.54
7.2.330.0000.01816.84
7.2.320.0060.01216.82
7.2.310.0060.00916.80
7.2.300.0060.01516.87
7.2.290.0030.01516.73
7.2.130.0080.00417.00
7.2.120.0000.01317.05
7.2.110.0150.00016.86
7.2.100.0100.00316.95
7.2.90.0030.01017.08
7.2.80.0110.00717.18
7.2.70.0070.00416.98
7.2.60.0660.00915.99
7.2.50.0070.01016.80
7.2.40.0030.01016.93
7.2.30.0100.00016.95
7.2.20.0080.00317.05
7.2.10.0060.00617.00
7.2.00.0050.00718.31
7.1.250.0090.00315.63
7.1.200.0040.00415.77
7.1.100.0030.01018.25
7.1.70.0240.01015.36
7.1.60.0370.02433.38
7.1.50.1520.01033.08
7.1.40.0450.02032.68
7.1.30.0510.01632.59
7.1.20.0480.01832.81
7.1.10.0200.01814.75
7.1.00.0170.01515.04
7.0.200.0230.01014.74
7.0.190.0240.00914.85
7.0.180.0170.01714.40
7.0.170.0220.01314.43
7.0.160.0420.00914.39
7.0.150.0240.01014.68
7.0.140.0190.00914.75
7.0.130.0250.01314.72
7.0.120.0220.01614.65
7.0.110.0240.00714.64
7.0.100.0250.01114.32
7.0.90.0250.00814.52
7.0.80.0220.01214.52
7.0.70.0250.01314.63
7.0.60.0210.01414.40
7.0.50.0260.00714.80
7.0.40.0540.00814.87
7.0.30.0220.01714.71
7.0.20.0280.01214.71
7.0.10.0150.01714.68
7.0.00.0120.01614.76

preferences:
38.86 ms | 400 KiB | 5 Q