3v4l.org

run code in 300+ PHP versions simultaneously
<?php function similarity($w1,$w2) { //return cosine similarity of w1 and w2 using formula in the //definition here: http://en.wikipedia.org/wiki/Cosine_similarity //get numerator: $numerator = 0; for($i = 0, $l = count($w1); $i < $l; $i++) $numerator += $w1[$i]*$w2[$i]; //get abs(w1) and abs(w2) $abs_w1 = 0; $abs_w2 = 0; for($i = 0, $l = count($w1); $i < $l; $i++) { $abs_w1 += $w1*$w1; $abs_w2 += $w2*$w2; } $abs_w1 = sqrt($abs_w1); $abs_w2 = sqrt($abs_w2); //make denominator: $denominator = $abs_w1*$abs_w2; return $numerator/$denominator; } similarity([1,2,3,4,5,6,7,8,9],[1,2,3,4,5,6,7,8,88]);

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.0070.01116.50
8.3.50.0150.00922.93
8.3.40.0140.00018.96
8.3.30.0030.01019.09
8.3.20.0040.00420.38
8.3.10.0040.00423.66
8.3.00.0000.00819.63
8.2.180.0040.01118.29
8.2.170.0140.00022.96
8.2.160.0110.00320.45
8.2.150.0000.00824.18
8.2.140.0040.00424.66
8.2.130.0050.00326.16
8.2.120.0080.00021.02
8.2.110.0080.01520.25
8.2.100.0120.00017.97
8.2.90.0060.00318.28
8.2.80.0060.00317.97
8.2.70.0000.00917.75
8.2.60.0040.00418.04
8.2.50.0060.00618.07
8.2.40.0030.00618.16
8.2.30.0040.00418.20
8.2.20.0030.00517.81
8.2.10.0000.00718.11
8.2.00.0000.00817.87
8.1.280.0140.00025.92
8.1.270.0050.00324.01
8.1.260.0040.00426.35
8.1.250.0070.00028.09
8.1.240.0060.00322.18
8.1.230.0070.00420.84
8.1.220.0080.00017.74
8.1.210.0050.00318.89
8.1.200.0030.00617.38
8.1.190.0000.00817.23
8.1.180.0000.00818.10
8.1.170.0040.00418.59
8.1.160.0000.00822.09
8.1.150.0040.00418.81
8.1.140.0000.00817.43
8.1.130.0030.00317.86
8.1.120.0070.00017.42
8.1.110.0000.00717.45
8.1.100.0000.00717.46
8.1.90.0030.00317.48
8.1.80.0040.00417.47
8.1.70.0070.00017.37
8.1.60.0090.00017.61
8.1.50.0000.00817.45
8.1.40.0020.00517.50
8.1.30.0040.00417.69
8.1.20.0040.00417.64
8.1.10.0000.00717.49
8.1.00.0000.00817.58
8.0.300.0040.00420.08
8.0.290.0040.00416.75
8.0.280.0070.00018.46
8.0.270.0070.00017.19
8.0.260.0030.00317.28
8.0.250.0000.00717.07
8.0.240.0030.00316.95
8.0.230.0000.00617.01
8.0.220.0000.00616.86
8.0.210.0030.00316.84
8.0.200.0040.00416.90
8.0.190.0060.00316.99
8.0.180.0030.00616.84
8.0.170.0040.00416.92
8.0.160.0050.00216.82
8.0.150.0070.00016.84
8.0.140.0000.00716.89
8.0.130.0060.00313.38
8.0.120.0080.00016.94
8.0.110.0070.00016.97
8.0.100.0030.00517.08
8.0.90.0040.00416.89
8.0.80.0090.01416.92
8.0.70.0070.00016.88
8.0.60.0040.00416.98
8.0.50.0000.00716.85
8.0.30.0090.01017.20
8.0.20.0140.00917.41
8.0.10.0030.00516.95
8.0.00.0100.00816.74
7.4.330.0020.00215.07
7.4.320.0040.00416.61
7.4.300.0000.00716.61
7.4.290.0000.00716.54
7.4.280.0040.00416.64
7.4.270.0000.00716.52
7.4.260.0050.00316.61
7.4.250.0040.00416.50
7.4.240.0020.00516.48
7.4.230.0030.00316.63
7.4.220.0060.01616.63
7.4.210.0070.01416.73
7.4.200.0050.00216.69
7.4.160.0060.00916.45
7.4.150.0120.00617.40
7.4.140.0110.00717.86
7.4.130.0090.01016.56
7.4.120.0060.01316.49
7.4.110.0100.00716.71
7.4.100.0070.01116.77
7.4.90.0130.00616.55
7.4.80.0140.00619.39
7.4.70.0090.00916.52
7.4.60.0060.01016.57
7.4.50.0050.00316.46
7.4.40.0000.01716.64
7.4.30.0110.00416.32
7.4.00.0030.01515.21
7.3.330.0030.00313.20
7.3.320.0000.00513.18
7.3.310.0000.00616.42
7.3.300.0080.00016.29
7.3.290.0070.00716.36
7.3.280.0090.00816.39
7.3.270.0070.01017.40
7.3.260.0110.01116.42
7.3.250.0050.01116.60
7.3.240.0130.00316.44
7.3.230.0140.00416.44
7.3.210.0100.00716.45
7.3.200.0090.01119.39
7.3.190.0060.01016.41
7.3.180.0080.00816.48
7.3.170.0100.00616.43
7.3.160.0120.00416.48
7.2.330.0100.00716.70
7.2.320.0160.00816.80
7.2.310.0120.00416.79
7.2.300.0070.01016.71
7.2.290.0200.02216.41
7.2.110.0070.00716.62
7.2.100.0030.00916.46
7.2.90.0070.00716.45
7.2.80.0090.00516.73
7.2.70.0050.00517.04
7.2.60.0090.00516.96
7.2.50.0000.00917.04
7.2.40.0090.00316.98
7.2.30.0060.00616.85
7.2.20.0060.00316.70
7.2.10.0080.00416.78
7.2.00.0060.00418.13
7.1.230.0090.00315.85
7.1.220.0030.01015.98
7.1.210.0030.00915.95
7.1.200.0050.00615.76
7.1.190.0030.01315.76
7.1.180.0040.00815.81
7.1.170.0030.00315.69
7.1.160.0070.00715.61
7.1.150.0040.00415.93
7.1.140.0000.01015.89
7.1.130.0090.00015.63
7.1.120.0070.00715.91
7.1.110.0000.00715.70
7.1.100.0090.00216.75
7.1.90.0000.01315.73
7.1.80.0030.00715.91
7.1.70.0020.00516.50
7.1.60.0050.01517.67
7.1.50.0070.01416.51
7.1.40.0070.00715.91
7.1.30.0130.00315.93
7.1.20.0030.00715.94
7.1.10.0030.01015.83
7.1.00.0040.04019.10
7.0.310.0030.00615.23
7.0.300.0000.01115.58
7.0.290.0070.00315.44
7.0.280.0030.00315.43
7.0.270.0030.01015.57
7.0.260.0000.01315.41
7.0.250.0110.00015.19
7.0.240.0040.00815.28
7.0.230.0040.00815.53
7.0.220.0030.01015.36
7.0.210.0070.00815.47
7.0.200.0040.00416.03
7.0.190.0000.00815.30
7.0.180.0030.00615.24
7.0.170.0030.00915.25
7.0.160.0000.01115.52
7.0.150.0030.00615.33
7.0.140.0060.03818.75
7.0.130.0040.00715.53
7.0.120.0090.00315.55
7.0.110.0110.00015.54
7.0.100.0060.00315.27
7.0.90.0100.00315.18
7.0.80.0030.00315.33
7.0.70.0060.00615.48
7.0.60.0030.04517.69
7.0.50.0070.03016.69
7.0.40.0070.02316.89
7.0.30.0180.02916.72
7.0.20.0200.04016.83
7.0.10.0130.03716.86
7.0.00.0050.04516.82
5.6.380.0030.01014.69
5.6.370.0130.00014.30
5.6.360.0060.00314.62
5.6.350.0110.00314.28
5.6.340.0030.01014.08
5.6.330.0070.00414.30
5.6.320.0040.00414.42
5.6.310.0040.00814.24
5.6.300.0040.00414.40
5.6.290.0060.00614.19
5.6.280.0080.03317.62
5.6.270.0030.00814.42
5.6.260.0040.00714.46
5.6.250.0090.00614.29
5.6.240.0070.00714.42
5.6.230.0090.00314.24
5.6.220.0090.00314.43
5.6.210.0030.04717.48
5.6.200.0070.02016.29
5.6.190.0060.03117.43
5.6.180.0100.03617.50
5.6.170.0120.02717.40
5.6.160.0090.02017.47
5.6.150.0050.04816.27
5.6.140.0020.02916.37
5.6.130.0050.02416.26
5.6.120.0020.03717.71
5.6.110.0030.03017.71
5.6.100.0030.02317.72
5.6.90.0080.04317.70
5.6.80.0070.04117.50
5.6.70.0030.01014.50
5.6.60.0060.00614.28
5.6.50.0030.01014.07
5.6.40.0000.00914.14
5.6.30.0030.00314.67
5.6.20.0030.00914.46
5.6.10.0040.00414.59
5.6.00.0060.00314.25
5.5.380.0030.00611.03
5.5.370.0060.00611.46
5.5.360.0060.00311.25
5.5.350.0150.03615.98
5.5.340.0040.04614.54
5.5.330.0030.02215.71
5.5.320.0110.02615.86
5.5.310.0080.02715.91
5.5.300.0020.02314.46
5.5.290.0050.04414.67
5.5.280.0050.02915.91
5.5.270.0070.03715.97
5.5.260.0070.04515.95
5.5.250.0080.03215.98
5.5.240.0070.03515.69
5.5.230.0070.00311.12
5.5.220.0030.00711.21
5.5.210.0030.00311.28
5.5.200.0000.01211.38
5.5.190.0000.00811.13
5.5.180.0030.00611.16
5.5.170.0000.01114.18
5.5.160.0060.00311.24
5.5.150.0070.00311.12
5.5.140.0080.00411.42
5.5.130.0000.00911.45
5.5.120.0080.00311.06
5.5.110.0060.00010.93
5.5.100.0000.01111.01
5.5.90.0050.00011.17
5.5.80.0030.00911.21
5.5.70.0060.00611.04
5.5.60.0030.00710.80
5.5.50.0060.00311.32
5.5.40.0000.00611.14
5.5.30.0070.00311.35
5.5.20.0050.00011.36
5.5.10.0030.00611.38
5.5.00.0040.00711.28
5.4.450.0100.04215.26
5.4.440.0380.03315.48
5.4.430.0460.03115.39
5.4.420.0310.03015.30
5.4.410.0160.03015.10
5.4.400.3180.02914.85
5.4.390.0150.03414.85
5.4.380.0050.03014.92
5.4.370.0100.02514.74
5.4.360.0050.02914.68
5.4.350.0070.02411.58
5.4.340.0090.02011.44
5.4.330.0080.00011.14
5.4.320.0030.02311.77
5.4.310.0020.02611.65
5.4.300.0060.01911.85
5.4.290.0040.02411.96
5.4.280.0020.02211.82
5.4.270.0040.02111.73
5.4.260.0030.02411.71
5.4.250.0030.02311.71
5.4.240.0050.02811.82
5.4.230.0080.02011.86
5.4.220.0050.01911.76
5.4.210.0050.02511.64
5.4.200.0060.02611.86
5.4.190.0070.01911.69
5.4.180.0040.02511.75
5.4.170.0040.02911.77
5.4.160.0090.02511.53
5.4.150.0040.02511.73
5.4.140.0070.02111.62
5.4.130.0060.02211.64
5.4.120.0040.02411.52
5.4.110.0050.02111.57
5.4.100.0060.01811.39
5.4.90.0050.02211.50
5.4.80.0040.02211.62
5.4.70.0050.01911.60
5.4.60.0050.02211.56
5.4.50.0080.01711.59
5.4.40.0070.01611.44
5.4.30.0040.02111.55
5.4.20.0050.02211.55
5.4.10.0050.02111.55
5.4.00.0030.02211.24
5.3.290.0050.02111.52
5.3.280.0020.02411.32
5.3.270.0040.02211.51
5.3.260.0070.02311.51
5.3.250.0020.02311.49
5.3.240.0050.02111.45
5.3.230.0060.02211.48
5.3.220.0070.01911.46
5.3.210.0080.01811.40
5.3.200.0020.02411.47
5.3.190.0050.02011.52
5.3.180.0040.02311.53
5.3.170.0060.02211.43
5.3.160.0040.02211.59
5.3.150.0080.01811.54
5.3.140.0070.01811.43
5.3.130.0050.02211.54
5.3.120.0060.02711.51
5.3.110.0060.02211.42
5.3.100.0040.02111.18
5.3.90.0080.01811.16
5.3.80.0020.02211.20
5.3.70.0070.01911.13
5.3.60.0020.02311.19
5.3.50.0030.02311.17
5.3.40.0050.02211.21
5.3.30.0030.02211.15
5.3.20.0040.02110.99
5.3.10.0050.02110.90
5.3.00.0050.02010.78
5.2.170.0040.0169.15
5.2.160.0060.0199.18
5.2.150.0020.0189.23
5.2.140.0020.0179.17
5.2.130.0060.0159.10
5.2.120.0020.0169.23
5.2.110.0020.0189.22
5.2.100.0030.0179.18
5.2.90.0040.0189.25
5.2.80.0020.0209.20
5.2.70.0050.0209.18
5.2.60.0030.0189.16
5.2.50.0020.0199.26
5.2.40.0040.0149.18
5.2.30.0040.0159.02
5.2.20.0040.0169.04
5.2.10.0070.0148.96
5.2.00.0070.0178.74
5.1.60.0050.0138.21
5.1.50.0040.0138.24
5.1.40.0020.0168.28
5.1.30.0050.0138.46
5.1.20.0050.0138.49
5.1.10.0040.0138.24
5.1.00.0020.0168.20
5.0.50.0040.0117.41
5.0.40.0040.0107.34
5.0.30.0050.0187.24
5.0.20.0020.0157.22
5.0.10.0050.0107.21
5.0.00.0020.0237.21
4.4.90.0050.0106.46
4.4.80.0050.0076.46
4.4.70.0030.0106.45
4.4.60.0040.0086.46
4.4.50.0050.0076.46
4.4.40.0020.0176.43
4.4.30.0050.0096.46
4.4.20.0040.0086.50
4.4.10.0030.0096.50
4.4.00.0040.0146.45
4.3.110.0020.0096.41
4.3.100.0010.0116.41
4.3.90.0030.0076.39
4.3.80.0020.0156.37
4.3.70.0020.0106.39
4.3.60.0020.0106.39
4.3.50.0050.0076.39
4.3.40.0030.0146.34
4.3.30.0010.0105.73
4.3.20.0020.0115.73
4.3.10.0020.0105.70
4.3.00.0030.0157.64

preferences:
47.19 ms | 400 KiB | 5 Q