3v4l.org

run code in 300+ PHP versions simultaneously
<?php /** * Object hashing tests. */ $sos = new SplObjectStorage(); $docs = array(); $iterations = (int) 100; //100000; for ($i = 0; $i < $iterations; ++$i) { $doc = new DOMDocument(); //$doc = new stdClass(); $docs[] = $doc; } $start = $finis = 0; $mem_empty = memory_get_usage(); // Load the SplObjectStorage $start = microtime(TRUE); foreach ($docs as $d) { $sos->attach($d); } $finis = microtime(TRUE); $time_to_fill = $finis - $start; // Check membership on the object storage $start = microtime(FALSE); foreach ($docs as $d) { $sos->contains($d); } $finis = microtime(FALSE); $time_to_check = $finis - $start; $mem_spl = memory_get_usage(); $mem_used = $mem_spl - $mem_empty; printf("SplObjectStorage:\nTime to fill: %0.12f.\nTime to check: %0.12f.\nMemory: %d\n\n", $time_to_fill, $time_to_check, $mem_used); unset($sos); $mem_empty = memory_get_usage(); // Test arrays: $start = microtime(TRUE); $arr = array(); // Load the array foreach ($docs as $d) { $arr[spl_object_hash($d)] = $d; } $finis = microtime(TRUE); $time_to_fill = $finis - $start; // Check membership on the array $start = microtime(FALSE); foreach ($docs as $d) { //$arr[spl_object_hash($d)]; isset($arr[spl_object_hash($d)]); } $finis = microtime(FALSE); $time_to_check = $finis - $start; $mem_arr = memory_get_usage(); $mem_used = $mem_arr - $mem_empty; printf("Arrays:\nTime to fill: %0.12f.\nTime to check: %0.12f.\nMemory: %d\n\n", $time_to_fill, $time_to_check, $mem_used);

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.3.00.0030.00816.69
7.2.130.0040.00717.00
7.2.120.0030.00716.84
7.2.110.0080.00816.78
7.2.100.0070.00716.83
7.2.90.0060.00617.09
7.2.80.0080.00817.04
7.2.70.0090.00316.71
7.2.60.0030.01416.90
7.2.50.0040.00816.96
7.2.40.0060.00917.10
7.2.30.0030.01117.07
7.2.20.0100.00016.95
7.2.10.0080.00417.00
7.2.00.0130.00518.21
7.1.250.0000.00815.73
7.1.240.0040.00715.84
7.1.230.0060.00315.53
7.1.220.0090.00015.57
7.1.210.0000.00915.88
7.1.200.0030.00615.54
7.1.190.0050.00315.87
7.1.180.0040.00715.79
7.1.170.0040.00815.89
7.1.160.0030.00715.73
7.1.150.0060.00615.78
7.1.140.0110.00715.92
7.1.130.0030.00615.47
7.1.120.0040.01115.89
7.1.110.0000.01015.98
7.1.100.0030.01015.75
7.1.90.0040.01115.61
7.1.80.0000.01315.50
7.1.70.0020.00916.54
7.1.60.0020.01117.54
7.1.50.0050.01016.52
7.1.40.0070.00315.97
7.1.30.0030.01015.64
7.1.20.0050.00515.70
7.1.10.0060.00615.89
7.1.00.0030.03719.18
7.0.330.0030.01015.21
7.0.320.0100.00015.50
7.0.310.0030.01415.62
7.0.300.0040.00715.18
7.0.290.0040.00415.39
7.0.280.0100.00315.28
7.0.270.0110.00315.50
7.0.260.0070.00715.32
7.0.250.0110.00015.32
7.0.240.0060.00615.30
7.0.230.0080.00315.32
7.0.220.0080.00015.55
7.0.210.0070.00715.40
7.0.200.0100.00316.15
7.0.190.0030.00715.30
7.0.180.0040.01115.36
7.0.170.0000.01015.38
7.0.160.0100.00015.46
7.0.150.0060.00615.39
7.0.140.0050.03818.65
7.0.130.0080.00015.48
7.0.120.0030.00715.37
7.0.110.0030.00615.51
7.0.100.0050.04417.65
7.0.90.0050.04117.69
7.0.80.0020.04117.76
7.0.70.0110.03517.79
7.0.60.0090.04517.67
7.0.50.0070.04717.84
7.0.40.0050.04716.76
7.0.30.0060.04116.75
7.0.20.0050.04216.83
7.0.10.0060.03816.77
7.0.00.0060.02816.74
5.6.380.0030.00514.49
5.6.370.0040.01114.32
5.6.360.0000.01214.40
5.6.350.0000.01814.66
5.6.340.0060.00614.65
5.6.330.0090.00614.45
5.6.320.0030.01014.43
5.6.310.0060.00614.33
5.6.300.0160.00014.73
5.6.290.0050.00514.46
5.6.280.0050.04017.87
5.6.270.0040.00814.43
5.6.260.0150.00014.23
5.6.250.0060.02817.66
5.6.240.0060.04217.64
5.6.230.0050.04017.57
5.6.220.0080.04017.62
5.6.210.0020.04917.58
5.6.200.0120.02817.77
5.6.190.0030.04217.81
5.6.180.0080.04317.67
5.6.170.0070.04517.69
5.6.160.0080.04517.66
5.6.150.0030.04717.63
5.6.140.0040.02717.75
5.6.130.0080.03617.72
5.6.120.0040.03017.77
5.6.110.0060.02417.88
5.6.100.0070.02517.70
5.6.90.0050.02517.86
5.6.80.0070.02217.35
5.6.70.0120.03317.40
5.6.60.0100.02017.58
5.6.50.0030.03117.29
5.6.40.0060.02517.52
5.6.30.0050.02317.48
5.6.20.0020.02517.41
5.6.10.0080.02017.41
5.6.00.0060.02017.35
5.5.380.0080.03815.86
5.5.370.0030.04515.96
5.5.360.0070.04215.89
5.5.350.0030.04415.91
5.5.340.0080.03016.05
5.5.330.0080.02516.04
5.5.320.0090.04016.25
5.5.310.0100.03716.04
5.5.300.0120.03616.06
5.5.290.0060.02816.07
5.5.280.0030.02516.04
5.5.270.0070.02216.00
5.5.260.0070.02415.97
5.5.250.0050.02515.96
5.5.240.0050.03015.68
5.5.230.0060.02615.63
5.5.220.0070.01915.76
5.5.210.0030.03515.85
5.5.200.0080.02015.72
5.5.190.0050.02715.75
5.5.180.0060.02615.76
5.5.170.0000.01311.18
5.5.160.0020.02615.80
5.5.150.0070.02115.69
5.5.140.0030.02715.68
5.5.130.0070.01915.76
5.5.120.0050.02315.74
5.5.110.0100.01615.82
5.5.100.0020.02515.70
5.5.90.0040.02115.72
5.5.80.0070.04215.70
5.5.70.0030.04615.62
5.5.60.0080.03915.75
5.5.50.0050.03515.63
5.5.40.0110.03615.65
5.5.30.0050.04315.63
5.5.20.0100.03815.63
5.5.10.0020.04515.64
5.5.00.0070.04315.62
5.4.450.0050.03215.31
5.4.440.0030.02615.22
5.4.430.0020.02315.27
5.4.420.0050.02515.28
5.4.410.0020.02715.08
5.4.400.0030.03015.14
5.4.390.0020.02415.17
5.4.380.0020.02215.03
5.4.370.0030.02315.09
5.4.360.0040.02215.07
5.4.350.0020.02515.13
5.4.340.0030.02515.13
5.4.330.0040.00711.18
5.4.320.0030.02215.00
5.4.310.0050.02315.21
5.4.300.0030.02315.21
5.4.290.0050.02215.20
5.4.280.0070.01915.16
5.4.270.0100.01315.23
5.4.260.0050.03015.09
5.4.250.0020.02415.21
5.4.240.0070.03815.06
5.4.230.0050.03815.14
5.4.220.0070.04215.07
5.4.210.0100.03715.15
5.4.200.0030.04515.22
5.4.190.0120.03715.23
5.4.180.0100.03715.20
5.4.170.0100.03515.13
5.4.160.0000.04715.10
5.4.150.0050.04515.08
5.4.140.0070.03813.82
5.4.130.0080.03813.80
5.4.120.0080.03813.80
5.4.110.0110.03313.81
5.4.100.0020.04413.80
5.4.90.0070.03813.79
5.4.80.0100.03813.77
5.4.70.0060.03813.84
5.4.60.0030.04213.72
5.4.50.0070.02513.75
5.4.40.0060.03813.71
5.4.30.0060.04013.72
5.4.20.0090.03313.85
5.4.10.0070.03713.92
5.4.00.0050.03713.53
5.3.290.0040.02612.90
5.3.280.0060.04512.92
5.3.270.0050.03212.87
5.3.260.0050.03512.95
5.3.250.0030.04412.91
5.3.240.0020.04512.86
5.3.230.0080.03812.87
5.3.220.0000.04112.89
5.3.210.0030.04312.83
5.3.200.0060.03512.90
5.3.190.0020.04512.85
5.3.180.0020.04212.85
5.3.170.0100.03912.90
5.3.160.0090.03512.85
5.3.150.0060.03812.90
5.3.140.0020.03312.88
5.3.130.0070.03912.91
5.3.120.0020.04212.89
5.3.110.0120.03012.84
5.3.100.0060.04312.64
5.3.90.0030.04012.64
5.3.80.0030.04112.65
5.3.70.0000.04512.64
5.3.60.0030.04012.62
5.3.50.0050.04012.52
5.3.40.0020.04412.62
5.3.30.0070.03712.48
5.3.20.0030.02612.50
5.3.10.0030.03312.35
5.3.00.0070.04212.40
5.2.170.0040.03511.81
5.2.160.0050.03511.81
5.2.150.0050.03211.81
5.2.140.0020.02811.81
5.2.130.0050.03311.81
5.2.120.0070.03511.81
5.2.110.0050.03511.81
5.2.100.0070.03211.81
5.2.90.0070.03111.81
5.2.80.0090.02611.81
5.2.70.0030.02711.81
5.2.60.0030.03611.81
5.2.50.0080.02811.81
5.2.40.0020.03711.81
5.2.30.0050.03311.81
5.2.20.0060.03111.81
5.2.10.0030.03511.81
5.2.00.0040.02911.81
5.1.60.0030.02911.81
5.1.50.0050.02711.81
5.1.40.0050.02711.81
5.1.30.0020.03011.81
5.1.20.0050.02111.81
5.1.10.0030.02511.81
5.1.00.0030.02911.81
5.0.50.0020.02611.81
5.0.40.0050.02011.81
5.0.30.0020.03311.81
5.0.20.0030.01611.81
5.0.10.0070.02011.81
5.0.00.0060.03011.81
4.4.90.0020.02211.81
4.4.80.0020.02011.81
4.4.70.0030.01911.81
4.4.60.0020.01811.81
4.4.50.0020.01711.81
4.4.40.0030.02611.81
4.4.30.0020.01211.81
4.4.20.0040.01311.81
4.4.10.0060.01211.81
4.4.00.0020.03111.81
4.3.110.0000.01611.81
4.3.100.0020.01711.81
4.3.90.0020.01811.81
4.3.80.0000.02511.81
4.3.70.0020.01511.81
4.3.60.0020.01911.81
4.3.50.0030.01811.81
4.3.40.0020.03111.81
4.3.30.0020.01611.81
4.3.20.0000.02311.81
4.3.10.0020.02011.81
4.3.00.0000.02011.81

preferences:
41.12 ms | 401 KiB | 5 Q