3v4l.org

run code in 300+ PHP versions simultaneously
<?php function wp_total_pages( $total_items, $per_page ) { $remainder = $total_items % $per_page; if ( $remainder ) { $total_items += $per_page - $remainder; } return $total_items / $per_page; } $input_sets = [ [506, 10], [505, 10], [504, 10], [500, 9.5], [500, 9], [35478743512, 15], [PHP_INT_MAX, 20], [PHP_INT_MAX + 250, 20], ]; foreach ($input_sets as list($a, $b)) { echo PHP_EOL, '=================================================', PHP_EOL; echo 'Given the following inputs:', PHP_EOL; var_dump($a, $b); $over = $a % $b; $over = ($over > 0) ? 1 : 0; echo PHP_EOL, 'The results will be:', PHP_EOL; echo 'ceil: ', var_dump(ceil($a/$b)); echo 'round + ceil: ', var_dump(round(ceil($a/$b))); echo 'wp_total_pages: ', var_dump(wp_total_pages($a, $b)); try { if (function_exists('intdiv')) { echo 'intdiv: ', var_dump($over + intdiv($a, $b)); } else { echo 'intdiv function not available', PHP_EOL; } } catch (Error $e) { echo 'intdiv: ', $e->getMessage(), PHP_EOL; } try { echo 'bcdiv: ', var_dump($over + bcdiv($a, $b)); } catch (Error $e) { echo 'bcdiv: ', $e->getMessage(), PHP_EOL; } echo PHP_EOL, 'And the results with an int cast added will be:', PHP_EOL; echo 'ceil: ', var_dump((int) ceil($a/$b)); echo 'round + ceil: ', var_dump((int) round(ceil($a/$b))); echo 'wp_total_pages: ', var_dump((int) wp_total_pages($a, $b)); try { if (function_exists('intdiv')) { echo 'intdiv: ', var_dump((int)($over + intdiv($a, $b))); } else { echo 'intdiv function not available', PHP_EOL; } } catch (Error $e) { echo 'intdiv: ', $e->getMessage(), PHP_EOL; } try { echo 'bcdiv: ', var_dump((int) ($over + bcdiv($a, $b))); } catch (Error $e) { echo 'bcdiv: ', $e->getMessage(), PHP_EOL; } }

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.20.0040.01318.10
8.4.10.0060.00319.92
8.3.150.0050.00518.65
8.3.140.0030.01419.02
8.3.130.0090.00018.52
8.3.120.0150.00419.41
8.3.110.0030.00720.94
8.3.100.0030.00517.02
8.3.90.0070.00326.77
8.3.80.0030.00716.88
8.3.70.0060.01318.53
8.3.60.0120.00616.63
8.3.50.0110.00817.76
8.3.40.0120.00918.91
8.3.30.0070.00719.09
8.3.20.0040.00424.18
8.3.10.0040.00424.66
8.3.00.0080.00026.16
8.2.270.0080.00017.39
8.2.260.0040.01118.59
8.2.250.0030.00717.02
8.2.240.0050.00518.95
8.2.230.0100.00022.58
8.2.220.0040.00437.54
8.2.210.0060.00326.77
8.2.200.0030.00616.63
8.2.190.0110.00416.75
8.2.180.0140.00725.92
8.2.170.0090.00619.21
8.2.160.0150.00622.96
8.2.150.0110.00025.66
8.2.140.0090.00024.66
8.2.130.0050.00326.16
8.2.120.0120.00320.96
8.2.110.0060.00320.47
8.2.100.0060.00618.16
8.2.90.0040.00418.00
8.2.80.0080.00019.02
8.2.70.0080.00018.05
8.2.60.0040.00418.34
8.2.50.0040.00418.10
8.2.40.0000.00821.27
8.2.30.0080.00019.54
8.2.20.0080.00018.30
8.2.10.0000.00819.54
8.2.00.0050.00319.52
8.1.310.0040.01518.60
8.1.300.0070.01117.86
8.1.290.0060.00330.84
8.1.280.0090.00625.92
8.1.270.0060.00323.99
8.1.260.0090.00026.35
8.1.250.0080.00028.09
8.1.240.0030.00623.84
8.1.230.0040.00817.96
8.1.220.0000.00817.89
8.1.210.0000.00818.77
8.1.200.0040.00417.60
8.1.190.0030.00617.50
8.1.180.0040.00418.10
8.1.170.0040.00418.87
8.1.160.0050.00319.12
8.1.150.0020.00519.13
8.1.140.0050.00318.98
8.1.130.0040.00417.67
8.1.120.0050.00217.61
8.1.110.0080.00017.52
8.1.100.0070.00317.66
8.1.90.0000.00817.48
8.1.80.0030.00717.60
8.1.70.0050.00317.56
8.1.60.0050.00517.69
8.1.50.0030.00617.60
8.1.40.0040.00417.71
8.1.30.0030.00517.89
8.1.20.0000.00817.84
8.1.10.0030.00517.63
8.1.00.0040.00417.63
8.0.300.0040.00418.77
8.0.290.0030.00617.13
8.0.280.0000.00718.67
8.0.270.0040.00418.85
8.0.260.0030.00317.06
8.0.250.0040.00417.23
8.0.240.0000.00817.09
8.0.230.0000.00717.20
8.0.220.0040.00417.14
8.0.210.0000.00717.16
8.0.200.0000.00717.25
8.0.190.0000.00917.12
8.0.180.0050.00217.19
8.0.170.0030.00617.13
8.0.160.0030.00517.09
8.0.150.0000.00816.96
8.0.140.0060.00317.13
8.0.130.0000.00613.52
8.0.120.0040.00417.16
8.0.110.0000.00817.09
8.0.100.0040.00417.13
8.0.90.0000.00817.02
8.0.80.0110.00917.15
8.0.70.0000.00817.14
8.0.60.0040.00416.95
8.0.50.0090.00017.19
8.0.30.0040.01717.24
8.0.20.0090.00917.14
8.0.10.0090.01217.13
8.0.00.0100.01317.20
7.4.330.0050.00015.55
7.4.320.0000.00716.69
7.4.300.0000.00816.73
7.4.290.0050.00316.71
7.4.280.0050.00216.62
7.4.270.0000.00716.75
7.4.260.0000.00513.46
7.4.250.0040.00416.63
7.4.240.0050.00316.76
7.4.230.0000.00716.60
7.4.220.0020.00516.67
7.4.210.0140.00316.80
7.4.200.0000.00716.59
7.4.160.0120.00916.90
7.4.150.0170.00316.59
7.4.140.0100.00816.63
7.4.130.0100.01016.74
7.4.120.0160.00416.71
7.4.110.0120.00916.62
7.4.100.0170.00316.71
7.4.90.0080.01316.54
7.4.80.0090.00616.82
7.4.70.0190.00016.79
7.4.60.0110.00616.52
7.4.50.0070.01116.96
7.4.40.0130.00616.76
7.4.30.0030.01216.54
7.4.20.0140.01116.43
7.4.10.0050.01116.66
7.4.00.0120.00316.56
7.3.330.0030.00516.62
7.3.320.0040.00413.60
7.3.310.0000.00716.38
7.3.300.0000.00716.61
7.3.290.0120.00616.59
7.3.270.0090.00916.59
7.3.260.0060.01416.59
7.3.250.0100.01016.57
7.3.240.0180.00616.77
7.3.230.0060.01216.46
7.3.220.0160.00016.51
7.3.210.0110.01116.65
7.3.200.0140.00516.69
7.3.190.0090.00616.75
7.3.180.0040.01516.62
7.3.170.0040.01616.71
7.3.160.0110.00716.43
7.3.150.0070.01316.70
7.3.140.0160.00016.53
7.3.130.0060.01216.73
7.3.120.0080.00816.82
7.3.110.0090.01216.51
7.3.100.0080.01116.63
7.3.90.0180.00016.83
7.3.80.0060.01316.52
7.3.70.0160.00516.51
7.3.60.0120.00916.63
7.3.50.0150.00316.64
7.3.40.0080.01116.71
7.3.30.0120.00616.52
7.3.20.0120.00416.61
7.3.10.0160.00016.69
7.3.00.0170.00316.45
7.2.340.0200.01116.83
7.2.330.0240.00616.81
7.2.320.0200.01216.86
7.2.310.0290.00716.61
7.2.300.0230.00816.79
7.2.290.0270.00916.91
7.2.280.0210.01416.92
7.2.270.0190.01516.92
7.2.260.0270.00616.89
7.2.250.0150.01816.57
7.2.240.0250.00916.87
7.2.230.0230.00916.68
7.2.220.0280.00316.58
7.2.210.0330.00016.77
7.2.200.0240.01216.86
7.2.190.0190.00916.68
7.2.180.0300.00316.80
7.2.170.0270.00716.79
7.2.160.0260.00316.82
7.2.150.0390.00316.89
7.2.140.0290.00016.87
7.2.130.0220.00316.84
7.2.120.0320.00416.92
7.2.110.0180.01516.80
7.2.100.0150.01516.73
7.2.90.0300.00516.77
7.2.80.0220.00916.66
7.2.70.0280.00716.86
7.2.60.0220.01916.81
7.2.50.0250.01116.89
7.2.40.0280.00616.80
7.2.30.0250.01016.78
7.2.20.0290.01116.69
7.2.10.0300.00416.83
7.2.00.0240.00616.73
7.1.330.0170.01015.75
7.1.320.0230.00915.79
7.1.310.0210.01115.73
7.1.300.0150.01215.96
7.1.290.0260.00615.84
7.1.280.0310.00615.83
7.1.270.0220.00915.79
7.1.260.0180.01115.66
7.1.250.0290.01015.81
7.1.240.0190.00415.80
7.1.230.0130.00915.57
7.1.220.0250.00415.67
7.1.210.0170.01015.87
7.1.200.0280.01215.77
7.1.190.0220.00915.52
7.1.180.0250.00415.67
7.1.170.0180.01315.76
7.1.160.0240.01215.73
7.1.150.0250.00315.83
7.1.140.0180.00715.79
7.1.130.0150.00915.63
7.1.120.0250.00915.69
7.1.110.0400.00415.85
7.1.100.0120.01215.86
7.1.90.0250.00615.83
7.1.80.0230.00615.92
7.1.70.0140.01715.85
7.1.60.0170.01415.79
7.1.50.0170.01015.79
7.1.40.0210.00915.73
7.1.30.0160.01115.77
7.1.20.0160.01215.79
7.1.10.0300.01015.91
7.1.00.0140.01015.72
7.0.330.0180.01115.29
7.0.320.0220.00715.32
7.0.310.0170.01215.43
7.0.300.0250.01215.36
7.0.290.0240.00915.52
7.0.280.0260.00615.52
7.0.270.0150.00615.24
7.0.260.0090.01515.41
7.0.250.0110.01115.44
7.0.240.0150.01015.49
7.0.230.0080.01215.38
7.0.220.0230.00515.59
7.0.210.0220.00415.32
7.0.200.0130.01115.26
7.0.190.0310.00715.36
7.0.180.0280.00315.48
7.0.170.0160.01215.38
7.0.160.0120.02115.37
7.0.150.0260.00315.42
7.0.140.0150.01115.33
7.0.130.0130.01615.43
7.0.120.0200.00815.51
7.0.110.0210.01015.42
7.0.100.0270.00815.57
7.0.90.0130.01315.26
7.0.80.0140.00515.48
7.0.70.0220.00415.54
7.0.60.0180.00615.61
7.0.50.0000.01615.30
7.0.40.0190.00315.21
7.0.30.0100.01015.18
7.0.20.0250.00315.44
7.0.10.0130.01015.13
7.0.00.0060.01615.32
5.6.400.0180.00916.07
5.6.390.0130.01316.40
5.6.380.0250.00316.24
5.6.370.0180.00916.37
5.6.360.0290.00816.42
5.6.350.0240.01016.26
5.6.340.0230.01016.03
5.6.330.0100.01016.19
5.6.320.0180.00615.90
5.6.310.0160.01616.26
5.6.300.0220.01316.26
5.6.290.0220.00316.30
5.6.280.0140.01415.96
5.6.270.0230.00816.29
5.6.260.0230.01016.37
5.6.250.0220.01016.35
5.6.240.0190.01016.14
5.6.230.0090.01316.07
5.6.220.0290.00015.99
5.6.210.0190.00916.00
5.6.200.0130.01916.40
5.6.190.0130.01616.02
5.6.180.0070.01416.12
5.6.170.0070.01115.96
5.6.160.0110.01116.01
5.6.150.0190.00516.14
5.6.140.0150.00816.20
5.6.130.0220.00516.40
5.6.120.0110.00815.88
5.6.110.0070.01115.98
5.6.100.0100.01015.82
5.6.90.0060.01616.16
5.6.80.0070.01415.83
5.6.70.0120.00916.17
5.6.60.0060.01416.11
5.6.50.0100.01015.93
5.6.40.0190.00816.11
5.6.30.0250.00716.25
5.6.20.0210.00916.15
5.6.10.0260.00316.12
5.6.00.0210.01116.06
5.5.380.0080.02016.27
5.5.370.0260.00616.14
5.5.360.0180.01516.24
5.5.350.0180.01616.00
5.5.340.0110.01515.84
5.5.330.0200.01116.48
5.5.320.0200.00716.21
5.5.310.0190.01116.27
5.5.300.0150.01215.96
5.5.290.0100.01716.05
5.5.280.0110.01716.15
5.5.270.0210.00616.41
5.5.260.0210.00615.82
5.5.250.0160.01616.01
5.5.240.0250.01016.07
5.5.230.0200.00816.10
5.5.220.0180.00916.06
5.5.210.0270.00515.99
5.5.200.0290.00615.99
5.5.190.0100.02015.86
5.5.180.0320.00416.04
5.5.170.0160.00816.10
5.5.160.0220.00616.11
5.5.150.0240.00315.89
5.5.140.0190.00816.02
5.5.130.0150.01015.80
5.5.120.0130.01315.94
5.5.110.0140.01516.29
5.5.100.0170.01316.18
5.5.90.0190.01316.21
5.5.80.0230.00815.79
5.5.70.0280.00616.16
5.5.60.0150.01516.04
5.5.50.0190.01316.03
5.5.40.0160.01516.03
5.5.30.0150.01116.07
5.5.20.0210.01216.16
5.5.10.0270.00316.12
5.5.00.0230.00816.07
5.4.450.0100.01012.50
5.4.440.0130.00612.57
5.4.430.0150.00312.54
5.4.420.0130.00712.45
5.4.410.0120.01212.62
5.4.400.0100.01012.49
5.4.390.0160.00512.51
5.4.380.0120.00612.25
5.4.370.0100.01312.59
5.4.360.0170.00712.34
5.4.350.0080.01212.49
5.4.340.0140.00312.27
5.4.330.0100.01012.31
5.4.320.0110.01112.41
5.4.310.0210.00412.44
5.4.300.0070.01112.35
5.4.290.0170.00412.33
5.4.280.0100.00712.22
5.4.270.0090.00912.24
5.4.260.0170.00312.47
5.4.250.0190.00512.47
5.4.240.0110.01112.39
5.4.230.0130.00412.35
5.4.220.0130.00612.45
5.4.210.0180.00712.27
5.4.200.0160.00812.18
5.4.190.0160.00812.58
5.4.180.0130.00712.50
5.4.170.0180.00012.46
5.4.160.0170.00612.61
5.4.150.0090.01212.31
5.4.140.0140.00712.33
5.4.130.0270.00012.50
5.4.120.0130.00712.48
5.4.110.0170.00812.36
5.4.100.0170.00712.46
5.4.90.0200.00612.25
5.4.80.0180.00412.38
5.4.70.0130.00912.29
5.4.60.0190.00012.52
5.4.50.0150.00712.47
5.4.40.0210.00012.38
5.4.30.0170.00312.39
5.4.20.0100.01012.54
5.4.10.0160.00612.48
5.4.00.0130.01312.34
5.3.290.0160.00512.91
5.3.280.0210.00412.78
5.3.270.0120.00912.84
5.3.260.0130.00612.86
5.3.250.0110.01112.70
5.3.240.0150.00712.73
5.3.230.0090.01312.64
5.3.220.0160.00312.81
5.3.210.0100.01012.69
5.3.200.0150.01012.67
5.3.190.0180.00712.86
5.3.180.0160.00613.13
5.3.170.0160.00412.99
5.3.160.0100.01012.86
5.3.150.0130.00612.98
5.3.140.0200.00512.96
5.3.130.0110.01112.76
5.3.120.0100.01312.93
5.3.110.0110.00812.94
5.3.100.0150.00413.06
5.3.90.0090.01213.02
5.3.80.0120.00812.86
5.3.70.0190.00012.72
5.3.60.0150.01212.95
5.3.50.0190.00312.87
5.3.40.0170.01112.67
5.3.30.0130.01012.84
5.3.20.0130.00812.81
5.3.10.0150.00512.50
5.3.00.0140.00912.47
5.2.170.0080.00811.91
5.2.160.0110.00711.91
5.2.150.0100.01011.91
5.2.140.0110.00711.73
5.2.130.0100.01011.87
5.2.120.0160.00411.85
5.2.110.0110.00611.72
5.2.100.0070.01011.74
5.2.90.0140.00911.91
5.2.80.0120.00611.66
5.2.70.0120.00911.66
5.2.60.0110.00911.64
5.2.50.0050.01011.72
5.2.40.0070.01111.71
5.2.30.0100.01011.64
5.2.20.0090.00611.64
5.2.10.0100.00511.64
5.2.00.0140.00011.64
5.1.60.0090.01211.64
5.1.50.0170.00311.64
5.1.40.0080.00811.64
5.1.30.0110.00811.64
5.1.20.0140.00711.64
5.1.10.0140.00411.64
5.1.00.0070.00711.64
5.0.50.0120.00311.64
5.0.40.0040.00911.64
5.0.30.0000.01411.64
5.0.20.0160.00611.64
5.0.10.0090.00411.64
5.0.00.0070.00411.64
4.4.90.0040.00411.64
4.4.80.0080.00411.64
4.4.70.0030.00811.64
4.4.60.0070.00311.64
4.4.50.0030.00611.64
4.4.40.0050.00511.64
4.4.30.0060.00311.64
4.4.20.0040.00611.64
4.4.10.0100.00011.64
4.4.00.0070.00311.64
4.3.110.0060.00011.64
4.3.100.0040.00411.64
4.3.90.0060.00311.64
4.3.80.0040.00411.64
4.3.70.0140.00011.64
4.3.60.0070.00011.64
4.3.50.0000.00811.64
4.3.40.0000.00911.64
4.3.30.0070.00711.64
4.3.20.0060.00011.64
4.3.10.0040.00411.64
4.3.00.0030.00311.64

preferences:
84.31 ms | 403 KiB | 5 Q