3v4l.org

run code in 300+ PHP versions simultaneously
<?php define ("FNV_prime_32", 16777619); define ("FNV_prime_64", 1099511628211); define ("FNV_prime_128", 309485009821345068724781371); define ("FNV_offset_basis_32", 2166136261); define ("FNV_offset_basis_64", 14695981039346656037); define ("FNV_offset_basis_128", 144066263297769815596495629667062367629); /* * The core of the FNV-1 hash algorithm is as follows: * * hash = offset_basis * for each octet_of_data to be hashed * hash = hash * FNV_prime * hash = hash xor octet_of_data * return hash * * Source: http://www.isthe.com/chongo/tech/comp/fnv/ */ /* * Example Java implementation: * * long fnv(byte[] buf, int offset, int len, long seed) * { * for (int i = offset; i < offset + len; i++) * { * seed += (seed << 1) + (seed << 4) + (seed << 7) + (seed << 8) + (seed << 24); * seed ^= buf[i]; * } * return seed; * } * * `Source: http://www.getopt.org/ - FNV1 Hash */ function fnvhash_fnv1($txt) { $buf = str_split($txt); $hash = FNV_offset_basis_32; foreach ($buf as $chr) { $hash += ($hash << 1) + ($hash << 4) + ($hash << 7) + ($hash << 8) + ($hash << 24); $hash = $hash ^ ord($chr); } $hash = $hash & 0x0ffffffff; return $hash; } var_dump(fnvhash_fnv1("test")); var_dump(fnvhash_fnv1("tess"));

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.1.70.0050.00217.52
8.1.60.0000.00917.59
8.1.50.0070.00017.49
8.1.40.0000.00917.67
8.1.30.0000.00817.73
8.1.20.0050.00317.64
8.1.10.0050.00217.48
8.1.00.0030.00517.54
8.0.200.0040.00416.97
8.0.190.0000.00817.05
8.0.180.0000.00816.90
8.0.170.0000.00817.00
8.0.160.0040.00417.04
8.0.150.0040.00416.95
8.0.140.0040.00416.90
8.0.130.0000.00613.35
8.0.120.0040.00416.95
8.0.110.0000.00816.82
8.0.100.0000.00717.01
8.0.90.0030.00517.04
8.0.80.0090.00617.03
8.0.70.0000.00816.86
8.0.60.0000.00816.93
8.0.50.0030.00516.84
8.0.30.0060.01217.04
8.0.20.0130.01117.40
8.0.10.0030.00517.21
8.0.00.0120.00816.86
7.4.300.0030.00316.58
7.4.290.0030.00316.59
7.4.280.0040.00416.57
7.4.270.0030.00316.67
7.4.260.0030.00616.65
7.4.250.0030.00316.67
7.4.240.0040.00316.55
7.4.230.0030.00416.50
7.4.220.0130.01316.77
7.4.210.0060.01316.75
7.4.200.0040.00416.71
7.4.160.0090.00616.55
7.4.150.0210.00617.40
7.4.140.0090.00917.86
7.4.130.0070.01116.64
7.4.120.0060.01216.66
7.4.110.0120.00316.55
7.4.100.0090.00916.57
7.4.90.0110.00516.67
7.4.80.0160.01019.39
7.4.70.0160.00016.55
7.4.60.0070.01016.59
7.4.50.0040.00416.63
7.4.40.0090.00916.39
7.4.30.0060.01016.55
7.4.00.0030.01015.24
7.3.330.0030.00313.30
7.3.320.0050.00013.39
7.3.310.0000.00716.24
7.3.300.0030.00316.38
7.3.290.0080.00616.33
7.3.280.0090.00816.40
7.3.270.0080.01617.40
7.3.260.0150.00616.61
7.3.250.0120.00516.60
7.3.240.0120.00616.35
7.3.230.0090.00916.52
7.3.210.0030.01316.43
7.3.200.0060.00919.39
7.3.190.0100.01016.49
7.3.180.0000.01716.53
7.3.170.0080.00816.44
7.3.160.0030.01416.47
7.3.120.0080.00615.10
7.3.10.0080.00416.60
7.3.00.0080.00816.52
7.2.330.0130.00316.75
7.2.320.0100.00816.75
7.2.310.0110.00616.80
7.2.300.0070.01016.80
7.2.290.0060.01716.55
7.2.130.0110.00716.76
7.2.120.0110.01116.55
7.2.110.0070.00716.72
7.2.100.0100.00716.67
7.2.90.0170.00316.52
7.2.80.0050.01016.60
7.2.70.0060.01216.91
7.2.60.0080.00616.87
7.2.50.0200.01116.80
7.2.40.0130.01016.79
7.2.30.0260.00716.66
7.2.20.0040.01316.85
7.2.10.0130.01016.63
7.2.00.0050.01018.10
7.1.250.0060.01115.63
7.1.200.0090.00915.66
7.1.100.0070.00418.31
7.1.70.0000.00717.36
7.1.60.0040.00819.70
7.1.50.0070.01816.70
7.1.00.0130.06722.60
7.0.200.0150.00016.69
7.0.140.0070.07322.19
7.0.100.0130.06020.07
7.0.90.0130.08020.11
7.0.80.0130.07319.99
7.0.70.0070.08320.05
7.0.60.0170.07020.10
7.0.50.0070.08720.36
7.0.40.0100.07320.25
7.0.30.0030.07320.29
7.0.20.0230.06720.26
7.0.10.0070.08320.23
7.0.00.0070.08320.17
5.6.250.0130.07720.78
5.6.240.0070.09020.80
5.6.230.0070.08320.64
5.6.220.0070.06720.79
5.6.210.0070.08020.63
5.6.200.0070.06321.10
5.6.190.0030.08021.27
5.6.180.0230.07021.11
5.6.170.0170.07321.13
5.6.160.0000.08321.21
5.6.150.0030.05321.06
5.6.140.0070.08021.06
5.6.130.0070.08721.21
5.6.120.0030.07021.16
5.6.110.0070.08321.17
5.6.100.0100.08021.10
5.6.90.0000.05721.20
5.6.80.0070.07020.58
5.6.70.0070.08020.49
5.6.60.0100.04320.61
5.6.50.0030.04020.51
5.6.40.0030.04720.54
5.6.30.0030.04020.60
5.6.20.0030.04020.48
5.6.10.0000.04320.56
5.6.00.0070.03720.55
5.5.380.0100.05320.51
5.5.370.0030.06020.57
5.5.360.0070.04720.44
5.5.350.0200.07320.50
5.5.340.0100.08020.96
5.5.330.0070.05020.85
5.5.320.0130.07321.09
5.5.310.0030.05721.06
5.5.300.0070.08021.05
5.5.290.0070.04320.96
5.5.280.0200.03720.93
5.5.270.0130.07720.79
5.5.260.0100.04020.82
5.5.250.0000.06020.77
5.5.240.0070.07720.19
5.5.230.0030.08020.34
5.5.220.0200.02320.18
5.5.210.0070.04020.25
5.5.200.0070.03720.41
5.5.190.0070.04020.34
5.5.180.0000.04320.32
5.5.160.0030.03720.36
5.5.150.0070.04720.23
5.5.140.0130.04020.31
5.5.130.0070.03720.22
5.5.120.0100.07320.27
5.5.110.0030.05320.36
5.5.100.0130.06020.30
5.5.90.0030.05020.26
5.5.80.0000.04020.21
5.5.70.0030.04720.25
5.5.60.0130.03020.10
5.5.50.0070.06320.06
5.5.40.0070.03320.15
5.5.30.0000.04320.25
5.5.20.0030.03720.28
5.5.10.0000.04320.07
5.5.00.0030.04320.07
5.4.450.0200.06319.51
5.4.440.0070.06319.28
5.4.430.0030.04719.37
5.4.420.0000.05019.51
5.4.410.0030.04019.32
5.4.400.0100.07319.24
5.4.390.0100.07319.13
5.4.380.0000.04019.17
5.4.370.0070.03719.08
5.4.360.0000.04018.88
5.4.350.0030.04319.23
5.4.340.0000.04019.23
5.4.320.0030.04018.85
5.4.310.0030.04019.05
5.4.300.0000.04019.09
5.4.290.0030.04018.95
5.4.280.0070.03318.85
5.4.270.0000.06718.90
5.4.260.0070.03319.03
5.4.250.0070.07319.02
5.4.240.0070.03719.04
5.4.230.0070.03319.21
5.4.220.0100.03319.20
5.4.210.0070.03719.03
5.4.200.0070.03318.87
5.4.190.0070.04018.84
5.4.180.0000.04319.13
5.4.170.0000.04019.03
5.4.160.0030.03719.14
5.4.150.0000.05019.23
5.4.140.0030.03716.55
5.4.130.0070.04016.48
5.4.120.0000.04316.48
5.4.110.0030.03716.39
5.4.100.0000.03716.34
5.4.90.0000.04016.40
5.4.80.0070.03316.49
5.4.70.0000.05016.44
5.4.60.0130.02316.37
5.4.50.0000.03716.41
5.4.40.0130.02316.32
5.4.30.0000.03716.36
5.4.20.0030.03316.48
5.4.10.0070.03316.46
5.4.00.0030.03715.79
5.3.290.0070.03714.65
5.3.280.0030.04314.70
5.3.270.0130.03714.63
5.3.260.0070.03714.75
5.3.250.0000.04014.73
5.3.240.0030.03714.72
5.3.230.0070.05714.69
5.3.220.0000.04014.71
5.3.210.0070.03314.63
5.3.200.0030.03714.50
5.3.190.0000.04014.67
5.3.180.0000.03714.50
5.3.170.0000.04314.50
5.3.160.0000.03714.55
5.3.150.0000.03714.54
5.3.140.0030.04014.63
5.3.130.0000.06014.62
5.3.120.0030.03714.69
5.3.110.0000.04014.61
5.3.100.0030.03314.15
5.3.90.0030.05314.01
5.3.80.0030.04314.08
5.3.70.0100.05714.00
5.3.60.0070.03313.98
5.3.50.0030.03713.98
5.3.40.0000.06313.86
5.3.30.0000.06013.98
5.3.20.0030.04713.70
5.3.10.0000.04013.75
5.3.00.0070.04713.71
5.2.170.0070.04012.10
5.2.160.0130.04312.10
5.2.150.0100.03712.10
5.2.140.0000.06712.10
5.2.130.0100.05312.10
5.2.120.0030.04012.10
5.2.110.0130.04712.10
5.2.100.0000.03712.10
5.2.90.0030.06312.10
5.2.80.0000.06712.10
5.2.70.0030.07712.10
5.2.60.0030.06012.10
5.2.50.0030.06712.10
5.2.40.0030.04312.10
5.2.30.0100.03312.10
5.2.20.0070.06012.10
5.2.10.0070.04712.10
5.2.00.0170.05012.10
5.1.60.0030.05012.10
5.1.50.0100.02012.10
5.1.40.0000.05712.10
5.1.30.0070.04712.10
5.1.20.0030.03012.10
5.1.10.0070.04312.10
5.1.00.0100.05012.10
5.0.50.0000.05012.10
5.0.40.0000.04012.10
5.0.30.0000.06712.10
5.0.20.0030.03312.10
5.0.10.0070.03012.10
5.0.00.0030.06012.10
4.4.90.0100.01012.10
4.4.80.0000.03712.10
4.4.70.0000.02712.10
4.4.60.0000.02312.10
4.4.50.0070.01312.10
4.4.40.0070.04712.10
4.4.30.0030.01312.10
4.4.20.0000.02012.10
4.4.10.0070.03312.10
4.4.00.0000.05312.10
4.3.110.0030.03712.10
4.3.100.0000.03712.10
4.3.90.0000.03312.10
4.3.80.0030.02312.10
4.3.70.0030.03312.10
4.3.60.0100.02712.10
4.3.50.0000.04012.10
4.3.40.0000.03712.10
4.3.30.0030.03712.10
4.3.20.0000.04012.10
4.3.10.0000.03312.10
4.3.00.0000.03712.10

preferences:
95.15 ms | 894 KiB | 17 Q