3v4l.org

run code in 300+ PHP versions simultaneously
<?php $competitors = [1, 2, 3, 4, 5 , 6, 7, 8]; $rounds = log( count( $competitors ), 2 ) + 1; // round one for( $i = 0; $i < log( count( $competitors ), 2 ); $i++ ) { $seeded = array( ); foreach( $competitors as $competitor ) { $splice = pow( 2, $i ); $seeded = array_merge( $seeded, array_splice( $competitors, 0, $splice ) ); $seeded = array_merge( $seeded, array_splice( $competitors, -$splice ) ); } $competitors = $seeded; } $events = array_chunk( $seeded, 2 ); if( $rounds > 2 ) { $round_index = count( $events ); // second round for( $i = 0; $i < count( $competitors ) / 2; $i++ ) { array_push( $events, array( array( 'from_event_index' => $i, 'from_event_rank' => 1 ), // rank 1 = winner array( 'from_event_index' => ++$i, 'from_event_rank' => 1 ) ) ); } $round_matchups = array( ); for( $i = 0; $i < count( $competitors ) / 2; $i++ ) { array_push( $round_matchups, array( array( 'from_event_index' => $i, 'from_event_rank' => 2 ), // rank 2 = loser array( 'from_event_index' => ++$i, 'from_event_rank' => 2 ) ) ); } $events = array_merge( $events, $round_matchups ); for( $i = 0; $i < count( $round_matchups ); $i++ ) { array_push( $events, array( array( 'from_event_index' => $i + count( $competitors ) / 2, 'from_event_rank' => 2 ), array( 'from_event_index' => $i + count( $competitors ) / 2 + count( $competitors ) / 2 / 2, 'from_event_rank' => 1 ) ) ); } } if( $rounds > 3 ) { // subsequent rounds for( $i = 0; $i < $rounds - 3; $i++ ) { $round_events = pow( 2, $rounds - 3 - $i ); $total_events = count( $events ); for( $j = 0; $j < $round_events; $j++ ) { array_push( $events, array( array( 'from_event_index' => $j + $round_index, 'from_event_rank' => 1 ), array( 'from_event_index' => ++$j + $round_index, 'from_event_rank' => 1 ) ) ); } for( $j = 0; $j < $round_events; $j++ ) { array_push( $events, array( array( 'from_event_index' => $j + $round_index + $round_events * 2, 'from_event_rank' => 1 ), array( 'from_event_index' => ++$j + $round_index + $round_events * 2, 'from_event_rank' => 1 ) ) ); } for( $j = 0; $j < $round_events / 2; $j++ ) { array_push( $events, array( array( 'from_event_index' => $j + $total_events, 'from_event_rank' => 2 ), array( 'from_event_index' => $j + $total_events + $round_events / 2, 'from_event_rank' => 1 ) ) ); } $round_index = $total_events; } } if( $rounds > 1 ) { // finals array_push( $events, array( array( 'from_event_index' => count( $events ) - 3, 'from_event_rank' => 1 ), array( 'from_event_index' => count( $events ) - 1, 'from_event_rank' => 1 ) ) ); } var_dump($events);

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.40.0150.00018.96
8.3.30.0190.00018.95
8.3.20.0080.00022.38
8.3.10.0030.00722.23
8.3.00.0060.00319.81
8.2.170.0110.00722.96
8.2.160.0030.01719.14
8.2.150.0000.00824.18
8.2.140.0040.00424.66
8.2.130.0040.00419.69
8.2.120.0040.00426.35
8.2.110.0060.00321.24
8.2.100.0090.00618.22
8.2.90.0000.00819.59
8.2.80.0040.00418.16
8.2.70.0040.00418.00
8.2.60.0030.00618.30
8.2.50.0090.00018.41
8.2.40.0040.00420.84
8.2.30.0000.00819.70
8.2.20.0000.00918.45
8.2.10.0030.00618.47
8.2.00.0000.00818.37
8.1.270.0000.00822.45
8.1.260.0080.00026.35
8.1.250.0080.00028.09
8.1.240.0040.00424.22
8.1.230.0070.00419.60
8.1.220.0030.00618.16
8.1.210.0060.00318.77
8.1.200.0050.00517.36
8.1.190.0000.00917.50
8.1.180.0040.00418.10
8.1.170.0040.00419.30
8.1.160.0070.00019.48
8.1.150.0000.00820.90
8.1.140.0030.00517.68
8.1.130.0050.00219.19
8.1.120.0030.00517.79
8.1.110.0080.00017.70
8.1.100.0040.00417.75
8.1.90.0040.00417.73
8.1.80.0040.00417.71
8.1.70.0040.00417.77
8.1.60.0070.00317.91
8.1.50.0040.00417.89
8.1.40.0120.00017.82
8.1.30.0030.00617.86
8.1.20.0060.00317.97
8.1.10.0040.00417.88
8.1.00.0050.00317.73
8.0.300.0000.00820.46
8.0.290.0000.00817.00
8.0.280.0000.00818.76
8.0.270.0040.00417.46
8.0.260.0030.00317.13
8.0.250.0030.00317.31
8.0.240.0080.00017.25
8.0.230.0040.00417.15
8.0.220.0000.00817.30
8.0.210.0040.00417.29
8.0.200.0030.00317.19
8.0.190.0030.00717.27
8.0.180.0060.00317.29
8.0.170.0040.00417.18
8.0.160.0000.00817.09
8.0.150.0080.00016.99
8.0.140.0000.00717.09
8.0.130.0030.00413.78
8.0.120.0040.00417.13
8.0.110.0040.00417.27
8.0.100.0030.00517.08
8.0.90.0000.00717.25
8.0.80.0120.01217.14
8.0.70.0040.00417.20
8.0.60.0000.00917.20
8.0.50.0060.00317.15
8.0.30.0140.00517.24
8.0.20.0120.01217.41
8.0.10.0080.00017.23
8.0.00.0120.00817.06
7.4.330.0030.00315.55
7.4.320.0050.00316.86
7.4.300.0070.00016.88
7.4.290.0040.00416.89
7.4.280.0000.00716.92
7.4.270.0070.00016.82
7.4.260.0040.00416.69
7.4.250.0000.00716.91
7.4.240.0060.00316.98
7.4.230.0000.00716.63
7.4.220.0070.01316.91
7.4.210.0000.01516.80
7.4.200.0040.00417.07
7.4.160.0140.00616.67
7.4.150.0160.01317.40
7.4.140.0130.00717.86
7.4.130.0110.01516.89
7.4.120.0090.01016.72
7.4.110.0140.00916.71
7.4.100.0160.00616.63
7.4.90.0100.01316.81
7.4.80.0120.01619.39
7.4.70.0120.00716.74
7.4.60.0090.00816.77
7.4.50.0070.01016.82
7.4.40.0100.00716.70
7.4.30.0150.00316.75
7.4.00.0100.00315.16
7.3.330.0030.00313.59
7.3.320.0000.00513.48
7.3.310.0050.00216.68
7.3.300.0040.00416.61
7.3.290.0060.01016.57
7.3.280.0100.00916.55
7.3.270.0110.01117.40
7.3.260.0100.01016.86
7.3.250.0130.01016.58
7.3.240.0080.01116.51
7.3.230.0190.00016.86
7.3.210.0100.01016.61
7.3.200.0120.00816.75
7.3.190.0000.02016.48
7.3.180.0130.00516.54
7.3.170.0100.01016.78
7.3.160.0130.00516.75
7.2.330.0130.00816.76
7.2.320.0090.01416.98
7.2.310.0070.01117.06
7.2.300.0060.01216.78
7.2.290.0060.01616.81
7.2.60.0120.00316.95
7.2.00.0060.00619.88
7.1.200.0070.00716.05
7.1.100.0000.01118.47
7.1.70.0070.00717.31
7.1.60.0070.02335.27
7.1.50.0230.00334.65
7.1.40.0230.01234.38
7.1.30.0190.01034.67
7.1.20.0230.01034.81
7.1.10.0000.01416.84
7.1.00.0080.00816.88
7.0.200.0040.01016.87
7.0.190.0070.00716.96
7.0.180.0070.01016.55
7.0.170.0070.01016.56
7.0.160.0080.00616.35
7.0.150.0040.01116.43
7.0.140.0030.01216.45
7.0.130.0040.01116.98
7.0.120.0090.00616.66
7.0.110.0080.00816.64
7.0.100.0040.01216.45
7.0.90.0080.00516.62
7.0.80.0130.00316.49
7.0.70.0040.01116.42
7.0.60.0070.00716.20
7.0.50.0060.01316.41
7.0.40.0050.01416.61
7.0.30.0040.01616.61
7.0.20.0120.00616.55
7.0.10.0090.00916.63
7.0.00.0090.01216.63

preferences:
43.17 ms | 400 KiB | 5 Q