3v4l.org

run code in 300+ PHP versions simultaneously
<?php function strpose_simple($haystack, $needle, $index = 0) { $hlen = strlen($haystack); $nlen = strlen($needle); do { $pos = strpos($haystack, $needle, $index); if ($pos !== false) { $end = $pos+$nlen; if (!isset($haystack[$pos-1]) || !trim($haystack[$pos-1])) { if (!isset($haystack[$end]) || !trim($haystack[$end])) { return $pos; } else $index = $pos+1; } else $index = $pos+1; } } while ($pos !== false && $pos < $hlen); return $pos; } function strpose_slow($haystack, $needle, $offset = 0) { $found = preg_match( '(\b(?:'.preg_quote($needle).')\b)Su', $haystack, $match, PREG_OFFSET_CAPTURE, $offset ); return ($found) ? $match[0][1] : FALSE; } $haystack = "Hello World"; $needles = array( "ll", "Hello", "Worlds" ); foreach (array('strpose_simple', 'strpose_slow') as $function) { $begin = 0; $end = 200000; $start = microtime(true); while ($begin++<$end) { foreach ($needles as $id => $needle) { $function($haystack, $needle); } } printf("%s: %.4f seconds/%d peak\n", $function, microtime(true)-$start, memory_get_usage(true)); }

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.00.0130.89915.28
7.3.120.0100.89315.08
7.3.110.0070.88414.96
7.3.100.0030.90715.05
7.3.90.0000.81415.09
7.3.80.0030.87214.82
7.3.70.0030.88214.95
7.3.60.0030.87815.05
7.3.50.0070.85114.84
7.3.40.0070.88315.01
7.3.30.0030.75815.05
7.3.20.0030.75916.76
7.3.10.0100.77316.72
7.3.00.0050.67616.64
7.2.250.0070.72115.36
7.2.240.0060.97115.32
7.2.230.0030.70215.30
7.2.220.0130.90915.17
7.2.210.0030.91615.47
7.2.200.0070.70915.45
7.2.190.0000.82315.29
7.2.180.0070.87515.34
7.2.170.0030.79915.13
7.2.160.0100.81715.30
7.2.150.0030.82117.14
7.2.140.0000.87017.19
7.2.130.0070.85217.14
7.2.120.0080.84216.98
7.2.110.0100.74417.05
7.2.100.0130.85916.97
7.2.90.0050.80217.10
7.2.80.0080.69317.20
7.2.70.0100.74117.14
7.2.60.0070.81517.13
7.2.50.0050.75017.13
7.2.40.0000.74917.15
7.2.30.0100.86717.05
7.2.20.0030.85117.13
7.2.10.0120.77217.20
7.2.00.0070.66218.06
7.1.330.0000.96016.01
7.1.320.0030.96816.05
7.1.310.0071.02016.13
7.1.300.0131.17916.05
7.1.290.0030.89315.91
7.1.280.0071.16015.63
7.1.270.0031.01716.01
7.1.260.0071.26815.85
7.1.250.0030.97616.00
7.1.240.0001.01215.96
7.1.230.0001.21915.99
7.1.220.0031.00416.13
7.1.210.0101.22915.99
7.1.200.0000.94616.13
7.1.190.0030.99215.78
7.1.180.0031.22015.96
7.1.170.0031.07915.96
7.1.160.0131.04616.06
7.1.150.0000.94115.93
7.1.140.0071.01615.82
7.1.130.0001.23615.91
7.1.120.0030.93216.15
7.1.110.0001.24715.92
7.1.100.0071.18215.85
7.1.90.0001.20916.10
7.1.80.0001.02916.02
7.1.70.0150.78316.64
7.1.60.0080.84717.62
7.1.50.0020.80016.59
7.1.40.0031.23516.09
7.1.30.0031.17916.05
7.1.20.0130.93515.71
7.1.10.0000.97015.96
7.1.00.0070.77619.23
7.0.330.0031.15115.75
7.0.320.0000.86815.77
7.0.310.0031.20815.67
7.0.300.0031.18515.67
7.0.290.0061.20615.69
7.0.280.0001.11215.54
7.0.270.0030.99315.62
7.0.260.0071.10315.41
7.0.250.0001.19615.77
7.0.240.0030.95515.43
7.0.230.0071.08615.44
7.0.220.0071.23015.60
7.0.210.0031.25215.82
7.0.200.0030.70916.29
7.0.190.0001.19115.41
7.0.180.0031.24515.66
7.0.170.0071.18015.63
7.0.160.0000.96315.43
7.0.150.0100.95215.71
7.0.140.0050.94118.91
7.0.130.0031.11515.74
7.0.120.0000.87915.72
7.0.110.0001.22115.45
7.0.100.0070.82817.78
7.0.90.0030.81917.83
7.0.80.0030.77617.64
7.0.70.0170.71517.82
7.0.60.0280.87617.57
7.0.50.0250.80218.04
7.0.40.0030.82416.92
7.0.30.0050.89816.80
7.0.20.0030.76716.98
7.0.10.0080.89916.89
7.0.00.0070.77516.81
5.6.400.0072.49214.79
5.6.390.0102.47514.65
5.6.380.0032.41714.60
5.6.370.0072.04514.67
5.6.360.0032.35114.37
5.6.350.0072.33414.83
5.6.340.0072.24314.71
5.6.330.0102.26414.37
5.6.320.0032.33814.49
5.6.310.0002.33514.53
5.6.300.0032.19314.73
5.6.290.0002.28514.40
5.6.280.0032.49614.57
5.6.270.0102.12314.44
5.6.260.0072.49214.68
5.6.250.0071.76117.66
5.6.240.0081.78917.61
5.6.230.0061.67717.66
5.6.220.0071.58317.58
5.6.210.0051.65817.60
5.6.200.0071.66317.78
5.6.190.0051.78317.83
5.6.180.0071.58617.79
5.6.170.0071.77117.82
5.6.160.0081.78017.67
5.6.150.0081.81517.71
5.6.140.0121.76517.84
5.6.130.0071.86317.86
5.6.120.0101.69117.89
5.6.110.0071.77817.77
5.6.100.0051.81117.99
5.6.90.0101.76417.79
5.6.80.0051.76717.32
5.6.70.0101.64417.39
5.6.60.0021.84817.44
5.6.50.0081.68817.47
5.6.40.0031.70117.45
5.6.30.0021.78317.39
5.6.20.0071.78317.40
5.6.10.0071.46817.28
5.6.00.0071.75417.28
5.5.380.0071.57817.43
5.5.370.0021.66917.58
5.5.360.0001.76417.41
5.5.350.0031.79217.42
5.5.340.0031.63917.73
5.5.330.0051.58717.70
5.5.320.0051.79417.80
5.5.310.0021.60817.76
5.5.300.0021.61517.53
5.5.290.0031.56017.59
5.5.280.0071.76717.65
5.5.270.0031.55717.72
5.5.260.0051.58217.72
5.5.250.0021.79117.41
5.5.240.0031.69617.27
5.5.230.0081.75317.20
5.5.220.0181.62517.25
5.5.210.0031.68817.36
5.5.200.0031.42517.23
5.5.190.0121.77417.24
5.5.180.0051.77317.30
5.5.170.0032.49514.23
5.5.160.0101.77617.17
5.5.150.0021.68417.37
5.5.140.0051.63517.39
5.5.130.0051.74617.31
5.5.120.0051.78117.15
5.5.110.0081.84617.36
5.5.100.0101.48717.19
5.5.90.0081.84917.27
5.5.80.0081.78417.20
5.5.70.0081.63017.20
5.5.60.0121.65117.31
5.5.50.0121.78817.24
5.5.40.0021.68217.21
5.5.30.0051.78417.38
5.5.20.0101.56617.19
5.5.10.0021.77417.26
5.5.00.0081.78317.02
5.4.450.0101.54515.38
5.4.440.0131.78915.48
5.4.430.0021.77915.27
5.4.420.0021.68115.16
5.4.410.0101.56915.17
5.4.400.0021.54115.06
5.4.390.0081.61114.90
5.4.380.0081.77015.03
5.4.370.0031.74915.05
5.4.360.0041.53015.09
5.4.350.0021.63615.04
5.4.340.0031.63815.16
5.4.330.0002.31511.25
5.4.320.0051.69515.16
5.4.310.0051.60415.15
5.4.300.0081.52015.14
5.4.290.0051.76515.13
5.4.280.0071.60415.20
5.4.270.0081.78815.13
5.4.260.0101.77214.99
5.4.250.0071.58215.09
5.4.240.0081.79815.29
5.4.230.0101.87215.08
5.4.220.0051.76115.03
5.4.210.0031.75915.10
5.4.200.0081.63215.19
5.4.190.0031.77715.06
5.4.180.0051.59915.17
5.4.170.0031.72115.00
5.4.160.0021.71315.14
5.4.150.0071.65115.29
5.4.140.0031.75013.73
5.4.130.0021.71913.85
5.4.120.0031.56413.82
5.4.110.0001.66613.75
5.4.100.0051.60813.81
5.4.90.0031.72913.80
5.4.80.0031.81313.89
5.4.70.0101.71613.87
5.4.60.0051.80613.66
5.4.50.0081.79113.67
5.4.40.0051.59113.82
5.4.30.0051.76413.93
5.4.20.0051.80413.84
5.4.10.0051.79813.79
5.4.00.0731.82813.59
5.3.290.0051.82612.62
5.3.280.0081.80412.52
5.3.270.0071.83012.57
5.3.260.0051.74112.64
5.3.250.0031.76112.49
5.3.240.0051.77912.54
5.3.230.0021.77712.43
5.3.220.0031.85812.48
5.3.210.0081.81212.61
5.3.200.0051.87412.46
5.3.190.0081.83112.62
5.3.180.0031.84612.52
5.3.170.0031.84812.61
5.3.160.0101.87012.64
5.3.150.0051.87712.71
5.3.140.0081.85312.57
5.3.130.0051.85912.53
5.3.120.0101.84112.60
5.3.110.0051.86612.69
5.3.100.0021.83012.16
5.3.90.0081.76912.34
5.3.80.0051.84312.26
5.3.70.0031.83012.05
5.3.60.0071.82812.25
5.3.50.0051.87012.28
5.3.40.0031.87012.25
5.3.30.0081.83912.08
5.3.20.0551.81312.03
5.3.10.0071.73411.98
5.3.00.0051.67611.90
5.2.170.0031.46011.06
5.2.160.0031.52011.01
5.2.150.0071.52311.29
5.2.140.0031.47011.13
5.2.130.0031.45711.18
5.2.120.0101.35711.16
5.2.110.0001.53311.18
5.2.100.0131.42011.04
5.2.90.0001.27711.23
5.2.80.0031.33011.17
5.2.70.0031.32311.04
5.2.60.0001.49310.93
5.2.50.0131.49011.15
5.2.40.0031.30711.02
5.2.30.0031.48010.99
5.2.20.0101.49011.00
5.2.10.0031.51310.94
5.2.00.0030.72710.60
5.1.60.0070.79010.18
5.1.50.0030.68710.18
5.1.40.0100.78310.18
5.1.30.0000.80310.36
5.1.20.0030.82710.28
5.1.10.0030.81010.18
5.1.00.0130.80310.18
5.0.50.0031.32010.18
5.0.40.0031.32010.18
5.0.30.0031.34010.18
5.0.20.0000.05310.18
5.0.10.0030.05010.18
5.0.00.0000.07710.18
4.4.90.0031.30310.18
4.4.80.0031.29710.18
4.4.70.0001.29710.18
4.4.60.0001.09710.18
4.4.50.0071.23710.18
4.4.40.0001.33010.18
4.4.30.0031.29710.18
4.4.20.0031.38310.18
4.4.10.0001.33010.18
4.4.00.0031.27710.18
4.3.110.0001.30710.18
4.3.100.0001.20010.18
4.3.90.0031.37310.18
4.3.80.0001.49310.18
4.3.70.0001.32310.18
4.3.60.0031.23310.18
4.3.50.0001.26310.18
4.3.40.0001.16310.18
4.3.30.0001.23710.18
4.3.20.0000.04310.18
4.3.10.0000.03010.18
4.3.00.0000.04010.32

preferences:
32.35 ms | 401 KiB | 5 Q