3v4l.org

run code in 300+ PHP versions simultaneously
<?php function generateRandomString($length = 10) { $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; $randomString = ''; for ($i = 0; $i < $length; $i++) { $randomString .= $characters[rand(0, strlen($characters) - 1)]; } return $randomString; } class obj { public $items = array(); public $data; } function subobj($obj, $depth=5) { for($i = 0; $i < 5; $i++) { $obj->items[$i] = new obj; $obj->items[$i]->data = generateRandomString(64); if($depth>1) subobj($obj->items[$i], $depth-1); } } print "Populating object..."; $obj = new obj; for($i = 0; $i < 10; $i++) { subobj($obj); } print "\nSerializing..."; $data = serialize($obj); print "\nLooping...\n"; $iterations = 20000; while($iterations--) { $newstr = unserialize($data); if($iterations % 1000 == 0) print "$iterations: " . sprintf('%0.2f', memory_get_usage()/1024/1024) . "Mb\n"; }

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)
7.0.60.0032.49728.73
7.0.50.0172.48326.57
7.0.40.0102.49020.19
7.0.30.0302.47020.11
7.0.20.0302.47020.30
7.0.10.0232.47720.11
7.0.00.0072.49320.11
5.6.210.0172.48332.77
5.6.200.0132.48730.33
5.6.190.0172.46732.70
5.6.180.3872.11332.57
5.6.170.0302.47032.48
5.6.160.0002.50032.56
5.6.150.0102.49030.36
5.6.140.0072.49330.29
5.6.130.0032.49730.36
5.6.120.0172.48332.38
5.6.110.0132.48732.32
5.6.100.0202.48032.34
5.6.90.0032.49732.33
5.6.80.0132.48731.72
5.5.350.0472.45332.61
5.5.340.0132.48730.17
5.5.330.0172.48332.37
5.5.320.0072.49332.46
5.5.310.0232.47732.43
5.5.300.0132.48730.15
5.5.290.0102.49030.13
5.5.280.0072.49332.13
5.5.270.0172.48332.15
5.5.260.0132.48732.13
5.5.250.0132.48731.94
5.5.240.0172.48331.62
5.4.450.0672.43031.70
5.4.440.0272.47030.41
5.4.430.0772.39030.57
5.4.422.4930.00030.54
5.4.412.4830.00030.59
5.4.402.1430.00030.40
5.4.392.4530.00030.23
5.4.382.2870.00030.07
5.4.372.1900.00030.18
5.4.362.3470.00030.09
5.4.352.4000.00029.93
5.4.340.0211.98223.07
5.4.320.0151.99423.56
5.4.310.0171.99123.55
5.4.300.0262.04423.56
5.4.290.0241.99623.55
5.4.280.0271.97823.45
5.4.270.0371.98123.45
5.4.260.0211.98823.45
5.4.250.0121.99523.45
5.4.240.0351.96923.45
5.4.230.0291.98123.45
5.4.220.0501.95223.46
5.4.210.0561.96823.44
5.4.200.0331.97523.44
5.4.190.0271.97723.43
5.4.180.0461.96023.43
5.4.170.0571.94923.43
5.4.160.0401.97123.43
5.4.150.0232.01823.43
5.4.140.0421.96223.11
5.4.130.0211.98423.10
5.4.120.0140.37313.91
5.4.110.0601.94123.05
5.4.100.0511.95423.05
5.4.90.0171.98423.06
5.4.80.0261.97823.07
5.4.70.0521.96223.06
5.4.60.0581.95223.06
5.4.50.0262.00323.06
5.4.40.0191.99823.05
5.4.30.0221.99323.05
5.4.20.0361.97123.05
5.4.10.0181.98623.05
5.4.00.0401.97222.54

preferences:
27.46 ms | 401 KiB | 5 Q