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 ) ) ); }

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.0070.01117.00
8.3.50.0080.00616.48
8.3.40.0070.00718.96
8.3.30.0110.00718.92
8.3.20.0000.00820.39
8.3.10.0040.00722.33
8.3.00.0080.00020.04
8.2.180.0030.01318.53
8.2.170.0110.00722.96
8.2.160.0080.00819.52
8.2.150.0080.00024.18
8.2.140.0080.00024.66
8.2.130.0060.00319.64
8.2.120.0050.00226.35
8.2.110.0040.00722.64
8.2.100.0060.00618.16
8.2.90.0040.00419.47
8.2.80.0060.00317.97
8.2.70.0000.00817.75
8.2.60.0000.00818.30
8.2.50.0050.00318.10
8.2.40.0030.00620.97
8.2.30.0000.00719.53
8.2.20.0080.00018.39
8.2.10.0030.00518.29
8.2.00.0040.00418.43
8.1.280.0160.00025.92
8.1.270.0000.00822.56
8.1.260.0050.00326.35
8.1.250.0070.00028.09
8.1.240.0040.00424.09
8.1.230.0110.00018.14
8.1.220.0080.00018.04
8.1.210.0040.00418.77
8.1.200.0000.00917.60
8.1.190.0040.00417.47
8.1.180.0030.00518.10
8.1.170.0040.00419.26
8.1.160.0030.00319.24
8.1.150.0070.00020.79
8.1.140.0000.00919.98
8.1.130.0030.00519.23
8.1.120.0040.00417.84
8.1.110.0080.00017.69
8.1.100.0050.00217.65
8.1.90.0080.00017.64
8.1.80.0000.00817.77
8.1.70.0070.00017.66
8.1.60.0080.00317.88
8.1.50.0040.00417.80
8.1.40.0030.00817.89
8.1.30.0080.00018.04
8.1.20.0000.00918.01
8.1.10.0040.00417.84
8.1.00.0040.00417.83
8.0.300.0080.00018.77
8.0.290.0030.00616.88
8.0.280.0030.00518.67
8.0.270.0000.00717.57
8.0.260.0070.00017.04
8.0.250.0000.00717.34
8.0.240.0030.00717.23
8.0.230.0040.00417.19
8.0.220.0070.00017.16
8.0.210.0040.00417.18
8.0.200.0000.00717.29
8.0.190.0030.00717.21
8.0.180.0030.00517.25
8.0.170.0000.00817.20
8.0.160.0040.00417.13
8.0.150.0040.00417.01
8.0.140.0070.00017.13
8.0.130.0030.00313.67
8.0.120.0000.00717.20
8.0.110.0020.00517.23
8.0.100.0000.00817.21
8.0.90.0080.00017.19
8.0.80.0160.00817.20
8.0.70.0040.00417.21
8.0.60.0000.00817.13
8.0.50.0040.00417.06
8.0.30.0100.00717.22
8.0.20.0120.01017.40
8.0.10.0050.00217.16
8.0.00.0030.01416.89
7.4.330.0030.00315.55
7.4.320.0000.00616.86
7.4.300.0070.00016.83
7.4.290.0030.00516.75
7.4.280.0040.00416.90
7.4.270.0000.00716.86
7.4.260.0000.00816.77
7.4.250.0050.00316.64
7.4.240.0030.00616.84
7.4.230.0050.00216.83
7.4.220.0170.00416.77
7.4.210.0150.00016.68
7.4.200.0000.00816.78
7.4.160.0140.00616.61
7.4.150.0150.00317.40
7.4.140.0070.01317.86
7.4.130.0110.00616.59
7.4.120.0110.00916.65
7.4.110.0120.00616.79
7.4.100.0090.00916.82
7.4.90.0060.01016.72
7.4.80.0070.01019.39
7.4.70.0070.01516.66
7.4.60.0120.00316.79
7.4.50.0040.01116.91
7.4.40.0070.01016.71
7.4.30.0100.00716.54
7.4.00.0090.00815.46
7.3.330.0050.00013.54
7.3.320.0030.00313.45
7.3.310.0070.00016.81
7.3.300.0040.00416.63
7.3.290.0070.00916.54
7.3.280.0090.00816.56
7.3.270.0100.00717.40
7.3.260.0090.00916.79
7.3.250.0090.00816.49
7.3.240.0110.00716.50
7.3.230.0060.01216.62
7.3.210.0090.00816.48
7.3.200.0110.00416.73
7.3.190.0060.01016.54
7.3.180.0130.00316.77
7.3.170.0070.01316.67
7.3.160.0060.01316.64
7.3.120.0070.01015.29
7.3.110.0040.01215.41
7.3.100.0080.00815.17
7.3.90.0050.00815.21
7.3.80.0070.00915.42
7.3.70.0080.00415.19
7.3.60.0020.01215.34
7.3.50.0080.00315.14
7.3.40.0040.00915.21
7.3.30.0080.00515.14
7.3.20.0060.00716.94
7.3.10.0050.00816.79
7.3.00.0080.00216.93
7.2.330.0130.00916.68
7.2.320.0070.01416.66
7.2.310.0140.00316.58
7.2.300.0130.00716.93
7.2.290.0180.00417.02
7.2.250.0080.01015.36
7.2.240.0080.01215.43
7.2.230.0030.01115.42
7.2.220.0050.00615.49
7.2.210.0070.00615.30
7.2.200.0060.00715.27
7.2.190.0060.00815.51
7.2.180.0080.00515.40
7.2.170.0080.00815.26
7.2.160.0080.00415.50
7.2.150.0030.01017.44
7.2.140.0070.00717.15
7.2.130.0000.00917.00
7.2.120.0040.01117.07
7.2.110.0000.01617.34
7.2.100.0060.00317.20
7.2.90.0070.00317.16
7.2.80.0060.00617.36
7.2.70.0030.01417.43
7.2.60.0080.00817.20
7.2.50.0000.01317.32
7.2.40.0070.00717.47
7.2.30.0070.01117.12
7.2.20.0090.00917.52
7.2.10.0100.00717.27
7.2.00.0070.00918.48
7.1.330.0060.00916.12
7.1.320.0060.00715.96
7.1.310.0070.00616.14
7.1.300.0070.00916.01
7.1.290.0060.00616.04
7.1.280.0070.00716.15
7.1.270.0070.00816.04
7.1.260.0080.00416.13
7.1.250.0000.01215.79
7.1.240.0000.01016.05
7.1.230.0100.00016.13
7.1.220.0090.00315.77
7.1.210.0060.00616.17
7.1.200.0050.00815.97
7.1.190.0030.01415.97
7.1.180.0040.00416.05
7.1.170.0070.00316.10
7.1.160.0060.01016.04
7.1.150.0000.01816.30
7.1.140.0100.00716.16
7.1.130.0040.01116.12
7.1.120.0040.00716.10
7.1.110.0100.00315.89
7.1.100.0050.00817.33
7.1.90.0000.01715.94
7.1.80.0060.00615.92
7.1.70.0090.00916.53
7.1.60.0130.01425.73
7.1.50.0080.01625.54
7.1.40.0110.01225.37
7.1.30.0110.01325.26
7.1.20.0110.01425.31
7.1.10.0070.01016.53
7.1.00.0070.00916.55
7.0.330.0080.00315.79
7.0.320.0060.00715.73
7.0.310.0060.00615.39
7.0.300.0030.00615.47
7.0.290.0000.01115.70
7.0.280.0070.01015.46
7.0.270.0030.01015.68
7.0.260.0080.00415.52
7.0.250.0040.00815.85
7.0.240.0060.00615.48
7.0.230.0030.01015.64
7.0.220.0030.01215.39
7.0.210.0070.01015.73
7.0.200.0070.01116.12
7.0.190.0080.00816.20
7.0.180.0080.00815.98
7.0.170.0050.01116.18
7.0.160.0090.00616.06
7.0.150.0080.00916.11
7.0.140.0070.00716.19
7.0.130.0060.00716.26
7.0.120.0060.01116.29
7.0.110.0060.01016.15
7.0.100.0070.01416.03
7.0.90.0070.00916.13
7.0.80.0060.01216.26
7.0.70.0040.01016.27
7.0.60.0050.00815.76
7.0.50.0070.00816.18
7.0.40.0030.01215.21
7.0.30.0020.01215.17
7.0.20.0090.00515.20
7.0.10.0050.00815.06
7.0.00.0020.01115.17
5.6.400.0000.01214.76
5.6.390.0070.00714.57
5.6.380.0060.01214.51
5.6.370.0090.00914.43
5.6.360.0110.00314.17
5.6.350.0040.01514.55
5.6.340.0090.00614.76
5.6.330.0100.00714.59
5.6.320.0070.01014.55
5.6.310.0060.01214.69
5.6.300.0040.01414.71
5.6.290.0090.00314.64
5.6.280.0110.00414.71
5.6.270.0080.00314.71
5.6.260.0030.01014.66
5.6.250.0120.00614.54
5.6.240.0090.00614.85
5.6.230.0040.01414.65
5.6.220.0060.00314.71
5.6.210.0060.00614.59
5.6.200.0070.00714.54
5.6.190.0000.01414.59
5.6.180.0060.00914.74
5.6.170.0030.00714.59
5.6.160.0120.00314.71
5.6.150.0060.00614.36
5.6.140.0000.01314.57
5.6.130.0060.00614.59
5.6.120.0090.00314.81
5.6.110.0130.00314.76
5.6.100.0040.01214.55
5.6.90.0070.00714.83
5.6.80.0060.01014.66
5.6.70.0030.01014.27
5.6.60.0000.01114.59
5.6.50.0000.01414.75
5.6.40.0090.00614.60
5.6.30.0040.01214.45
5.6.20.0090.00614.61
5.6.10.0040.00414.42
5.6.00.0110.00014.41

preferences:
61.59 ms | 401 KiB | 5 Q