3v4l.org

run code in 300+ PHP versions simultaneously
<?php function mathematical_zeros_after_dot($float) { $float = abs($float); // remove any signs $float -= (int)$float; // remove whole numbers from float if ($float == 0) { return "Rendered as 0"; } $max = 20; for ($x = 0; $x < $max; ++$x) { $float *= 10; if ($float >= 1) { return $x; } } return "$max {exceeded}"; } $floats = [ 25.000000000022, // 10 0.0000062, // 5 0.020320, // 1 .505000, // 0 0, // 0 .000507, // 3 -.002009, // 2 1000, // 0 0.00, // 0 1 // 0 -1.0000000000004000004, // 12 981.0000000000000000000004000004 // 21 ]; foreach ($floats as $float) { echo "(Math) {$float} has " , mathematical_zeros_after_dot($float) , " zero(s)\n"; echo "Barmar {$float} has " , strspn($float, "0", strpos($float, ".")+1) , " zero(s)\n"; echo "(PMA) {$float} has " , preg_match_all('~(?:\.|\G(?!^))0~', $float) , " zero(s)\n"; echo "(PA) {$float} has " , (preg_match('~\.\K0+~', $float, $match) ? strlen($match[0]) : 0) , " zero(s)\n"; }

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.0130.00724.32
8.4.110.0050.00523.71
8.4.100.0120.00818.69
8.4.90.0120.00919.16
8.4.80.0040.00518.70
8.4.70.0130.00718.12
8.4.60.0070.00418.70
8.4.50.0090.01218.80
8.4.40.0100.01019.75
8.4.30.0130.00719.79
8.4.20.0140.00720.51
8.4.10.0090.01219.83
8.3.250.0090.01018.85
8.3.240.0120.00617.04
8.3.230.0130.00816.62
8.3.220.0100.00619.05
8.3.210.0080.00116.93
8.3.200.0060.00416.98
8.3.190.0160.00417.36
8.3.180.0060.00217.37
8.3.170.0040.01522.74
8.3.160.0160.00017.12
8.3.150.0100.01017.37
8.3.140.0130.00718.43
8.3.130.0030.00618.54
8.3.120.0070.01020.83
8.3.110.0070.01316.86
8.3.100.0050.00324.06
8.3.90.0130.00718.43
8.3.80.0090.00318.43
8.3.70.0130.00718.68
8.3.60.0100.01318.68
8.3.50.0100.01417.67
8.3.40.0160.00019.04
8.3.30.0100.00718.70
8.3.20.0040.00421.95
8.3.10.0080.00020.15
8.3.00.0000.00821.90
8.2.290.0120.00720.58
8.2.280.0100.01018.48
8.2.270.0040.01417.27
8.2.260.0110.00717.11
8.2.250.0100.00716.79
8.2.240.0030.00617.32
8.2.230.0030.00720.94
8.2.220.0090.00037.54
8.2.210.0040.00426.77
8.2.200.0060.00318.29
8.2.190.0080.00816.58
8.2.180.0080.00816.75
8.2.170.0110.00418.98
8.2.160.0150.00622.96
8.2.150.0090.00025.66
8.2.140.0030.00624.66
8.2.130.0040.00419.85
8.2.120.0080.00026.35
8.2.110.0040.00821.10
8.2.100.0130.00017.97
8.2.90.0030.00618.09
8.2.80.0000.00818.05
8.2.70.0030.00617.93
8.2.60.0030.00618.16
8.2.50.0000.00818.10
8.2.40.0000.00819.47
8.2.30.0000.00720.52
8.2.20.0040.00418.02
8.2.10.0000.00819.24
8.2.00.0030.00618.16
8.1.330.0120.00722.24
8.1.320.0130.00716.39
8.1.310.0080.00016.66
8.1.300.0060.00918.06
8.1.290.0090.00318.88
8.1.280.0070.01025.92
8.1.270.0130.00323.99
8.1.260.0070.00026.35
8.1.250.0030.00528.09
8.1.240.0030.00622.52
8.1.230.0000.01222.67
8.1.220.0030.00517.78
8.1.210.0030.00518.77
8.1.200.0060.00317.35
8.1.190.0040.00417.38
8.1.180.0040.00418.10
8.1.170.0040.00718.78
8.1.160.0000.00819.02
8.1.150.0040.00418.80
8.1.140.0000.00918.81
8.1.130.0030.00320.34
8.1.120.0000.00717.63
8.1.110.0080.00017.69
8.1.100.0060.00317.68
8.1.90.0000.00817.51
8.1.80.0040.00417.53
8.1.70.0000.00717.47
8.1.60.0000.00817.61
8.1.50.0060.01017.64
8.1.40.0140.00217.72
8.1.30.0080.00817.84
8.1.20.0090.00717.74
8.1.10.0070.00517.74
8.1.00.0080.00617.58
8.0.300.0000.00819.85
8.0.290.0050.00316.75
8.0.280.0050.00318.52
8.0.270.0030.00517.31
8.0.260.0040.00418.53
8.0.250.0030.00317.27
8.0.240.0030.00317.05
8.0.230.0040.00417.18
8.0.220.0000.00717.14
8.0.210.0030.00417.07
8.0.200.0030.00317.05
8.0.190.0080.00017.21
8.0.180.0050.00717.09
8.0.170.0040.00617.13
8.0.160.0080.00417.08
8.0.150.0060.00717.03
8.0.140.0070.00416.94
8.0.130.0080.00515.25
8.0.120.0090.00417.08
8.0.110.0110.00317.07
8.0.100.0090.00517.11
8.0.90.0090.00816.98
8.0.80.0110.00517.04
8.0.70.0070.00517.11
8.0.60.0080.00417.05
8.0.50.0060.00817.00
8.0.30.0130.00817.15
8.0.20.0180.00417.21
8.0.10.0090.00517.24
8.0.00.0080.01117.06
7.4.330.0020.00215.55
7.4.320.0030.00316.87
7.4.300.0060.00016.83
7.4.290.0080.00616.72
7.4.280.0150.00416.63
7.4.270.0120.00516.71
7.4.260.0080.00616.70
7.4.250.0100.00316.73
7.4.240.0080.00416.69
7.4.230.0150.00016.89
7.4.220.0080.00616.73
7.4.210.0090.00816.77
7.4.200.0060.00616.71
7.4.190.0170.00016.77
7.4.180.0140.00316.71
7.4.160.0140.00616.81
7.4.150.0100.01016.68
7.4.140.0160.00517.32
7.4.130.0090.00916.62
7.4.120.0130.00316.72
7.4.110.0100.00716.83
7.4.100.0110.01216.65
7.4.90.0150.00416.81
7.4.80.0120.00618.01
7.4.70.0150.00516.67
7.4.60.0110.00616.74
7.4.50.0110.00516.73
7.4.40.0060.01316.69
7.4.30.0130.00316.60
7.4.20.0100.00516.53
7.4.10.0120.00416.68
7.4.00.0090.00816.02
7.3.330.0110.00115.00
7.3.320.0090.00315.03
7.3.310.0110.00216.52
7.3.300.0070.00616.38
7.3.290.0060.00616.45
7.3.280.0120.00716.51
7.3.270.0130.00716.49
7.3.260.0130.00716.58
7.3.250.0170.00216.38
7.3.240.0090.01016.62
7.3.230.0150.00416.65
7.3.220.0110.00816.55
7.3.210.0120.00616.57
7.3.200.0110.00916.50
7.3.190.0110.01016.59
7.3.180.0120.01016.57
7.3.170.0120.00716.40
7.3.160.0110.00816.60
7.3.150.0060.01216.58
7.3.140.0140.00716.48
7.3.130.0110.00816.34
7.3.120.0150.00316.30
7.3.110.0110.00816.41
7.3.100.0140.00516.43
7.3.90.0190.00016.89
7.3.80.0190.00016.56
7.3.70.0190.00016.57
7.3.60.0110.00816.65
7.3.50.0120.00815.81
7.3.40.0160.00215.81
7.3.30.0130.00515.88
7.3.20.0130.00516.81
7.3.10.0130.00616.76
7.3.00.0120.00816.76
7.2.340.0130.00616.57
7.2.330.0070.01216.71
7.2.320.0090.00916.76
7.2.310.0120.00616.92
7.2.300.0090.00916.72
7.2.290.0130.00916.76
7.2.280.0150.00316.69
7.2.270.0160.00316.74
7.2.260.0130.00616.68
7.2.250.0180.00016.60
7.2.240.0130.00616.71
7.2.230.0160.00316.59
7.2.220.0190.00016.62
7.2.210.0100.00816.69
7.2.200.0170.00416.72
7.2.190.0200.00016.79
7.2.180.0110.01015.96
7.2.170.0100.00815.96
7.2.160.0130.00516.03
7.2.150.0150.00917.04
7.2.140.0130.00617.04
7.2.130.0170.00516.93
7.2.120.0150.00317.03
7.2.110.0120.00617.12
7.2.100.0140.00617.04
7.2.90.0680.00516.94
7.2.80.0170.00516.79
7.2.70.0140.00916.84
7.2.60.0190.00516.97
7.2.50.0170.00817.07
7.2.40.0130.00617.09
7.2.30.0190.00717.06
7.2.20.0250.00417.01
7.2.10.0140.00417.05
7.2.00.0110.00716.89
7.1.330.0150.00417.38
7.1.320.0140.00617.57
7.1.310.0130.00717.59
7.1.300.0150.00417.57
7.1.290.0150.00517.49
7.1.280.0150.00815.90
7.1.270.0120.00415.81
7.1.260.0080.00815.63
7.1.250.0130.00715.90
7.1.240.0150.00317.32
7.1.230.0160.00317.45
7.1.220.0140.00417.52
7.1.210.0140.00517.36
7.1.200.0150.00517.49
7.1.190.0160.00317.34
7.1.180.0180.00017.39
7.1.170.0120.01217.52
7.1.160.0160.00317.41
7.1.150.0190.00017.27
7.1.140.0080.01217.31
7.1.130.0120.00817.58
7.1.120.0140.00517.31
7.1.110.0130.00517.49
7.1.100.0200.00017.46
7.1.90.0190.00017.60
7.1.80.0130.00517.68
7.1.70.0150.00417.38
7.1.60.0160.00317.70
7.1.50.0190.00017.64
7.1.40.0150.00417.47
7.1.30.0190.00017.56
7.1.20.0170.00317.43
7.1.10.0190.00017.36
7.1.00.0150.00417.56

preferences:
108.02 ms | 403 KiB | 5 Q