3v4l.org

run code in 300+ PHP versions simultaneously
<?php $xmlstr = '<?xml version="1.0" encoding="utf-8"?> <rss version="2.0"> <Xiami> <ArtistID>179</ArtistID> <ArtistName>Band 1</ArtistName> <XiamiID>9dl4gN1c745</XiamiID> <Streaming>246</Streaming> <Fans>84</Fans> <TotalComments>1992</TotalComments> <AllSongs> <Songs> <SongID>8ILroS998dc</SongID> <SongName>Song 1</SongName> <SongComments>9223</SongComments> </Songs> <Songs> <SongID>8ILLD61a351</SongID> <SongName>Song 2</SongName> <SongComments>7221</SongComments> </Songs> <Songs> <SongID>mTnf0L5d6b9</SongID> <SongName>Song 3</SongName> <SongComments>21212</SongComments> </Songs> <Songs> <SongID>xOd2YIc7f69</SongID> <SongName>Song 4</SongName> <SongComments>422</SongComments> </Songs> <Songs> <SongID>mTmg866314c</SongID> <SongName>Song 5</SongName> <SongComments>81211</SongComments> </Songs> </AllSongs> </Xiami> </rss>'; function popular_songs($Artist) { $Songs = $Artist->xpath('//Songs'); usort($Songs, function ($a, $b) { return $b->SongComments - $a->SongComments; }); return array_slice($Songs, 0, 3); } $xml = simplexml_load_string($xmlstr); foreach($xml->children() as $Artist) { $ArtistName = $Artist->ArtistName; $Streaming = $Artist->Streaming; $Fans = $Artist->Fans; $SongsArrays = $Artist->AllSongs; $SongsCount = $Artist->AllSongs->Songs->count(); $TotalComments = array_reduce($Artist->xpath('//SongComments'), function ($c, $v) { return $c + $v; }, 0); echo $TotalComments . PHP_EOL; $PopularSongs = popular_songs($Artist); print_r($PopularSongs); }

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.10.0100.01017.11
8.5.00.0100.01020.52
8.4.160.0080.00426.07
8.4.150.0020.00014.05
8.4.140.0150.00718.09
8.4.130.0120.00918.05
8.4.120.0080.00920.84
8.4.110.0170.00419.11
8.4.100.0140.00718.41
8.4.90.0130.00720.96
8.4.80.0050.00420.98
8.4.70.0120.00721.02
8.4.60.0120.01120.87
8.4.50.0090.01120.82
8.4.40.0040.00419.64
8.4.30.0130.00620.71
8.4.20.0090.01218.98
8.4.10.0090.00918.07
8.3.280.0130.00718.84
8.3.270.0120.00916.93
8.3.260.0130.00616.69
8.3.250.0050.00319.16
8.3.240.0100.01117.17
8.3.230.0060.00317.15
8.3.220.0090.00919.48
8.3.210.0120.00717.05
8.3.200.0060.00317.04
8.3.190.0130.00619.13
8.3.180.0120.00619.28
8.3.170.0060.01217.45
8.3.160.0130.00617.19
8.3.150.0140.00717.12
8.3.140.0040.00416.98
8.3.130.0090.00017.06
8.3.120.0130.00319.23
8.3.110.0030.00620.94
8.3.100.0060.00324.06
8.3.90.0140.00426.77
8.3.80.0000.01018.68
8.3.70.0140.00717.13
8.3.60.0060.01218.80
8.3.50.0100.01019.63
8.3.40.0150.00619.07
8.3.30.0060.00819.01
8.3.20.0080.00021.02
8.3.10.0080.00022.52
8.3.00.0000.00820.99
8.2.290.0050.00417.52
8.2.280.0110.00920.51
8.2.270.0070.01117.10
8.2.260.0090.00017.55
8.2.250.0000.00817.02
8.2.240.0060.00317.50
8.2.230.0030.00622.58
8.2.220.0000.01037.54
8.2.210.0080.00026.77
8.2.200.0030.00618.88
8.2.190.0090.00617.13
8.2.180.0040.01518.64
8.2.170.0070.00722.96
8.2.160.0100.00320.85
8.2.150.0000.00824.18
8.2.140.0050.00324.66
8.2.130.0090.00026.16
8.2.120.0080.00020.39
8.2.110.0090.00020.78
8.2.100.0060.00618.34
8.2.90.0000.00818.13
8.2.80.0000.00819.41
8.2.70.0040.00418.00
8.2.60.0000.00818.30
8.2.50.0030.00518.25
8.2.40.0090.00020.32
8.2.30.0000.00818.45
8.2.20.0040.00418.63
8.2.10.0030.00519.70
8.2.00.0070.00019.63
8.1.330.0110.00916.26
8.1.320.0040.00518.40
8.1.310.0160.00017.20
8.1.300.0040.00418.93
8.1.290.0070.00330.84
8.1.280.0090.00625.92
8.1.270.0040.00424.29
8.1.260.0040.00426.35
8.1.250.0040.00428.09
8.1.240.0070.01119.30
8.1.230.0040.00818.20
8.1.220.0040.00418.15
8.1.210.0040.00418.77
8.1.200.0060.00317.98
8.1.190.0000.00817.72
8.1.180.0050.00318.10
8.1.170.0050.00319.32
8.1.160.0090.00019.30
8.1.150.0000.00819.32
8.1.140.0030.00520.65
8.1.130.0030.00320.52
8.1.120.0040.00417.86
8.1.110.0000.00817.99
8.1.100.0040.00417.82
8.1.90.0030.00517.85
8.1.80.0080.00017.96
8.1.70.0000.00717.84
8.1.60.0040.00417.81
8.1.50.0080.00018.04
8.1.40.0050.00318.03
8.1.30.0000.00918.09
8.1.20.0030.00618.14
8.1.10.0000.00817.94
8.1.00.0070.00418.04
8.0.300.0050.00518.77
8.0.290.0030.00617.25
8.0.280.0000.00718.83
8.0.270.0030.00517.25
8.0.260.0030.00320.55
8.0.250.0000.00717.32
8.0.240.0040.00417.48
8.0.230.0040.00417.32
8.0.220.0000.00717.42
8.0.210.0040.00417.33
8.0.200.0000.00817.46
8.0.190.0040.00417.49
8.0.180.0000.00817.52
8.0.170.0000.00817.36
8.0.160.0040.00417.32
8.0.150.0050.00317.41
8.0.140.0050.00517.17
8.0.130.0000.00513.69
8.0.120.0040.00417.43
8.0.110.0000.00817.38
8.0.100.0040.00417.33
8.0.90.0030.00617.39
8.0.80.0080.00817.38
8.0.70.0000.00817.32
8.0.60.0040.00417.42
8.0.50.0030.00617.46
8.0.30.0090.01217.43
8.0.20.0140.00717.64
8.0.10.0050.00317.55
8.0.00.0160.00317.19
7.4.330.0030.00317.24
7.4.320.0050.00316.96
7.4.300.0030.00316.82
7.4.290.0040.00417.02
7.4.280.0040.00417.00
7.4.270.0000.00716.86
7.4.260.0030.00313.73
7.4.250.0020.00516.79
7.4.240.0040.00416.90
7.4.230.0080.00016.84
7.4.220.0050.00217.05
7.4.210.0110.00716.90
7.4.200.0000.00717.08
7.4.130.0030.01516.93
7.4.120.0000.02116.79
7.4.110.0110.00816.84
7.4.100.0070.01416.94
7.4.90.0100.00717.19
7.4.80.0040.01819.39
7.4.70.0110.00516.94
7.4.60.0060.01016.89
7.4.50.0100.00316.97
7.4.40.0140.00317.07
7.4.00.0060.00915.23
7.3.330.0070.00016.82
7.3.320.0000.00513.38
7.3.310.0030.00316.62
7.3.300.0000.00716.59
7.3.290.0070.00016.67
7.3.280.0030.01316.68
7.3.260.0100.01216.78
7.3.240.0100.00816.76
7.3.230.0030.01316.83
7.3.210.0090.00916.79
7.3.200.0130.00316.92
7.3.190.0130.00616.84
7.3.180.0130.01016.88
7.3.170.0060.01016.85
7.3.160.0100.00716.84
7.3.120.0120.00417.15
7.3.110.0060.00617.15
7.3.100.0090.00716.08
7.3.90.0050.01015.94
7.3.80.0050.01316.24
7.3.70.0080.00516.07
7.3.60.0050.01316.06
7.3.50.0100.00716.01
7.3.40.0030.01516.11
7.3.30.0030.01316.01
7.3.20.0150.00316.15
7.3.10.0080.01016.00
7.3.00.0060.01116.06
7.2.330.0070.01117.03
7.2.320.0090.00916.97
7.2.310.0060.01217.15
7.2.300.0070.01017.16
7.2.290.0040.01517.23
7.2.240.0070.01117.15
7.2.230.0060.01116.15
7.2.220.0120.00316.17
7.2.210.0090.01016.13
7.2.200.0100.00816.13
7.2.190.0040.01216.21
7.2.180.0050.01216.18
7.2.170.0070.01016.17
7.2.160.0090.00816.27
7.2.150.0090.01016.29
7.2.140.0060.01116.31
7.2.130.0120.00516.29
7.2.120.0050.01216.22
7.2.110.0090.01116.19
7.2.100.0030.01416.16
7.2.90.0090.01516.27
7.2.80.0020.01516.21
7.2.70.0100.00716.12
7.2.60.0080.01116.27
7.2.50.0090.00916.09
7.2.40.0100.00916.29
7.2.30.0070.01016.22
7.2.20.0100.00916.21
7.2.10.0050.01216.25
7.2.00.0070.01116.19
7.1.330.0000.01417.15
7.1.320.0090.00715.63
7.1.310.0070.01015.65
7.1.300.0060.00815.65
7.1.290.0070.00915.62
7.1.280.0020.01415.72
7.1.270.0120.00415.60
7.1.260.0070.00815.54
7.1.250.0070.01015.63

preferences:
41.57 ms | 403 KiB | 5 Q