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(); echo $i, "\t", bytes_as_hex($hsh,8), $aref, $anow, 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.0170.00718.31
8.3.50.0060.01218.09
8.3.40.0100.01720.47
8.3.30.0130.00618.66
8.3.20.0110.00024.18
8.3.10.0080.00324.66
8.3.00.0130.00726.16
8.2.180.0120.01525.92
8.2.170.0110.01418.85
8.2.160.0200.00022.96
8.2.150.0140.00625.66
8.2.140.0120.00924.66
8.2.130.0090.00026.16
8.2.120.0110.00026.35
8.2.110.0040.00822.20
8.2.100.0120.00818.04
8.2.90.0030.00618.28
8.2.80.0060.00317.97
8.2.70.0000.00917.50
8.2.60.0040.00417.50
8.2.50.0000.01018.05
8.2.40.0030.00618.24
8.2.30.0090.00018.11
8.2.20.0070.00318.07
8.2.10.0030.00621.00
8.2.00.0030.00719.34
8.1.280.0160.00625.92
8.1.270.0060.00623.99
8.1.260.0100.00028.09
8.1.250.0040.00728.09
8.1.240.0090.00323.96
8.1.230.0090.00622.73
8.1.220.0030.00717.74
8.1.210.0100.00018.77
8.1.200.0000.01117.43
8.1.190.0070.00317.35
8.1.180.0110.00019.13
8.1.170.0030.00617.62
8.1.160.0050.00518.96
8.1.150.0000.00918.96
8.1.140.0030.00618.89
8.1.130.0040.00420.03
8.1.120.0070.00317.43
8.1.110.0030.00717.46
8.1.100.0120.00017.53
8.1.90.0000.00917.54
8.1.80.0080.00017.48
8.1.70.0000.01017.48
8.1.60.0030.00617.55
8.1.50.0070.00317.42
8.1.40.0060.00317.53
8.1.30.0030.00717.57
8.1.20.0050.00517.56
8.1.10.0050.00517.61
8.1.00.0030.00617.52
8.0.300.0000.00922.03
8.0.290.0070.00316.75
8.0.280.0000.00918.48
8.0.270.0030.00618.02
8.0.260.0050.00318.47
8.0.250.0040.00416.94
8.0.240.0040.00417.02
8.0.230.0030.00617.04
8.0.220.0070.00316.89
8.0.210.0030.00617.06
8.0.200.0030.00517.00
8.0.190.0030.00716.93
8.0.180.0050.00416.90
8.0.170.0110.00016.89
8.0.160.0100.00016.88
8.0.150.0030.00916.95
8.0.140.0040.00416.88
8.0.130.0040.00413.43
8.0.120.0050.00516.96
8.0.110.0060.00316.92
8.0.100.0050.00516.81
8.0.90.0090.00016.84
8.0.80.0080.01816.94
8.0.70.0040.00716.94
8.0.60.0090.00016.97
8.0.50.0090.00016.84
8.0.30.0120.01517.20
8.0.20.0160.01617.21
8.0.10.0030.00617.12
8.0.00.0190.00616.61
7.4.330.0000.00515.55
7.4.320.0030.00616.65
7.4.300.0000.00816.54
7.4.290.0030.00716.46
7.4.280.0030.00716.45
7.4.270.0040.00416.63
7.4.260.0030.00313.27
7.4.250.0030.00616.45
7.4.240.0030.00616.45
7.4.230.0030.00616.44
7.4.220.0020.00716.43
7.4.210.0050.01516.51
7.4.200.0040.00416.58
7.4.130.0140.01516.60
7.4.120.0160.02516.60
7.4.110.0090.01816.69
7.4.100.0380.00816.48
7.4.90.0250.01816.57
7.4.80.0360.01416.43
7.4.70.0220.01116.35
7.4.60.0250.01316.27
7.4.50.0240.01816.48
7.4.40.0200.01316.66
7.4.30.0240.00616.35
7.4.20.0100.02616.15
7.4.10.0110.02116.20
7.4.00.0090.01816.57
7.3.330.0040.00416.33
7.3.320.0070.00313.27
7.3.310.0030.00616.48
7.3.300.0060.00316.46
7.3.290.0080.01616.44
7.3.260.0200.01016.46
7.3.230.0070.02316.64
7.3.220.0370.01216.59
7.3.210.0380.00816.50
7.3.200.0330.02016.44
7.3.190.0310.00816.63
7.3.180.0150.01716.36
7.3.170.0130.02016.39
7.3.160.0120.02416.32
7.3.150.0230.01316.32
7.3.140.0210.01316.45
7.3.130.0120.02016.27
7.3.120.0220.01216.51
7.3.110.0310.00616.42
7.3.100.0200.01216.43
7.3.90.0160.01616.34
7.3.80.0180.01516.36
7.3.70.0150.02016.07
7.3.60.0120.02116.38
7.3.50.0080.02016.29
7.3.40.0160.01216.17
7.3.30.0150.02416.02
7.3.20.0130.01416.15
7.3.10.0260.00016.33
7.3.00.0090.01816.26
7.2.330.0270.01216.81
7.2.320.0210.01716.80
7.2.310.0160.00616.49
7.2.300.0170.00716.61
7.2.290.0120.01216.33
7.2.280.0160.00616.48
7.2.270.0040.01816.52
7.2.260.0090.01216.38
7.2.250.0110.01116.59
7.2.240.0090.00916.64
7.2.230.0120.00616.30
7.2.220.0130.01016.31
7.2.210.0090.01916.38
7.2.200.0120.01216.29
7.2.190.0130.00616.36
7.2.180.0140.00716.24
7.2.170.0100.00716.47
7.2.160.0070.01116.42
7.2.150.0130.01316.42
7.2.140.0130.00716.49
7.2.130.0110.01116.54
7.2.120.0160.00816.64
7.2.110.0130.00816.22
7.2.100.0110.01116.37
7.2.90.0100.01116.46
7.2.80.0080.01316.57
7.2.70.0100.01416.53
7.2.60.0140.00816.64
7.2.50.0100.01016.46
7.2.40.0150.01216.71
7.2.30.0270.00516.49
7.2.20.0130.01316.47
7.2.10.0160.00816.35
7.2.00.0040.01716.39

preferences:
31.88 ms | 401 KiB | 5 Q