3v4l.org

run code in 300+ PHP versions simultaneously
<?php $contacts = [/* a few Contact entities in there */]; // ExampleA $names = retrieve_names($contacts); $isPrimaryContact = is_primary_contact($contacts); $countries = retrieve_countries($contacts); // It is easy to provide simple functions: this makes both the calling code easy to read // and each functions, `retrieve_name` and co. easy to implement. // BUT, this comes at a cost: instead of having a O(n) operation you make it a O(3n) because // in each function you would iterate over the array once more. // ExampleB: a more performant alternative. Depending of the logic that needs to be crammed there // it can easily become a lot less readable. $names = []; $isPrimaryContact = false; $countries = []; foreach($contacts as $contact) { $names[] = $contact->name; $isPrimaryContact = $isPrimaryContact || $contact->isPrimary; $countries[] = $contact->address->country; }

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.5.30.0080.01019.20
8.5.20.0100.00820.14
8.5.10.0110.00619.41
8.5.00.0130.01020.11
8.4.180.0170.00519.81
8.4.170.0130.00920.43
8.4.160.0100.01220.55
8.4.150.0020.00114.05
8.4.140.0120.00917.73
8.4.130.0130.00918.67
8.4.120.0110.00520.49
8.4.110.0100.00720.68
8.4.100.0120.00817.66
8.4.90.0060.00620.72
8.4.80.0110.00918.91
8.4.70.0120.00818.71
8.4.60.0120.00720.75
8.4.50.0040.00520.51
8.4.40.0130.00317.51
8.4.30.0150.00324.07
8.4.20.0130.00619.55
8.4.10.0030.00519.77
8.3.300.0110.00919.13
8.3.290.0100.01020.66
8.3.280.0120.01018.36
8.3.270.0120.00716.48
8.3.260.0030.00616.54
8.3.250.0120.00716.61
8.3.240.0100.00816.63
8.3.230.0110.00516.69
8.3.220.0110.00820.86
8.3.210.0110.00916.61
8.3.200.0020.00716.63
8.3.190.0050.00320.50
8.3.180.0110.00618.84
8.3.170.0050.00317.11
8.3.160.0060.01220.71
8.3.150.0110.00717.06
8.3.140.0140.00322.49
8.3.130.0030.00516.57
8.3.120.0370.00716.27
8.3.110.0410.00316.41
8.3.100.0160.01116.66
8.3.90.0260.00916.72
8.3.80.0250.00616.43
8.3.70.0210.01116.16
8.3.60.0220.01016.78
8.3.50.0270.01016.67
8.3.40.0370.00317.25
8.3.30.0340.01017.55
8.3.20.0180.00919.10
8.3.10.0120.00617.47
8.3.00.0070.00419.38
8.2.300.0100.01020.41
8.2.290.0120.00617.11
8.2.280.0100.00919.11
8.2.270.0190.00016.57
8.2.260.0050.00316.96
8.2.250.0080.00016.58
8.2.240.0110.00716.58
8.2.230.0200.00016.37
8.2.220.0090.00218.53
8.2.210.0110.00816.49
8.2.200.0150.00416.91
8.2.190.0120.00616.95
8.2.180.0250.00716.53
8.2.170.0310.00817.75
8.2.160.0120.00717.71
8.2.150.0250.00417.11
8.2.140.0400.00717.25
8.2.130.0320.01217.46
8.2.120.0390.00417.55
8.2.110.0320.00817.31
8.2.100.0340.00017.51
8.2.90.0300.01017.56
8.2.80.0320.00917.27
8.2.70.0270.01017.52
8.2.60.0230.00017.56
8.2.50.0200.00017.44
8.2.40.0390.00017.55
8.2.30.0260.01017.40
8.2.20.0360.00317.29
8.2.10.0340.01017.36
8.2.00.0310.01317.34
8.1.340.0140.00621.79
8.1.330.0150.00316.38
8.1.320.0150.00421.88
8.1.310.0110.00718.34
8.1.300.0400.00316.17
8.1.290.0340.00015.96
8.1.280.0320.00616.11
8.1.270.0330.01317.29
8.1.260.0240.01717.10
8.1.250.0300.01217.14
8.1.240.0330.00617.13
8.1.230.0260.01317.13
8.1.220.0330.00417.27
8.1.210.0270.00617.14
8.1.200.0290.00717.19
8.1.190.0290.00716.95
8.1.180.0340.00416.74
8.1.170.0140.00517.04
8.1.160.0230.00516.86
8.1.150.0280.00516.99
8.1.140.0300.00617.08
8.1.130.0240.00617.19
8.1.120.0270.00317.30
8.1.110.0290.00716.92
8.1.100.0290.00917.11
8.1.90.0380.00016.93
8.1.80.0340.00317.19
8.1.70.0270.00317.28
8.1.60.0330.00417.15
8.1.50.0270.01317.37
8.1.40.0340.00617.14
8.1.30.0390.00817.46
8.1.20.0340.00717.47
8.1.10.0230.01617.16
8.1.00.0220.01217.29

preferences:
44.27 ms | 998 KiB | 5 Q