3v4l.org

run code in 300+ PHP versions simultaneously
<?php $input = '1|27|31|33'; $separator = '##|##'; $iterations = 100000; $time = microtime(true); for ($i = 0; $i < $iterations; $i++) { $result = str_replace('|', $separator, $input); } $time1 = microtime(true); echo 'processed with str_replace in ' . round(($time1 - $time) * 1000) . ' millisecs' . PHP_EOL; for ($i = 0; $i < $iterations; $i++) { $result = ''; $it = new CachingIterator(new ArrayIterator(explode('|', $input)), CachingIterator::FULL_CACHE); foreach ($it as $categoryId) { $result .= $categoryId; if ($it->hasNext()) { $result .= $separator; } } } $time2 = microtime(true); echo 'processed with CachingIterator in ' . round(($time2 - $time1) * 1000) . ' millisecs' . PHP_EOL;

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.1.60.0300.39733.23
7.1.50.0430.39032.99
7.1.40.0430.47332.78
7.1.30.0670.47332.90
7.1.20.0430.44332.70
7.1.10.0670.41714.73
7.1.00.0250.38718.55
7.0.200.0370.54315.06
7.0.190.0300.40314.93
7.0.180.0400.41714.42
7.0.170.0300.49014.62
7.0.160.0470.43714.40
7.0.150.0470.60014.55
7.0.140.0130.41718.46
7.0.130.0370.44014.78
7.0.120.0370.63314.61
7.0.110.0600.40714.43
7.0.100.0270.39217.22
7.0.90.0350.43217.28
7.0.80.0370.42717.20
7.0.70.0470.36217.21
7.0.60.0550.39817.04
7.0.50.0520.41517.44
7.0.40.0150.37317.39
7.0.30.0230.38817.40
7.0.20.0270.38317.21
7.0.10.0670.34517.25
7.0.00.0480.42717.30
5.6.300.0131.15021.00
5.6.290.0300.81320.81
5.6.280.0070.67520.99
5.6.270.0270.73720.92
5.6.260.0230.77020.76
5.6.250.0130.67520.68
5.6.240.0050.70220.68
5.6.230.0070.62520.77
5.6.220.0070.58820.72
5.6.210.0170.64020.77
5.6.200.0030.69320.85
5.6.190.0130.85320.93
5.6.180.0050.65820.85
5.6.170.0150.60820.86
5.6.160.0080.68020.95
5.6.150.0130.57821.04
5.6.140.0200.65820.88
5.6.130.0220.59220.96
5.6.120.0100.58820.87
5.6.110.0100.60320.84
5.6.100.0070.59021.00
5.6.90.0120.70720.86
5.6.80.0100.65220.29
5.6.70.0150.63720.26
5.6.60.0150.76820.24
5.6.50.0080.56720.29
5.6.40.0070.59520.26
5.6.30.0100.57720.31
5.6.20.0170.57320.29
5.6.10.0220.58020.22
5.6.00.0050.71720.32
5.5.380.0330.61018.97
5.5.370.0100.73818.97
5.5.360.0070.61518.88
5.5.350.0180.68518.98
5.5.340.0080.58819.44
5.5.330.0130.58319.28
5.5.320.0120.63719.29
5.5.310.0150.65819.36
5.5.300.0150.65819.31
5.5.290.0100.65819.40
5.5.280.0170.63519.40
5.5.270.0150.75019.37
5.5.260.0170.54519.49
5.5.250.0170.64319.12
5.5.240.0080.65018.79
5.5.230.0070.63518.78
5.5.220.0180.70318.76
5.5.210.0100.56518.69
5.5.200.0150.70518.77
5.5.190.0120.61318.78
5.5.180.0150.64018.57
5.5.160.0150.60018.77
5.5.150.0030.58318.60
5.5.140.0070.62318.76
5.5.130.0120.57718.75
5.5.120.0130.59718.76
5.5.110.0080.60818.74
5.5.100.0150.57718.73
5.5.90.0200.62518.64
5.5.80.0070.57218.47
5.5.70.0030.52718.64
5.5.60.0150.56018.63
5.5.50.0070.54818.57
5.5.40.0120.55718.63
5.5.30.0070.57718.53
5.5.20.0180.58818.58
5.5.10.0100.53518.59
5.5.00.0180.70018.55
5.4.450.0070.55219.36
5.4.440.0130.61719.23
5.4.430.0170.66819.43
5.4.420.0120.56219.40
5.4.410.0100.56319.28
5.4.400.0170.64818.85
5.4.390.0150.59719.02
5.4.380.0120.60819.09
5.4.370.0130.72818.97
5.4.360.0100.57818.99
5.4.350.0100.54519.06
5.4.340.0180.68818.90
5.4.320.0100.56819.05
5.4.310.0100.58719.07
5.4.300.0080.54318.94
5.4.290.0130.56219.00
5.4.280.0070.55319.00
5.4.270.0080.55219.07
5.4.260.0080.55519.08
5.4.250.0470.52019.05
5.4.240.0170.54818.83
5.4.230.0050.57818.98
5.4.220.0150.55718.85
5.4.210.0150.56218.90
5.4.200.0080.55718.99
5.4.190.0070.51318.89
5.4.180.0130.52218.92
5.4.170.0100.64019.03
5.4.160.0080.60519.01
5.4.150.0080.62219.01
5.4.140.0130.66816.41
5.4.130.0150.58316.33
5.4.120.0030.68516.44
5.4.110.0120.59016.53
5.4.100.0080.57716.47
5.4.90.0080.56516.34
5.4.80.0100.55516.45
5.4.70.0100.76816.30
5.4.60.0120.59216.23
5.4.50.0130.60816.38
5.4.40.0080.58316.49
5.4.30.0100.74816.34
5.4.20.0230.71816.46
5.4.10.0130.59816.36
5.4.00.0030.58815.72
5.3.290.0120.74814.73
5.3.280.0070.68814.62
5.3.270.0150.74314.72
5.3.260.0080.71814.71
5.3.250.0330.86714.69
5.3.240.0280.83714.57
5.3.230.0050.71214.50
5.3.220.0080.69214.67
5.3.210.0000.80514.65
5.3.200.0170.71014.56
5.3.190.0120.68314.53
5.3.180.0230.74314.62
5.3.170.0150.78314.68
5.3.160.0050.66714.63
5.3.150.0150.73814.47
5.3.140.0100.67314.60
5.3.130.0130.85314.58
5.3.120.0130.74814.54
5.3.110.0070.82014.54
5.3.100.0100.65014.23
5.3.90.0100.76014.16
5.3.80.0130.85314.25
5.3.70.0220.77714.24
5.3.60.0250.73014.12
5.3.50.0020.66514.03
5.3.40.0220.79814.17
5.3.30.0150.73014.16
5.3.20.0170.70214.05
5.3.10.0120.64514.07
5.3.00.0520.63514.06
5.2.170.0130.72012.78
5.2.160.0080.68012.87
5.2.150.0080.65512.70
5.2.140.0150.74012.85
5.2.130.0050.70812.84
5.2.120.0080.66212.76
5.2.110.0100.76312.67
5.2.100.0120.73512.92
5.2.90.0070.70712.70
5.2.80.0150.61812.70
5.2.70.0170.70012.67
5.2.60.0080.64712.88
5.2.50.0070.65812.72
5.2.40.0180.66712.71
5.2.30.0150.66312.81
5.2.20.0150.66812.84
5.2.10.0120.67812.67
5.2.00.0130.64212.52
5.1.60.0000.07312.30
5.1.50.0080.08812.40
5.1.40.0050.09312.20
5.1.30.0080.09312.47
5.1.20.0030.10012.42
5.1.10.0020.09512.27
5.1.00.0080.09512.36
5.0.50.0000.12711.60
5.0.40.0080.14311.45
5.0.30.0100.12211.27
5.0.20.0070.11211.42
5.0.10.0030.11511.33
5.0.00.0070.12011.26
4.4.90.0030.02710.14
4.4.80.0050.02710.17
4.4.70.0020.02710.14
4.4.60.0020.03010.14
4.4.50.0020.03210.14
4.4.40.0020.03810.14
4.4.30.0080.02710.14
4.4.20.0000.03010.14
4.4.10.0050.02510.14
4.4.00.0050.04310.14
4.3.110.0050.02710.14
4.3.100.0070.02310.14
4.3.90.0020.02810.14
4.3.80.0070.04510.14
4.3.70.0020.02810.14
4.3.60.0000.02710.14
4.3.50.0020.02510.14
4.3.40.0000.04010.14
4.3.30.0030.02710.14
4.3.20.0020.02810.14
4.3.10.0000.02310.14
4.3.00.0030.02810.14

preferences:
38.78 ms | 401 KiB | 5 Q