3v4l.org

run code in 300+ PHP versions simultaneously
<?php /** * Object hashing tests. */ $sos = new SplObjectStorage(); $usage = "php %s INTEGER \t - Run the SPLObjectStorage vs. Array test with INTEGER size.\n"; if (count($argv) < 2) { printf($usage, $argv[0]); exit(1); } $docs = array(); $iterations = 100000; //100000; echo "Count of DOMDocuments: {$iterations}" . PHP_EOL. PHP_EOL; 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(true); foreach ($docs as $d) { $sos->contains($d); } $finis = microtime(true); $time_to_check = $finis - $start; $mem_spl = memory_get_usage(); $mem_used = $mem_spl - $mem_empty; printf("SplObjectStorage:\nTime to fill: %0.12f. [s]\nTime to check: %0.12f. [s]\nMemory: %d [MB]\n\n", $time_to_fill, $time_to_check, $mem_used/1024/1024); unset($sos); $mem_empty = memory_get_usage(); // Test arrays: $start = microtime(TRUE); $arr = new SplFixedArray($iterations); // Load the array $_i = 0; foreach ($docs as $d) { $arr[$_i] = $d; $_i++; } $finis = microtime(TRUE); $time_to_fill = $finis - $start; // Check membership on the array $start = microtime(FALSE); $_i = 0; foreach ($docs as $d) { isset($arr[$_i]); $_i++; } $finis = microtime(FALSE); $time_to_check = $finis - $start; $mem_arr = memory_get_usage(); $mem_used = $mem_arr - $mem_empty; printf("SplFixedArray:\nTime to fill: %0.12f. [s]\nTime to check: %0.12f. [s]\nMemory: %d [MB]\n\n", $time_to_fill, $time_to_check, $mem_used/1024/1024); $mem_empty = memory_get_usage(); // Test arrays: $start = microtime(TRUE); $arr = array(); $_i =0; // Load the array foreach ($docs as $d) { $arr[$_i] = $d; $_i++; } $finis = microtime(TRUE); $time_to_fill = $finis - $start; // Check membership on the array $start = microtime(FALSE); $_i =0; foreach ($docs as $d) { isset($arr[$_i]); $_i++; } $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. [s]\nTime to check: %0.12f. [s]\nMemory: %d [MB]\n\n", $time_to_fill, $time_to_check, $mem_used/1024/1024); ?>

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.4.10.0070.01114.96
7.4.00.0100.00914.79
7.3.130.0100.00714.98
7.3.120.0100.00814.94
7.3.110.0070.01014.89
7.3.100.0080.00714.93
7.3.90.0040.00914.90
7.3.80.0060.00614.99
7.3.70.0040.01014.92
7.3.60.0040.01014.86
7.3.50.0070.00614.82
7.3.40.0040.00814.91
7.3.30.0050.00914.87
7.3.20.0090.00516.70
7.3.10.0050.00916.64
7.3.00.0050.00916.67
7.2.260.0100.01015.04
7.2.250.0100.01015.15
7.2.240.0070.01115.15
7.2.230.0050.01115.00
7.2.220.0050.00814.96
7.2.210.0030.01015.17
7.2.200.0080.00915.11
7.2.190.0080.00415.07
7.2.180.0060.01015.02
7.2.170.0050.00915.05
7.2.160.0060.00315.09
7.2.150.0120.00317.04
7.2.140.0080.00416.71
7.2.130.0050.01116.79
7.2.120.0070.00716.55
7.2.110.0030.01016.86
7.2.100.0040.00916.80
7.2.90.0080.00716.82
7.2.80.0050.01017.13
7.2.70.0030.01016.96
7.2.60.0030.00916.79
7.2.50.0080.00216.84
7.2.40.0070.00516.94
7.2.30.0040.00916.86
7.2.20.0070.00516.87
7.2.10.0030.00817.00
7.2.00.0060.00717.70
7.1.330.0090.00515.83
7.1.320.0020.00915.71
7.1.310.0090.00415.79
7.1.300.0070.00715.71
7.1.290.0070.00415.81
7.1.280.0050.00915.81
7.1.270.0060.00415.70
7.1.260.0090.00615.70
7.1.250.0110.00415.77
7.1.240.0040.01115.80
7.1.230.0070.00715.63
7.1.220.0110.00415.72
7.1.210.0000.01215.66
7.1.200.0000.01515.55
7.1.190.0030.00715.69
7.1.180.0040.00415.65
7.1.170.0000.00815.52
7.1.160.0100.00315.63
7.1.150.0000.01315.78
7.1.140.0030.00615.80
7.1.130.0100.00315.57
7.1.120.0000.01115.57
7.1.110.0040.01115.76
7.1.100.0040.01115.77
7.1.90.0060.00615.93
7.1.80.0000.01315.57
7.1.70.0040.00916.59
7.1.60.0080.01017.67
7.1.50.0090.00616.17
7.1.40.0030.01015.54
7.1.30.0030.00515.61
7.1.20.0030.01015.82
7.1.10.0060.00315.54
7.1.00.0040.04319.08
7.0.330.0070.00715.32
7.0.320.0070.01115.34
7.0.310.0030.00715.16
7.0.300.0110.00315.56
7.0.290.0030.01015.43
7.0.280.0080.00615.16
7.0.270.0040.00415.22
7.0.260.0100.00315.49
7.0.250.0070.00715.45
7.0.240.0060.00315.16
7.0.230.0040.00715.45
7.0.220.0030.00615.59
7.0.210.0040.00815.39
7.0.200.0270.00615.04
7.0.190.0070.00715.16
7.0.180.0070.01015.30
7.0.170.0060.00315.39
7.0.160.0030.00815.13
7.0.150.0060.00615.41
7.0.140.0060.03618.71
7.0.130.0030.01015.56
7.0.120.0030.00815.48
7.0.110.0060.00615.43
7.0.100.0030.01015.30
7.0.90.0070.00715.47
7.0.80.0070.00715.40
7.0.70.0070.00715.32
7.0.60.0050.00714.76
7.0.50.0250.04017.90
7.0.40.0200.03916.94
7.0.30.0100.03416.79
7.0.20.0070.03616.87
7.0.10.0110.02516.78
7.0.00.0070.03316.84
5.6.400.0120.00614.52
5.6.390.0060.00614.65
5.6.380.0090.00914.67
5.6.370.0030.01414.06
5.6.360.0030.01014.19
5.6.350.0070.01014.42
5.6.340.0000.00914.71
5.6.330.0060.00314.21
5.6.320.0000.00814.55
5.6.310.0040.00714.41
5.6.300.0030.00914.74
5.6.290.0060.00614.37
5.6.280.0020.04317.67
5.6.270.0060.00914.66
5.6.260.0090.00314.35
5.6.250.0060.00814.61
5.6.240.0000.01114.52
5.6.230.0000.01614.57
5.6.220.0070.00714.32
5.6.210.0110.04217.74
5.6.200.0070.04417.54
5.6.190.0080.04317.73
5.6.180.0100.03317.54
5.6.170.0180.03217.70
5.6.160.0090.03417.57
5.6.150.0030.03917.62
5.6.140.0120.04517.70
5.6.130.0150.03717.51
5.6.120.0100.03517.64
5.6.110.0170.03317.71
5.6.100.0100.03817.79
5.6.90.0050.03317.71
5.6.80.0100.03217.14
5.6.70.0070.03017.26
5.6.60.0000.00914.32
5.6.50.0030.00614.44
5.6.40.0060.01014.22
5.6.30.0080.00614.19
5.6.20.0110.00414.25
5.6.10.0030.01014.13
5.6.00.0060.00914.43
5.5.380.0060.00614.24
5.5.370.0070.00714.36
5.5.360.0060.00614.37
5.5.350.0150.03217.56
5.5.340.0070.03617.47
5.5.330.0080.03317.79
5.5.320.0120.03517.69
5.5.310.0030.03817.63
5.5.300.0050.03517.61
5.5.290.0080.04217.55
5.5.280.0150.02517.37
5.5.270.0100.04417.65
5.5.260.0090.03417.54
5.5.250.0090.03517.41
5.5.240.0090.03017.23
5.5.230.0080.00614.45
5.5.220.0070.00714.33
5.5.210.0100.00314.16
5.5.200.0100.00314.11
5.5.190.0030.01014.08
5.5.180.0060.00614.22
5.5.170.0000.01214.40
5.5.160.0070.00714.16
5.5.150.0090.00614.29
5.5.140.0090.00414.17
5.5.130.0030.01014.39
5.5.120.0040.01114.16
5.5.110.0040.01114.17
5.5.100.0000.01014.33
5.5.90.0030.00714.40
5.5.80.0040.01413.84
5.5.70.0070.00713.82
5.5.60.0000.01314.27
5.5.50.0100.00314.03
5.5.40.0050.00814.06
5.5.30.0110.00414.08
5.5.20.0030.01314.44
5.5.10.0120.00314.59
5.5.00.0040.01114.08
5.4.450.0090.03115.51
5.4.440.0100.02815.60
5.4.430.0050.03615.47
5.4.420.0050.03515.51
5.4.410.0120.03715.44
5.4.400.0070.03115.43
5.4.390.0110.04015.36
5.4.380.0200.03015.35
5.4.370.0170.03015.45
5.4.360.0090.03215.44
5.4.350.0050.03215.32
5.4.340.0130.02815.31
5.4.330.0040.00711.69
5.4.320.0080.03315.36
5.4.310.0100.03215.43
5.4.300.0060.03815.36
5.4.290.0100.02715.38
5.4.280.0030.04615.36
5.4.270.0020.03415.35
5.4.260.0030.03415.36
5.4.250.0160.03115.30
5.4.240.0140.02615.32
5.4.230.0080.03715.43
5.4.220.0080.03115.35
5.4.210.0060.03115.36
5.4.200.0080.04015.31
5.4.190.0100.03815.34
5.4.180.0090.02615.37
5.4.170.0110.03015.39
5.4.160.0080.03515.30
5.4.150.0090.02915.29
5.4.140.0070.02713.93
5.4.130.0040.03314.07
5.4.120.0070.02814.08
5.4.110.0020.03313.98
5.4.100.0130.02114.11
5.4.90.0050.03314.01
5.4.80.0070.02714.09
5.4.70.0030.03214.01
5.4.60.0050.03314.10
5.4.50.0020.03014.10
5.4.40.0070.03114.00
5.4.30.0080.02813.98
5.4.20.0090.02514.01
5.4.10.0080.04213.95
5.4.00.0030.02913.82
5.3.290.0100.05014.73
5.3.280.0100.05314.57
5.3.270.0070.05714.57
5.3.260.0070.05714.41
5.3.250.0130.05014.63
5.3.240.0100.06014.49
5.3.230.0000.07314.48
5.3.220.0070.05014.54
5.3.210.0070.05714.44
5.3.200.0070.07014.45
5.3.190.0170.06714.61
5.3.180.0130.05014.52
5.3.170.0170.06314.58
5.3.160.0070.05314.53
5.3.150.0100.06014.57
5.3.140.0100.05714.59
5.3.130.0070.06714.61
5.3.120.0230.04314.42
5.3.110.0030.05714.45
5.3.100.0100.05013.91
5.3.90.0100.05313.84
5.3.80.0200.05313.92
5.3.70.0030.05713.87
5.3.60.0070.05014.04
5.3.50.0100.04713.87
5.3.40.0070.05313.84
5.3.30.0100.05313.72
5.3.20.0130.04313.57
5.3.10.0070.05313.61
5.3.00.0100.07313.49
5.2.170.0100.03711.05
5.2.160.0100.04711.19
5.2.150.0000.05010.96
5.2.140.0070.06311.16
5.2.130.0100.03311.02
5.2.120.0100.03710.92
5.2.110.0100.05711.13
5.2.100.0030.06011.04
5.2.90.0070.05711.12
5.2.80.0130.05011.07
5.2.70.0070.05711.13
5.2.60.0000.05011.02
5.2.50.0030.04311.06
5.2.40.0070.04310.94
5.2.30.0030.04310.78
5.2.20.0100.04710.77
5.2.10.0000.04710.79
5.2.00.0100.05310.67
5.1.60.0000.03710.08
5.1.50.0000.03710.11
5.1.40.0070.03310.07
5.1.30.0130.03010.43
5.1.20.0100.03310.27
5.1.10.0070.03710.16
5.1.00.0030.03710.19
5.0.50.0070.0308.55
5.0.40.0000.0338.53
5.0.30.0070.0438.29
5.0.20.0100.0238.25
5.0.10.0070.0278.23
5.0.00.0100.0408.39
4.4.90.0130.0135.98
4.4.80.0100.0175.90
4.4.70.0000.0275.93
4.4.60.0030.0275.94
4.4.50.0030.0235.91
4.4.40.0070.0405.93
4.4.30.0070.0235.95
4.4.20.0070.0206.00
4.4.10.0070.0205.98
4.4.00.0030.0376.00
4.3.110.0030.0235.88
4.3.100.0000.0275.88
4.3.90.0070.0175.84
4.3.80.0030.0375.83
4.3.70.0170.0105.86
4.3.60.0130.0135.88
4.3.50.0070.0205.82
4.3.40.0000.0375.90
4.3.30.0000.0274.63
4.3.20.0000.0274.59
4.3.10.0030.0204.52
4.3.00.0030.0276.97

preferences:
33.27 ms | 400 KiB | 5 Q