3v4l.org

run code in 300+ PHP versions simultaneously
<?php class GreatestCommonDivisor { /** * Get the divisor of a given number. * * @param int $num * The number. * * @return int[] * The divisors of the number. */ private function factors(int $num): array { return array_filter( range(1, $num), function (int $i) use ($num) { return 0 === $num % $i; } ); } /** * Get the greatest common divisor. * * @param int ...$x * The numbers. * * @return int * The greatest common divisor. */ public function gcd(...$x): int { $x = array_map([$this, 'factors'], $x); $intersect = array_intersect(...$x); return end($intersect); } } trait gcdTrait { /** * Get the greatest common divisor. * * @param int ...$x * The first number. * * @return int * The greatest common divisor. */ function gcd(...$x): int { return (new GreatestCommonDivisor())->gcd(...$x); } } class customClass { use gcdTrait; } $foo = new customClass(); echo $foo->gcd(10, 20, 45);

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.0090.00618.18
8.3.50.0030.01218.04
8.3.40.0070.00718.53
8.3.30.0060.00918.80
8.3.20.0040.00419.33
8.3.10.0030.00623.54
8.3.00.0040.00420.83
8.2.180.0060.01225.92
8.2.170.0040.01118.94
8.2.160.0120.00322.96
8.2.150.0040.00425.66
8.2.140.0050.00324.66
8.2.130.0040.00426.16
8.2.120.0060.00618.75
8.2.110.0060.00319.38
8.2.100.0040.00820.59
8.2.90.0060.00317.78
8.2.80.0040.00419.21
8.2.70.0040.00418.03
8.2.60.0000.00817.68
8.2.50.0040.00418.10
8.2.40.0030.00519.47
8.2.30.0000.00819.32
8.2.20.0000.01018.13
8.2.10.0040.00418.18
8.2.00.0030.00617.75
8.1.280.0100.01025.92
8.1.270.0060.00318.88
8.1.260.0090.00026.35
8.1.250.0050.00228.09
8.1.240.0030.00620.77
8.1.230.0040.00720.92
8.1.220.0060.00317.79
8.1.210.0000.00818.77
8.1.200.0030.00617.35
8.1.190.0040.00417.35
8.1.180.0030.00618.10
8.1.170.0040.00418.59
8.1.160.0000.00718.82
8.1.150.0040.00418.91
8.1.140.0030.00322.05
8.1.130.0080.00020.38
8.1.120.0000.00717.38
8.1.110.0040.00417.53
8.1.100.0000.00817.38
8.1.90.0040.00417.43
8.1.80.0040.00417.46
8.1.70.0050.00517.42
8.1.60.0050.00317.65
8.1.50.0040.00417.45
8.1.40.0070.00017.42
8.1.30.0030.00617.69
8.1.20.0050.00317.64
8.1.10.0000.00717.60
8.1.00.0030.00517.57
8.0.300.0040.00419.79
8.0.290.0090.00016.75
8.0.280.0030.00418.32
8.0.270.0070.00017.18
8.0.260.0000.00618.50
8.0.250.0000.00716.96
8.0.240.0000.00716.81
8.0.230.0040.00416.97
8.0.220.0030.00316.93
8.0.210.0000.00916.92
8.0.200.0070.00016.95
8.0.190.0030.00616.98
8.0.180.0040.00416.84
8.0.170.0080.00016.93
8.0.160.0000.00716.89
8.0.150.0040.00416.82
8.0.140.0070.00016.72
8.0.130.0040.00413.30
8.0.120.0000.00716.83
8.0.110.0000.00816.94
8.0.100.0000.00816.70
8.0.90.0040.00416.71
8.0.80.0110.00816.87
8.0.70.0070.00016.84
8.0.60.0050.00316.68
8.0.50.0000.00716.92
8.0.30.0040.01517.18
8.0.20.0070.01317.40
8.0.10.0040.00416.88
8.0.00.0090.00916.89
7.4.330.0030.00315.55
7.4.320.0030.00316.61
7.4.300.0000.00616.46
7.4.290.0060.00316.59
7.4.280.0000.00716.42
7.4.270.0000.00716.56
7.4.260.0040.00416.59
7.4.250.0000.00816.48
7.4.240.0040.00316.42
7.4.230.0000.00716.49
7.4.220.0000.00716.41
7.4.210.0080.00816.59
7.4.200.0000.00716.35
7.4.160.0070.01016.46
7.4.140.0120.00817.86
7.4.130.0160.00616.54
7.4.120.0100.00916.53
7.4.110.0120.00616.61
7.4.100.0140.00316.46
7.4.90.0030.01316.52
7.4.80.0100.00719.39
7.4.70.0070.01316.37
7.4.60.0120.00416.52
7.4.50.0000.01416.56
7.4.40.0080.01516.46
7.4.10.0060.01016.50
7.4.00.0030.01315.72
7.3.330.0060.00013.33
7.3.320.0000.00513.30
7.3.310.0040.00416.13
7.3.300.0030.00316.11
7.3.290.0000.00716.22
7.3.280.0110.00316.27
7.3.260.0090.00916.34
7.3.240.0110.00816.42
7.3.230.0060.01216.37
7.3.210.0130.00716.33
7.3.200.0060.00916.51
7.3.190.0090.00916.30
7.3.180.0060.01616.58
7.3.170.0100.01016.44
7.3.160.0090.01216.30
7.3.130.0100.01016.20
7.3.120.0030.01615.61
7.3.110.0080.01015.57
7.3.100.0100.00515.31
7.3.90.0080.00715.52
7.3.80.0060.00315.53
7.3.70.0070.00715.54
7.3.60.0070.00815.69
7.3.50.0060.00515.47
7.3.40.0090.00515.64
7.3.30.0080.00915.52
7.3.20.0060.00817.36
7.3.10.0050.00917.34
7.3.00.0080.00417.29
7.2.330.0100.00716.45
7.2.320.0110.00616.79
7.2.310.0140.00516.52
7.2.300.0070.01016.68
7.2.290.0120.00716.46
7.2.260.0070.01016.54
7.2.250.0090.01016.66
7.2.240.0060.01115.78
7.2.230.0030.01215.69
7.2.220.0100.00615.89
7.2.210.0040.01215.80
7.2.200.0050.00815.76
7.2.190.0090.00715.84
7.2.180.0060.00715.83
7.2.170.0030.00815.69
7.2.160.0050.01215.88
7.2.150.0060.00817.75
7.2.140.0070.00717.75
7.2.130.0050.00717.77
7.2.120.0060.00917.70
7.2.110.0280.00816.79
7.2.100.0220.01016.66
7.2.90.0240.00616.70
7.2.80.0210.01016.54
7.2.70.0230.00716.81
7.2.60.0250.00616.72
7.2.50.0220.01116.72
7.2.40.0240.00816.83
7.2.30.0190.00916.79
7.2.20.0220.00916.89
7.2.10.0190.01116.88
7.2.00.0180.01016.72
7.1.330.0040.01116.45
7.1.320.0030.01116.54
7.1.310.0020.01316.61
7.1.300.0100.00216.46
7.1.290.0070.00716.61
7.1.280.0070.00716.58
7.1.270.0030.01216.68
7.1.260.0050.01016.60
7.1.250.0080.00416.40
7.1.240.0100.00017.42
7.1.230.0440.00715.46
7.1.220.0800.00815.64
7.1.210.0310.00515.66
7.1.200.0270.00615.45
7.1.190.0310.00715.45
7.1.180.0260.00915.54
7.1.170.0350.00315.42
7.1.160.0290.01215.73
7.1.150.0350.00815.45
7.1.140.0290.00815.58
7.1.130.0300.01015.61
7.1.120.0310.00515.50
7.1.110.0410.00515.68
7.1.100.0310.00615.66
7.1.90.0250.01115.70
7.1.80.0260.00915.66
7.1.70.0270.01015.72
7.1.60.0420.01124.57
7.1.50.0410.00924.61
7.1.40.0450.01324.57
7.1.30.0500.00924.57
7.1.20.0410.00824.72
7.1.10.0290.00715.58
7.1.00.0300.00915.44
7.0.330.0070.00316.96
7.0.320.0030.01417.00
7.0.310.0100.00317.05
7.0.300.0080.00516.97
7.0.290.0040.00816.86
7.0.280.0000.00917.11
7.0.270.0120.00616.96
7.0.260.0000.00917.13
7.0.250.0030.00617.03
7.0.240.0070.00717.04
7.0.230.0040.00717.16
7.0.220.0070.00717.22
7.0.210.0040.00716.92
7.0.200.0100.00317.01
7.0.190.0060.00617.16
7.0.180.0120.00316.93
7.0.170.0060.00617.21
7.0.160.0070.00417.13
7.0.150.0070.00416.99
7.0.140.0060.00617.04
7.0.130.0030.00717.14
7.0.120.0070.00417.03
7.0.110.0040.00817.01
7.0.100.0100.00317.09
7.0.90.0060.00316.91
7.0.80.0070.00717.21
7.0.70.0040.01116.95
7.0.60.0060.00816.91
7.0.50.0000.01216.81
7.0.40.0050.00514.94
7.0.30.0000.01315.01
7.0.20.0110.00415.01
7.0.10.0000.01115.17
7.0.00.0060.00714.88
5.6.400.0070.01015.61
5.6.390.0030.01015.40
5.6.380.0060.00914.91
5.6.370.0090.00015.71
5.6.360.0040.00715.69
5.6.350.0040.00815.72
5.6.340.0060.00615.39
5.6.330.0130.00016.03
5.6.320.0110.00415.29
5.6.310.0040.00715.45
5.6.300.0060.00315.67
5.6.290.0100.00715.90
5.6.280.0100.00015.39
5.6.270.0030.01015.64
5.6.260.0030.00715.63
5.6.250.0090.00615.42
5.6.240.0060.00315.67
5.6.230.0030.01015.63
5.6.220.0090.00615.61
5.6.210.0090.00615.51
5.6.200.0070.00715.22
5.6.190.0080.00415.52
5.6.180.0070.00715.51
5.6.170.0040.01215.67
5.6.160.0040.01415.89
5.6.150.0040.01115.79
5.6.140.0100.00315.59
5.6.130.0090.00615.73
5.6.120.0060.00615.52
5.6.110.0060.00615.61
5.6.100.0090.00615.45
5.6.90.0000.01115.40
5.6.80.0090.00615.77
5.6.70.0030.00715.52
5.6.60.0080.00615.51
5.6.50.0090.00615.68
5.6.40.0070.01115.55
5.6.30.0040.01415.52
5.6.20.0030.01115.59
5.6.10.0060.01215.58
5.6.00.0130.00315.58

preferences:
55.91 ms | 401 KiB | 5 Q