3v4l.org

run code in 300+ PHP versions simultaneously
<?php //bk2020 cc0 // SipHash-2-4 // Aumasson and Bernstein 2012, https://131002.net/siphash/ // https://github.com/jedisct1/libsodium/tree/master/src/libsodium/crypto_shorthash // https://github.com/php/php-src/tree/master/ext/sodium/libsodium.c#L472 function bytes_as_hex(&$str, $len=null) { if( !$len ) { $len = strlen($str); } // zero-based array index for unpack, kennwhite 2005: // https://www.php.net/manual/en/function.unpack.php#45188 $arrhead = array_merge( unpack('C*', substr($str,0,$len)) ); return array_reduce( $arrhead, function($a,$b) { return ($b>15) ? $a.dechex($b) : $a.'0'.dechex($b); }, '' ); } $SIPHASH = null; if( function_exists('\sodium_crypto_shorthash') ) { $SIPHASH = 'sodium_crypto_shorthash'; } else if( function_exists('\Sodium\crypto_shorthash') ) { $SIPHASH = '\Sodium\crypto_shorthash'; } else { die('Unable to test SipHash-2-4 using sodium_crypto_shorthash'); } $SIPKEY = '1234567890abcdef'; // 16-byte key for SipHash-2-4 echo '# ', $SIPHASH, PHP_EOL; // thanks to: https://3v4l.org/EsGSU // (note: bin2hex won't print leading zero on byte values <16) for ($i = 0; $i < 256; ++$i) { $msg = bin2hex( chr(($i & 0x3F) | 0x80) ); $aref = hrtime(); $hsh = $SIPHASH( $msg, $SIPKEY ); $anow = hrtime(); $nanos = ($anow[0]===$aref[0]) ? $anow[1]-$aref[1] : -1; echo $i, "\t", bytes_as_hex($hsh,8), $nanos, PHP_EOL; }

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.0130.01318.18
8.3.50.0110.00717.75
8.3.40.0170.00020.34
8.3.30.0130.00618.66
8.3.20.0100.01024.18
8.3.10.0030.00624.66
8.3.00.0060.00326.16
8.2.180.0130.01025.92
8.2.170.0170.00018.95
8.2.160.0160.00322.96
8.2.150.0100.00025.66
8.2.140.0060.00324.66
8.2.130.0070.01126.16
8.2.120.0140.00320.84
8.2.110.0040.00722.25
8.2.100.0030.01017.91
8.2.90.0040.00418.34
8.2.80.0040.00417.97
8.2.70.0050.00517.50
8.2.60.0040.00417.75
8.2.50.0000.00918.05
8.2.40.0030.00618.19
8.2.30.0000.00918.26
8.2.20.0030.00618.21
8.2.10.0060.00321.09
8.2.00.0070.00319.34
8.1.280.0090.00925.92
8.1.270.0070.00323.99
8.1.260.0070.00326.35
8.1.250.0040.00428.09
8.1.240.0040.00723.97
8.1.230.0100.00322.77
8.1.220.0060.00317.78
8.1.210.0000.00918.77
8.1.200.0000.01117.53
8.1.190.0000.01017.23
8.1.180.0100.00019.14
8.1.170.0000.00917.62
8.1.160.0060.00318.82
8.1.150.0040.00418.85
8.1.140.0030.00618.92
8.1.130.0030.00520.17
8.1.120.0080.00317.50
8.1.110.0040.00417.53
8.1.100.0040.00717.45
8.1.90.0000.00917.54
8.1.80.0030.00617.36
8.1.70.0030.00617.37
8.1.60.0030.00617.52
8.1.50.0060.00317.53
8.1.40.0060.00317.55
8.1.30.0000.00917.70
8.1.20.0030.00617.54
8.1.10.0060.00317.61
8.1.00.0030.00617.50
8.0.300.0000.00821.99
8.0.290.0000.00916.75
8.0.280.0000.00918.47
8.0.270.0000.00918.03
8.0.260.0030.00518.52
8.0.250.0040.00417.01
8.0.240.0080.00016.95
8.0.230.0000.00816.87
8.0.220.0090.00316.84
8.0.210.0030.00616.82
8.0.200.0000.00716.87
8.0.190.0090.00016.87
8.0.180.0060.00316.96
8.0.170.0030.00716.96
8.0.160.0030.00716.87
8.0.150.0060.00316.90
8.0.140.0030.00616.86
8.0.130.0070.00013.31
8.0.120.0030.00616.85
8.0.110.0000.00916.74
8.0.100.0000.00916.93
8.0.90.0030.00516.98
8.0.80.0070.01116.80
8.0.70.0070.00316.81
8.0.60.0000.00816.88
8.0.50.0040.00416.82
8.0.30.0190.00416.90
8.0.20.0170.01317.21
8.0.10.0030.00616.90
8.0.00.0090.01016.70
7.4.330.0050.00015.55
7.4.320.0040.00416.63
7.4.300.0000.00816.60
7.4.290.0000.00916.47
7.4.280.0060.00316.54
7.4.270.0040.00416.53
7.4.260.0030.00313.27
7.4.250.0060.00316.57
7.4.240.0000.00916.53
7.4.230.0030.00516.37
7.4.220.0040.00416.58
7.4.210.0070.01316.63
7.4.200.0000.00816.72
7.4.130.0150.01216.54
7.4.120.0230.00316.41
7.4.110.0070.01716.63
7.4.100.0120.01416.21
7.4.90.0210.00616.37
7.4.80.0080.01916.40
7.4.70.0060.02216.36
7.4.60.0170.01016.51
7.4.50.0190.00916.40
7.4.40.0080.02116.46
7.4.30.0150.01216.20
7.4.20.0190.01316.24
7.4.10.0220.00616.58
7.4.00.0160.00916.72
7.3.330.0090.00016.23
7.3.320.0060.00313.25
7.3.310.0000.00816.38
7.3.300.0040.00416.40
7.3.290.0090.01116.39
7.3.260.0200.01216.43
7.3.230.0220.00716.43
7.3.220.0150.02116.30
7.3.210.0200.01316.45
7.3.200.0290.00416.45
7.3.190.0160.01016.48
7.3.180.0220.00916.33
7.3.170.0140.01816.32
7.3.160.0120.01716.60
7.3.150.0180.01516.17
7.3.140.0120.02016.21
7.3.130.0190.01116.50
7.3.120.0160.01616.23
7.3.110.0130.01416.43
7.3.100.0170.01416.47
7.3.90.0150.01516.29
7.3.80.0150.01216.50
7.3.70.0180.00916.21
7.3.60.0150.01516.23
7.3.50.0120.01516.16
7.3.40.0230.01016.23
7.3.30.0160.01516.43
7.3.20.0120.01616.16
7.3.10.0170.01816.22
7.3.00.0240.01516.19
7.2.330.0110.01416.73
7.2.320.0090.01516.67
7.2.310.0090.00916.39
7.2.300.0130.00416.70
7.2.290.0100.01016.64
7.2.280.0130.01116.50
7.2.270.0120.01216.47
7.2.260.0110.01116.34
7.2.250.0090.00916.62
7.2.240.0090.01216.41
7.2.230.0160.01016.36
7.2.220.0130.01016.31
7.2.210.0130.00716.26
7.2.200.0090.01016.34
7.2.190.0100.01016.38
7.2.180.0160.01016.15
7.2.170.0160.00916.46
7.2.160.0110.01016.33
7.2.150.0130.01016.57
7.2.140.0170.01016.05
7.2.130.0240.00016.28
7.2.120.0190.00316.40
7.2.110.0060.01216.29
7.2.100.0190.00916.18
7.2.90.0200.00716.30
7.2.80.0240.01216.66
7.2.70.0240.01416.80
7.2.60.0250.01216.68
7.2.50.0330.00316.47
7.2.40.0180.01316.61
7.2.30.0100.01416.38
7.2.20.0050.01416.38
7.2.10.0160.00916.31
7.2.00.0370.01716.29

preferences:
79.17 ms | 401 KiB | 5 Q