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') 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.10.0070.29115.01
7.4.00.0030.31914.88
7.3.130.0070.39115.12
7.3.120.0100.40814.83
7.3.110.0100.40015.12
7.3.100.0100.27614.99
7.3.90.0030.31714.70
7.3.80.0070.36814.79
7.3.70.0030.27814.74
7.3.60.0070.39714.87
7.3.50.0070.33514.82
7.3.40.0030.30314.84
7.3.30.0030.31314.85
7.3.20.0030.39216.85
7.3.10.0030.31916.36
7.3.00.0070.31616.64
7.2.260.0090.32415.19
7.2.250.0000.41115.32
7.2.240.0070.38814.99
7.2.230.0070.34315.29
7.2.220.0100.38814.86
7.2.210.0030.32815.27
7.2.200.0030.35815.34
7.2.190.0070.30514.97
7.2.180.0030.29615.07
7.2.170.0000.37515.26
7.2.160.0030.37314.76
7.2.150.0000.38816.91
7.2.140.0030.36716.74
7.2.130.0100.28616.98
7.2.120.0030.36716.86
7.2.110.0030.33716.77
7.2.100.0100.41417.02
7.2.90.0030.34316.86
7.2.80.0030.35717.07
7.2.70.0030.43116.88
7.2.60.0100.32916.85
7.2.50.0000.30016.94
7.2.40.0070.39616.68
7.2.30.0070.28617.09
7.2.20.0030.41516.94
7.2.10.0030.29216.97
7.2.00.0050.25718.22
7.1.330.0070.47715.82
7.1.320.0100.45915.91
7.1.310.0000.49815.68
7.1.300.0030.41515.83
7.1.290.0100.39615.75
7.1.280.0030.47015.84
7.1.270.0100.44215.63
7.1.260.0030.42115.79
7.1.250.0070.43915.72
7.1.240.0030.40615.60
7.1.230.0030.50115.84
7.1.220.0000.41915.81
7.1.210.0070.46015.90
7.1.200.0070.40115.82
7.1.190.0030.42915.91
7.1.180.0000.48415.76
7.1.170.0030.50615.57
7.1.160.0070.43215.79
7.1.150.0030.47415.76
7.1.140.0070.49715.75
7.1.130.0030.44415.91
7.1.120.0070.41515.73
7.1.110.0030.40415.95
7.1.100.0000.46115.99
7.1.90.0000.38915.94
7.1.80.0030.51115.89
7.1.70.0250.29516.46
7.1.60.0080.34817.36
7.1.50.0000.28516.23
7.1.40.0000.50415.86
7.1.30.0100.46915.70
7.1.20.0000.49615.60
7.1.10.0030.45515.74
7.1.00.0050.40219.13
7.0.330.0070.38515.41
7.0.320.0070.46715.46
7.0.310.0000.43015.22
7.0.300.0000.39415.24
7.0.290.0000.48615.18
7.0.280.0030.36915.56
7.0.270.0030.38515.31
7.0.260.0070.42315.26
7.0.250.0030.44515.27
7.0.240.0000.39715.40
7.0.230.0050.50515.55
7.0.220.0030.39015.35
7.0.210.0130.39215.54
7.0.200.0180.26215.00
7.0.190.0070.48415.55
7.0.180.0030.49815.61
7.0.170.0030.40015.43
7.0.160.0000.44515.26
7.0.150.0070.40615.43
7.0.140.0020.33218.76
7.0.130.0000.42415.51
7.0.120.0070.39815.59
7.0.110.0030.47515.43
7.0.100.0070.33717.89
7.0.90.0080.33417.55
7.0.80.0050.35617.69
7.0.70.0050.35617.61
7.0.60.0070.31517.60
7.0.50.0080.36317.85
7.0.40.0080.32216.72
7.0.30.0100.35816.87
7.0.20.0080.34116.68
7.0.10.0030.32516.81
7.0.00.0070.31316.62
5.6.400.0030.94214.52
5.6.390.0070.98514.30
5.6.380.0071.10614.18
5.6.370.0001.04614.45
5.6.360.0031.03514.46
5.6.350.0000.94914.68
5.6.340.0070.93414.60
5.6.330.0030.94414.54
5.6.320.0130.99614.18
5.6.310.0030.93414.52
5.6.300.0031.01614.29
5.6.290.0030.98014.11
5.6.280.0080.80717.83
5.6.270.0030.96914.50
5.6.260.0001.10514.56
5.6.250.0070.83517.53
5.6.240.0120.69917.53
5.6.230.0080.74417.52
5.6.220.0100.72117.44
5.6.210.0080.75617.38
5.6.200.0030.77817.76
5.6.190.0030.80117.73
5.6.180.0070.76817.59
5.6.170.0100.74717.66
5.6.160.0050.83917.94
5.6.150.0030.82617.71
5.6.140.0080.75017.84
5.6.130.0080.79617.58
5.6.120.0070.78817.65
5.6.110.0080.82717.82
5.6.100.0020.66417.83
5.6.90.0070.66817.71
5.6.80.0030.68517.33
5.6.70.0120.70417.46
5.6.60.0100.76617.29
5.6.50.0150.82317.42
5.6.40.0070.78017.46
5.6.30.0030.77017.51
5.6.20.0030.81917.31
5.6.10.0050.72417.32
5.6.00.0120.74917.27
5.5.380.0070.80817.23
5.5.370.0030.81117.38
5.5.360.0080.77717.29
5.5.350.0020.75917.39
5.5.340.0100.75517.51
5.5.330.0120.82217.57
5.5.320.0100.76217.66
5.5.310.0030.82417.52
5.5.300.0050.72217.45
5.5.290.0080.69417.57
5.5.280.0050.82217.55
5.5.270.0090.85017.64
5.5.260.0040.74017.37
5.5.250.0050.75517.36
5.5.240.0100.72917.27
5.5.230.0020.81217.14
5.5.220.0050.84517.41
5.5.210.0050.76417.29
5.5.200.0030.82517.14
5.5.190.0140.84616.99
5.5.180.0050.84917.31
5.5.170.0030.91214.28
5.5.160.0030.81217.00
5.5.150.0070.83717.18
5.5.140.0080.75217.27
5.5.130.0450.79017.17
5.5.120.0050.72217.15
5.5.110.0120.76717.25
5.5.100.0030.74717.10
5.5.90.0080.78417.17
5.5.80.0150.76917.16
5.5.70.0100.78317.21
5.5.60.0140.76717.13
5.5.50.0080.72117.13
5.5.40.0020.75017.18
5.5.30.0080.75217.15
5.5.20.0120.77717.12
5.5.10.0110.77517.16
5.5.00.0080.81617.30
5.4.450.0020.78715.18
5.4.440.0030.81215.19
5.4.430.0000.82015.04
5.4.420.0180.78415.24
5.4.410.0080.80615.14
5.4.400.0050.75514.94
5.4.390.0030.76915.13
5.4.380.0020.71315.02
5.4.370.0020.74115.00
5.4.360.0070.84515.15
5.4.350.0050.85915.05
5.4.340.0080.80115.01
5.4.330.0031.03611.07
5.4.320.0000.86215.09
5.4.310.0050.73215.03
5.4.300.0070.81915.24
5.4.290.0140.84315.13
5.4.280.0070.79915.04
5.4.270.0060.83114.94
5.4.260.0030.84615.00
5.4.250.0070.84715.12
5.4.240.0070.78915.02
5.4.230.0070.87214.96
5.4.220.0030.86714.93
5.4.210.0080.73915.01
5.4.200.0000.78015.09
5.4.190.0160.75615.11
5.4.180.0080.89315.06
5.4.170.0070.83214.97
5.4.160.0020.83315.04
5.4.150.0010.86515.02
5.4.140.0090.77713.76
5.4.130.0070.79313.85
5.4.120.0070.84413.86
5.4.110.0080.69713.71
5.4.100.0020.78613.82
5.4.90.0070.79913.83
5.4.80.0060.84313.72
5.4.70.0050.81413.76
5.4.60.0040.73113.58
5.4.50.0080.78613.79
5.4.40.0020.78313.63
5.4.30.0180.79913.76
5.4.20.0070.71013.73
5.4.10.0050.77813.75
5.4.00.0020.81313.57
5.3.290.0070.90812.78
5.3.280.0021.04712.68
5.3.270.0020.89112.73
5.3.260.0081.02812.75
5.3.250.0050.90712.73
5.3.240.0020.89412.71
5.3.230.0050.97212.68
5.3.220.0081.00612.70
5.3.210.0050.89212.69
5.3.200.0071.00512.66
5.3.190.0051.00412.68
5.3.180.0071.02812.72
5.3.170.0051.01912.76
5.3.160.0070.90612.67
5.3.150.0070.90612.77
5.3.140.0020.93312.76
5.3.130.0071.05012.72
5.3.120.0051.03812.72
5.3.110.0050.97912.67
5.3.100.0020.91612.40
5.3.90.0030.83312.47
5.3.80.0080.90212.37
5.3.70.0071.05012.43
5.3.60.0030.89312.45
5.3.50.0000.81412.43
5.3.40.0120.92012.44
5.3.30.0080.89212.33
5.3.20.0050.86312.22
5.3.10.0020.90612.21
5.3.00.0030.87512.18
5.2.170.0070.73011.08
5.2.160.0070.73711.21
5.2.150.0030.83311.04
5.2.140.0100.78711.20
5.2.130.0030.74311.03
5.2.120.0000.83011.04
5.2.110.0100.87310.99
5.2.100.0030.71711.00
5.2.90.0100.84011.16
5.2.80.0070.76311.15
5.2.70.0030.90311.17
5.2.60.0070.80311.08
5.2.50.0100.78711.12
5.2.40.0030.82310.93
5.2.30.0000.83711.07
5.2.20.0070.80311.00
5.2.10.0030.81710.90
5.2.00.0000.76710.68
5.1.60.0030.78710.11
5.1.50.0000.64710.01
5.1.40.0070.78710.02
5.1.30.0100.80010.25
5.1.20.0030.82310.29
5.1.10.0630.79310.07
5.1.00.0030.82710.20
5.0.50.0071.3508.66
5.0.40.0071.2378.55
5.0.30.1301.2808.25
5.0.20.0230.0337.92
5.0.10.0030.0377.95
5.0.00.0100.0637.95
4.4.90.0031.3708.24
4.4.80.0001.1578.24
4.4.70.0101.3038.24
4.4.60.0071.3308.24
4.4.50.0001.3108.24
4.4.40.0071.2578.24
4.4.30.0001.3408.24
4.4.20.0001.2638.24
4.4.10.0031.2738.24
4.4.00.0001.3108.24
4.3.110.0001.2438.24
4.3.100.0031.3338.24
4.3.90.0071.2938.30
4.3.80.0001.4278.70
4.3.70.0031.3508.70
4.3.60.0001.3138.70
4.3.50.0001.3308.70
4.3.40.0001.4308.70
4.3.30.0031.3108.70
4.3.20.0030.0374.28
4.3.10.0030.0434.30
4.3.00.0070.0434.30

preferences:
40.24 ms | 401 KiB | 5 Q