3v4l.org

run code in 300+ PHP versions simultaneously
#!/usr/bin/env php <?php /** * Generate the page order for building a PDF of A4 pages printed as an A5 Booklet form on a MacBook that is * missing the proper A5 Booklet form. * * @return int[] */ function getPageList(int $pageCount): array { // Generate a list of page numbers, including additional blank pages required to get the total number of page // divisible by 4 to represent the list of A4 pages to be printed in as an A5 Booklet form. $pages = $pageCount % 4 !== 0 ? array_merge( range(1, $pageCount), array_fill( $pageCount + 1, 4 - ($pageCount % 4), 'blank' ) ) : range(1, $pageCount); $results = []; // Extract the pages to be printed in the relevant order for an A5 Booklet form. while (count($pages) !== 0) { // The page order is last page, first page, first + 1, last - 1. // As we remove these pages from $pages, we can repeat this extraction whilst there are no pages to left. $results[1 + count($results)] = [ 'Left front' => array_pop($pages), 'Right front' => array_shift($pages), 'Right back' => array_shift($pages), 'Left back' => array_pop($pages), ]; } return $results; } print_r(getPageList($argv[1]));

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.70.0130.00618.43
8.3.60.0290.01625.92
8.3.50.0120.00325.92
8.3.40.0110.01925.92
8.3.30.0250.00725.92
8.3.20.0290.00725.92
8.3.10.0300.00025.92
8.3.00.0270.00625.92
8.2.190.0140.00716.58
8.2.180.0090.00925.92
8.2.170.0260.01025.92
8.2.160.0280.01225.92
8.2.150.0310.00325.92
8.2.140.0240.01025.92
8.2.130.0260.00725.92
8.2.120.0350.00025.92
8.2.110.0260.00725.92
8.2.100.0250.00625.92
8.2.90.0330.00325.92
8.2.80.0240.00825.92
8.2.70.0290.00725.92
8.2.60.0120.01225.92
8.2.50.0230.01025.92
8.2.40.0220.00725.92
8.2.30.0220.00925.92
8.2.20.0120.00325.92
8.2.10.0260.00325.92
8.2.00.0240.00825.92
8.1.280.0280.00325.92
8.1.270.0300.00425.92
8.1.260.0200.01425.92
8.1.250.0340.00025.92
8.1.240.0220.00725.92
8.1.230.0240.00725.92
8.1.220.0230.00525.92
8.1.210.0280.00625.92
8.1.200.0200.01125.92
8.1.190.0150.01825.92
8.1.180.0340.00325.92
8.1.170.0370.00625.92
8.1.160.0190.01125.92
8.1.150.0210.00925.92
8.1.140.0250.00625.92
8.1.130.0240.00625.92
8.1.120.0220.00925.92
8.1.110.0230.00525.92
8.1.100.0270.00625.92
8.1.90.0300.00025.92
8.1.80.0300.00025.92
8.1.70.0260.01325.92
8.1.60.0350.00725.92
8.1.50.0420.00625.92
8.1.40.0400.00425.92
8.1.30.0280.01125.92
8.1.20.0190.01625.92
8.1.10.0240.01225.92
8.1.00.0280.00725.92

preferences:
23.19 ms | 401 KiB | 5 Q