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), "\t", $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.0140.01718.18
8.3.50.0090.00918.01
8.3.40.0130.00320.52
8.3.30.0160.01318.67
8.3.20.0130.00724.18
8.3.10.0050.00524.66
8.3.00.0090.00026.16
8.2.180.0100.01325.92
8.2.170.0240.00318.96
8.2.160.0060.01222.96
8.2.150.0120.00625.66
8.2.140.0070.01024.66
8.2.130.0030.00626.16
8.2.120.0100.01019.95
8.2.110.0070.00422.25
8.2.100.0040.01317.85
8.2.90.0090.00018.28
8.2.80.0030.00617.97
8.2.70.0000.00917.75
8.2.60.0030.00617.50
8.2.50.0000.01018.05
8.2.40.0030.00618.25
8.2.30.0030.00618.18
8.2.20.0030.00618.21
8.2.10.0000.00921.02
8.2.00.0060.00319.26
8.1.280.0150.00325.92
8.1.270.0050.00523.99
8.1.260.0100.00026.35
8.1.250.0030.00728.09
8.1.240.0030.00723.92
8.1.230.0120.00322.57
8.1.220.0060.00317.78
8.1.210.0030.00618.77
8.1.200.0030.00617.53
8.1.190.0000.00917.22
8.1.180.0070.00319.13
8.1.170.0060.00317.62
8.1.160.0080.00018.86
8.1.150.0060.00319.01
8.1.140.0060.00318.89
8.1.130.0040.00420.08
8.1.120.0030.00717.50
8.1.110.0090.00017.38
8.1.100.0040.00717.45
8.1.90.0030.00617.47
8.1.80.0030.00617.37
8.1.70.0090.00017.50
8.1.60.0030.00617.54
8.1.50.0070.00317.53
8.1.40.0030.00717.53
8.1.30.0060.00317.73
8.1.20.0090.00017.74
8.1.10.0030.00617.61
8.1.00.0030.00617.39
8.0.300.0070.00421.93
8.0.290.0060.00316.75
8.0.280.0080.00018.47
8.0.270.0000.00817.96
8.0.260.0040.00418.35
8.0.250.0030.00616.98
8.0.240.0000.00916.99
8.0.230.0030.00516.96
8.0.220.0000.01016.79
8.0.210.0050.00316.90
8.0.200.0000.00816.99
8.0.190.0030.00616.98
8.0.180.0090.00016.91
8.0.170.0000.00916.92
8.0.160.0060.00316.94
8.0.150.0040.00816.75
8.0.140.0000.01116.84
8.0.130.0030.00313.29
8.0.120.0030.00616.84
8.0.110.0000.00816.79
8.0.100.0060.00316.93
8.0.90.0040.00416.83
8.0.80.0080.01216.94
8.0.70.0030.00716.79
8.0.60.0030.00616.78
8.0.50.0040.00417.04
8.0.30.0130.01017.08
8.0.20.0220.01617.13
8.0.10.0030.00617.04
8.0.00.0120.01216.74
7.4.330.0000.00515.55
7.4.320.0030.00616.63
7.4.300.0000.00716.46
7.4.290.0030.00616.64
7.4.280.0030.00616.56
7.4.270.0030.00616.61
7.4.260.0040.00413.27
7.4.250.0030.00516.61
7.4.240.0000.00916.64
7.4.230.0040.00416.61
7.4.220.0030.00516.55
7.4.210.0110.00916.55
7.4.200.0000.00816.37
7.4.130.0130.01416.54
7.4.120.0220.01916.64
7.4.110.0130.01416.61
7.4.100.0180.00916.54
7.4.90.0130.01716.39
7.4.80.0140.01016.43
7.4.70.0130.01916.26
7.4.60.0160.01616.19
7.4.50.0190.01616.33
7.4.40.0220.01316.37
7.4.30.0070.01916.33
7.4.20.0180.01216.19
7.4.10.0110.01416.64
7.4.00.0140.01016.43
7.3.330.0060.00316.29
7.3.320.0000.00813.38
7.3.310.0040.00416.48
7.3.300.0000.00816.35
7.3.290.0110.01116.38
7.3.260.0070.01716.35
7.3.230.0160.01016.68
7.3.220.0110.01416.50
7.3.210.0190.00916.47
7.3.200.0130.01316.41
7.3.190.0200.01116.50
7.3.180.0100.01616.46
7.3.170.0100.02716.22
7.3.160.0180.01216.16
7.3.150.0170.00716.38
7.3.140.0210.01416.48
7.3.130.0130.01016.33
7.3.120.0210.00316.40
7.3.110.0140.01116.40
7.3.100.0110.01916.19
7.3.90.0060.01816.52
7.3.80.0200.01216.31
7.3.70.0170.00716.19
7.3.60.0170.00816.28
7.3.50.0180.00916.11
7.3.40.0060.01916.25
7.3.30.0030.02016.34
7.3.20.0220.00616.27
7.3.10.0210.01016.29
7.3.00.0110.02216.31
7.2.330.0070.01016.43
7.2.320.0150.00416.82
7.2.310.0030.01516.55
7.2.300.0090.00916.57
7.2.290.0130.00316.53
7.2.280.0180.00316.48
7.2.270.0120.00916.26
7.2.260.0060.01116.34
7.2.250.0030.01416.73
7.2.240.0120.00916.37
7.2.230.0130.00716.51
7.2.220.0060.01216.43
7.2.210.0120.00616.40
7.2.200.0100.01316.30
7.2.190.0090.00916.39
7.2.180.0160.00316.38
7.2.170.0110.00616.44
7.2.160.0070.01016.37
7.2.150.0090.01516.57
7.2.140.0150.00916.21
7.2.130.0090.00916.57
7.2.120.0150.00416.65
7.2.110.0160.00916.34
7.2.100.0190.00316.44
7.2.90.0040.01516.49
7.2.80.0060.01216.72
7.2.70.0080.01216.75
7.2.60.0100.01016.68
7.2.50.0060.01216.63
7.2.40.0150.00916.66
7.2.30.0060.01216.36
7.2.20.0120.00616.48
7.2.10.0060.01216.23
7.2.00.0060.01216.23

preferences:
32.52 ms | 401 KiB | 5 Q