3v4l.org

run code in 300+ PHP versions simultaneously
<?php /** * Return the coefficient of two items based on Jaccard index * http://en.wikipedia.org/wiki/Jaccard_index * * Example: * * $tags1 = "code, php, jaccard, test, items"; * $tags2 = "test, code"; * echo getSimilarityCoefficient( $tags1, $tags2 ); // 0.28 * * $str1 = "similarity coefficient of two items"; * $str2 = "two items are cool"; * echo getSimilarityCoefficient( $str1, $str2, " " ); // 0.44 * * @param string $item1 * @param string $item2 * @param string $separator * @return float * @author Henrique Hohmann * @author Alex Rock * @version 0.2 */ function getSimilarityCoefficient( $item1, $item2, $separator = "," ) { $item1 = array_unique(array_map('trim', explode( $separator, strtolower($item1) ))); $item2 = array_unique(array_map('trim', explode( $separator, strtolower($item2) ))); $arr_intersection = array_intersect( $item2, $item1 ); $arr_union = array_unique(array_merge( $item1, $item2 )); $coefficient = count( $arr_intersection ) / count( $arr_union ); return $coefficient; } $tags1 = "code, test"; $tags2 = "test, code"; echo getSimilarityCoefficient( $tags1, $tags2 ); echo "\n"; $tags1 = "test, code"; $tags2 = "test, code"; echo getSimilarityCoefficient( $tags1, $tags2 ); echo "\n"; $str1 = "two items that are cool"; $str2 = "two items are cool"; echo getSimilarityCoefficient( $str1, $str2, " " ); echo "\n"; $str1 = "I've got two COOL items"; $str2 = "two items are cool"; echo getSimilarityCoefficient( $str1, $str2, " " );

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.4.120.0090.00820.50
8.4.110.0080.01122.67
8.4.100.0090.01120.75
8.4.90.0140.00720.57
8.4.80.0080.00817.93
8.4.70.0100.00517.95
8.4.60.0150.00818.65
8.4.50.0110.00918.60
8.4.40.0130.00619.11
8.4.30.0230.01118.09
8.4.20.0100.01017.56
8.4.10.0040.00419.32
8.3.250.0040.00319.13
8.3.240.0110.00718.87
8.3.230.0130.00716.35
8.3.220.0070.00317.34
8.3.210.0110.00816.60
8.3.200.0050.00516.67
8.3.190.0100.00917.19
8.3.180.0150.00416.54
8.3.170.0120.00618.77
8.3.160.0140.00417.33
8.3.150.0040.01518.94
8.3.140.0080.00016.35
8.3.130.0050.00316.66
8.3.120.0030.00919.03
8.3.110.0110.00020.94
8.3.100.0070.00316.61
8.3.90.0120.00318.38
8.3.80.0030.00617.97
8.3.70.0090.00618.30
8.3.60.0150.00018.30
8.3.50.0070.00724.62
8.3.40.0120.00318.63
8.3.30.0150.00018.72
8.3.20.0000.00821.77
8.3.10.0030.00522.06
8.3.00.0030.00523.48
8.2.290.0070.00520.54
8.2.280.0110.00818.19
8.2.270.0160.00318.64
8.2.260.0050.00318.52
8.2.250.0090.00016.50
8.2.240.0030.00617.05
8.2.230.0050.00322.58
8.2.220.0040.00424.06
8.2.210.0050.00326.77
8.2.200.0000.00916.63
8.2.190.0100.01016.63
8.2.180.0140.00018.29
8.2.170.0090.00622.96
8.2.160.0090.00622.08
8.2.150.0080.00024.18
8.2.140.0100.00024.66
8.2.130.0040.00426.16
8.2.120.0080.00021.08
8.2.110.0050.00520.94
8.2.100.0060.00617.72
8.2.90.0140.01123.92
8.2.80.0060.00318.16
8.2.70.0080.00017.75
8.2.60.0000.00917.75
8.2.50.0080.00018.05
8.2.40.0050.00218.09
8.2.30.0000.00819.39
8.2.20.0000.00718.00
8.2.10.0040.00419.24
8.2.00.0000.00719.26
8.1.330.0110.00721.95
8.1.320.0080.01116.29
8.1.310.0040.00418.19
8.1.300.0040.01118.56
8.1.290.0070.00318.88
8.1.280.0110.00425.92
8.1.270.0040.00422.06
8.1.260.0060.00326.35
8.1.250.0000.00728.09
8.1.240.0090.00022.54
8.1.230.0040.00820.93
8.1.220.0080.00017.74
8.1.210.0000.00919.03
8.1.200.0000.01017.35
8.1.190.0080.00017.35
8.1.180.0040.00418.10
8.1.170.0060.00317.62
8.1.160.0040.00418.86
8.1.150.0080.00418.95
8.1.140.0000.00718.84
8.1.130.0030.00320.16
8.1.120.0030.00317.54
8.1.110.0000.00817.52
8.1.100.0040.00417.50
8.1.90.0030.00317.50
8.1.80.0040.00417.53
8.1.70.0030.00317.52
8.1.60.0040.00417.63
8.1.50.0000.01017.48
8.1.40.0040.00417.55
8.1.30.0030.00517.58
8.1.20.0100.00617.66
8.1.10.0110.00617.52
8.1.00.0140.00317.43
8.0.300.0000.00819.89
8.0.290.0040.00416.75
8.0.280.0060.00318.37
8.0.270.0000.00718.10
8.0.260.0030.00318.53
8.0.250.0040.00416.98
8.0.240.0030.00317.02
8.0.230.0030.00316.88
8.0.220.0000.00716.82
8.0.210.0000.00716.92
8.0.200.0070.00016.88
8.0.190.0040.00416.89
8.0.180.0030.00616.77
8.0.170.0000.00916.91
8.0.160.0030.00316.98
8.0.150.0090.00516.74
8.0.140.0120.00216.89
8.0.130.0100.00314.99
8.0.120.0070.00515.63
8.0.110.0090.00415.72
8.0.100.0090.00515.63
8.0.90.0070.00615.71
8.0.80.0090.00516.15
8.0.70.0120.00415.68
8.0.60.0050.00915.64
8.0.50.0110.00315.70
8.0.30.0120.00215.94
8.0.20.0120.00516.35
8.0.10.0110.00415.86
8.0.00.0090.00416.16
7.4.330.0050.00015.55
7.4.320.0000.00616.55
7.4.300.0070.00016.55
7.4.290.0050.00316.53
7.4.280.0020.00516.55
7.4.270.0110.00316.56
7.4.260.0120.00416.50
7.4.250.0100.00215.50
7.4.240.0070.00415.71
7.4.230.0080.00615.39
7.4.220.0080.00415.48
7.4.210.0100.00416.07
7.4.200.0080.00615.47
7.4.190.0080.00515.46
7.4.180.0100.00415.58
7.4.160.0080.00315.56
7.4.150.0100.00215.42
7.4.140.0120.00115.40
7.4.130.0150.00515.87
7.4.120.0090.00515.69
7.4.110.0090.00615.76
7.4.100.0100.00515.83
7.4.90.0110.00515.71
7.4.80.0080.00716.40
7.4.70.0110.00415.84
7.4.60.0080.00715.94
7.4.50.0140.00515.75
7.4.40.0130.00715.81
7.4.30.0130.00615.89
7.4.20.0120.00715.89
7.4.10.0120.00715.95
7.4.00.0100.00615.99
7.3.330.0070.00516.18
7.3.320.0100.00414.25
7.3.310.0090.00515.16
7.3.300.0120.00115.28
7.3.290.0100.00415.77
7.3.280.0100.00415.56
7.3.270.0120.00015.17
7.3.260.0090.00615.52
7.3.250.0090.00515.25
7.3.240.0100.00715.90
7.3.230.0090.00515.69
7.3.220.0110.00515.40
7.3.210.0090.00615.70
7.3.200.0100.00615.75
7.3.190.0120.00415.74
7.3.180.0140.00415.69
7.3.170.0120.00715.69
7.3.160.0150.00515.82
7.3.150.0110.00815.74
7.3.140.0130.00615.81
7.3.130.0120.00715.79
7.3.120.0120.00715.73
7.3.110.0120.00715.72
7.3.100.0120.00715.73
7.3.90.0130.00715.88
7.3.80.0130.00715.72
7.3.70.0110.00815.76
7.3.60.0140.00615.85
7.3.50.0110.00815.81
7.3.40.0100.00915.85
7.3.30.0130.00515.86
7.3.20.0130.01016.71
7.3.10.0150.00616.73
7.3.00.0180.00816.75
7.2.340.0090.00715.76
7.2.330.0100.00715.81
7.2.320.0100.00815.88
7.2.310.0130.00615.79
7.2.300.0130.00715.84
7.2.290.0110.01015.93
7.2.280.0140.00715.85
7.2.270.0120.00815.97
7.2.260.0120.00715.96
7.2.250.0120.00916.01
7.2.240.0140.00615.95
7.2.230.0140.00716.02
7.2.220.0130.00515.96
7.2.210.0130.00716.01
7.2.200.0130.00715.99
7.2.190.0130.00916.06
7.2.180.0110.00716.05
7.2.170.0150.00516.09
7.2.160.0120.00916.01
7.2.150.0160.00516.70
7.2.140.0110.01016.65
7.2.130.0120.00816.70
7.2.120.0110.00916.69
7.2.110.0120.00816.69
7.2.100.0150.00716.78
7.2.90.0130.00716.69
7.2.80.0100.00816.69
7.2.70.0130.00716.72
7.2.60.0130.00616.59
7.2.50.0080.01116.66
7.2.40.0110.00816.66
7.2.30.0120.00816.61
7.2.20.0090.00816.64
7.2.10.0110.00716.70
7.2.00.0110.00816.74

preferences:
36.38 ms | 403 KiB | 5 Q