3v4l.org

run code in 300+ PHP versions simultaneously
<?php $source = <<<SOURCEND This is a test {% block hello %} This is a test This is a {{ \$test }} {% end block %} {{ block('hello') }} {% for \$post in \$posts %} {% end %} SOURCEND; function microtwig_compile($source){ function microtwig_parsecmd($cmd){ static $stack = array(); $fragments = preg_split('/\s+/',$cmd); $cmd = array_shift($fragments); switch($cmd){ case 'block': return 'function block_'.$fragments[0].'(){'; break; case 'if': $stack[] = 'if'; return 'if('.$fragments[2].' as '.$fragments[0].'):'; break; case 'for': $stack[] = 'foreach'; return 'foreach('.$fragments[2].' as '.$fragments[0].'):'; break; case 'end': switch(isset($fragments[0])?$fragments[0]:''){ case 'block': return '}'; break; default: switch($peek = array_pop($stack)){ case 'if': return 'endif;'; break; case 'foreach': return 'endforeach;'; break; } break; } break; default: break; } } $cnt=0; $fragments = array(); $source = str_replace(array('{{','}}'),array('<?php echo','?>'),$source); foreach(explode('{%',$source) as $tmp) { foreach(explode('%}',$tmp) as $item) { $fragments[] = $cnt++%2?'<?php '.microtwig_parsecmd(trim($item)).'?>':$item; } } return implode('',$fragments); } echo microtwig_compile($source);

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)
8.3.40.0090.00919.09
8.3.30.0070.00719.06
8.3.20.0080.00020.34
8.3.10.0080.00022.23
8.3.00.0000.00822.39
8.2.170.0060.00922.96
8.2.160.0000.01420.98
8.2.150.0080.00024.18
8.2.140.0030.00624.66
8.2.130.0000.00826.16
8.2.120.0090.00019.47
8.2.110.0060.00321.97
8.2.100.0080.00419.70
8.2.90.0040.00419.17
8.2.80.0050.00317.97
8.2.70.0000.00917.75
8.2.60.0040.00418.05
8.2.50.0030.00518.07
8.2.40.0040.00418.16
8.2.30.0040.00418.10
8.2.20.0050.00317.92
8.2.10.0040.00419.66
8.2.00.0030.00518.00
8.1.270.0060.00322.31
8.1.260.0080.00026.35
8.1.250.0040.00428.09
8.1.240.0030.00623.82
8.1.230.0110.00019.22
8.1.220.0050.00317.79
8.1.210.0060.00318.77
8.1.200.0000.01017.47
8.1.190.0040.00417.64
8.1.180.0060.00318.65
8.1.170.0030.00518.84
8.1.160.0040.00422.08
8.1.150.0070.00018.77
8.1.140.0000.00717.65
8.1.130.0030.00317.86
8.1.120.0040.00417.52
8.1.110.0040.00417.54
8.1.100.0040.00417.72
8.1.90.0030.00417.68
8.1.80.0070.00017.56
8.1.70.0070.00017.61
8.1.60.0000.00817.79
8.1.50.0060.00317.71
8.1.40.0000.00817.68
8.1.30.0030.00617.85
8.1.20.0000.00817.79
8.1.10.0030.00617.62
8.1.00.0080.00017.71
8.0.300.0000.00719.15
8.0.290.0000.00717.05
8.0.280.0000.00718.47
8.0.270.0030.00517.32
8.0.260.0060.00317.07
8.0.250.0000.00717.14
8.0.240.0000.00817.14
8.0.230.0030.00317.22
8.0.220.0080.00017.04
8.0.210.0000.00717.09
8.0.200.0030.00517.06
8.0.190.0060.00417.17
8.0.180.0040.00417.14
8.0.170.0000.00717.14
8.0.160.0040.00417.08
8.0.150.0040.00417.18
8.0.140.0050.00316.99
8.0.130.0060.00013.59
8.0.120.0000.00817.11
8.0.110.0000.00817.13
8.0.100.0050.00316.93
8.0.90.0070.00017.16
8.0.80.0140.00617.11
8.0.70.0040.00417.25
8.0.60.0000.00717.25
8.0.50.0040.00416.93
8.0.30.0130.00517.41
8.0.20.0090.00917.54
8.0.10.0050.00217.33
8.0.00.0130.00716.90
7.4.330.0000.00515.09
7.4.320.0000.00716.76
7.4.300.0070.00016.66
7.4.290.0000.00816.66
7.4.280.0050.00316.64
7.4.270.0000.00716.73
7.4.260.0000.00716.73
7.4.250.0000.00816.86
7.4.240.0020.00516.79
7.4.230.0040.00416.88
7.4.220.0100.00716.68
7.4.210.0060.00816.81
7.4.200.0070.00016.86
7.4.190.0070.00016.71
7.4.160.0100.00516.86
7.4.150.0080.01017.40
7.4.140.0050.01417.86
7.4.130.0090.01116.81
7.4.120.0060.01116.87
7.4.110.0100.00716.79
7.4.100.0060.01216.73
7.4.90.0160.00316.66
7.4.80.0190.00319.39
7.4.70.0100.00616.96
7.4.60.0160.00316.98
7.4.50.0090.00016.55
7.4.40.0070.01022.77
7.4.30.0100.00616.68
7.4.00.0000.01415.30
7.3.330.0030.00313.57
7.3.320.0030.00313.61
7.3.310.0070.00016.65
7.3.300.0070.00016.45
7.3.290.0110.00316.50
7.3.280.0070.01016.55
7.3.270.0170.00017.40
7.3.260.0070.01016.74
7.3.250.0080.00916.60
7.3.240.0070.01416.71
7.3.230.0100.01016.64
7.3.210.0080.00816.53
7.3.200.0130.00319.39
7.3.190.0090.00916.64
7.3.180.0100.00716.67
7.3.170.0070.01016.68
7.3.160.0120.00416.70
7.3.120.0060.01014.75
7.2.330.0100.01916.79
7.2.320.0080.00816.98
7.2.310.0100.01316.83
7.2.300.0100.01017.00
7.2.290.0090.00916.97
7.2.00.0000.01419.43
7.1.100.0030.00918.15
7.1.70.0000.00717.54
7.1.60.0090.01519.82
7.1.50.0170.01734.76
7.1.00.0030.07722.47
7.0.200.0000.01016.98
7.0.140.0030.07722.13
7.0.60.0100.08319.96
7.0.50.0070.03718.03
7.0.40.0100.08320.11
7.0.30.0230.08720.23
7.0.20.0300.08020.11
7.0.10.0270.09020.07
7.0.00.0030.05720.24
5.6.280.0030.07320.84
5.6.210.0070.05020.48
5.6.200.0030.08318.24
5.6.190.0030.04720.46
5.6.180.3800.04020.77
5.6.170.0200.06320.47
5.6.160.0100.03720.43
5.6.150.0130.07318.15
5.6.140.0170.07718.18
5.6.130.0130.07018.15
5.6.120.0000.04721.00
5.6.110.0200.07021.00
5.6.100.0030.08321.15
5.6.90.0100.07321.02
5.6.80.0100.06320.40
5.6.70.0330.05320.55
5.5.350.0030.04020.46
5.5.340.0070.08317.97
5.5.330.0100.08720.47
5.5.320.0300.05020.27
5.5.310.0170.04320.35
5.5.300.0100.05317.97
5.5.290.0070.07017.99
5.5.280.0100.05720.87
5.5.270.0130.07720.66
5.5.260.0170.07020.78
5.5.250.0070.07320.66
5.5.240.0000.08320.28
5.4.450.0530.06019.55
5.4.440.0900.06719.58
5.4.430.0470.06019.63
5.4.420.0670.06019.57
5.4.410.0600.04719.57
5.4.400.0870.00018.86
5.4.390.0900.00018.84
5.4.380.0270.05318.52
5.4.370.0300.04718.79
5.4.360.0670.06018.78
5.4.350.0130.06318.75
5.4.340.0370.04318.49
5.4.320.0080.04212.52
5.4.310.0100.03612.52
5.4.300.0060.04212.52
5.4.290.0080.03912.52
5.4.280.0060.03512.41
5.4.270.0070.04012.42
5.4.260.0070.05318.80
5.4.250.0100.05018.79
5.4.240.0130.04318.79
5.4.230.0000.05718.85
5.4.220.0130.05018.79
5.4.210.0170.04018.93
5.4.200.0100.05018.94
5.4.190.0070.05318.79
5.4.180.0000.06018.89
5.4.170.0030.05718.99
5.4.160.0130.06018.81
5.4.150.0200.06318.98
5.4.140.0030.05316.62
5.4.130.0070.04716.41
5.4.120.0130.04316.42
5.4.110.0170.06316.38
5.4.100.0070.07016.52
5.4.90.0000.05316.49
5.4.80.0070.04716.50
5.4.70.0100.04316.39
5.4.60.0100.06316.34
5.4.50.0070.04716.48
5.4.40.0030.05016.64
5.4.30.0070.05016.34
5.4.20.0100.04316.47
5.4.10.0070.05016.39
5.4.00.0000.07015.75
5.3.290.0100.04212.80
5.3.280.0100.05014.84
5.3.270.0100.06014.77
5.3.260.0100.07714.46
5.3.250.0130.05014.71
5.3.240.0130.04714.72
5.3.230.0130.06314.70
5.3.220.0100.07014.68
5.3.210.0270.06714.61
5.3.200.0130.04714.81
5.3.190.0130.04314.69
5.3.180.0130.05714.67
5.3.170.0100.04714.59
5.3.160.0030.05314.55
5.3.150.0030.05314.67
5.3.140.0070.04714.67
5.3.130.0070.05014.66
5.3.120.0070.05314.65
5.3.110.0070.05314.56
5.3.100.0070.05014.13
5.3.90.0130.05314.11
5.3.80.0070.04714.06
5.3.70.0130.04014.12
5.3.60.0070.05313.85
5.3.50.0130.04013.99
5.3.40.0000.05314.04
5.3.30.0000.05314.13
5.3.20.0100.04313.80
5.3.10.0100.04313.89
5.3.00.0170.03713.74
5.2.170.0030.04311.25
5.2.160.0030.04011.25
5.2.150.0070.04011.18
5.2.140.0000.04311.24
5.2.130.0100.03711.22
5.2.120.0030.04011.35
5.2.110.0030.04311.29
5.2.100.0100.03310.96
5.2.90.0030.04311.13
5.2.80.0070.05311.12
5.2.70.0000.04711.02
5.2.60.0100.04011.17
5.2.50.0100.03311.14
5.2.40.0030.04010.93
5.2.30.0070.04011.07
5.2.20.0070.04010.98
5.2.10.0030.04010.79
5.2.00.0030.04010.86
5.1.60.0030.03310.08
5.1.50.0030.03310.09
5.1.40.0070.03010.25
5.1.30.0030.03710.36
5.1.20.0070.03310.46
5.1.10.0030.03710.16
5.1.00.0100.04010.14
5.0.50.0070.0238.60
5.0.40.0100.0208.46
5.0.30.0070.0408.11
5.0.20.0100.0208.20
5.0.10.0000.0338.13
5.0.00.0100.0338.26
4.4.90.0030.0237.02
4.4.80.0030.0207.02
4.4.70.0030.0207.02
4.4.60.0030.0207.02
4.4.50.0030.0207.02
4.4.40.0070.0307.02
4.4.30.0000.0237.02
4.4.20.0030.0237.02
4.4.10.0100.0177.02
4.4.00.0070.0307.02
4.3.110.0070.0177.02
4.3.100.0000.0237.02
4.3.90.0030.0207.02
4.3.80.0000.0377.02
4.3.70.0030.0237.02
4.3.60.0070.0177.02
4.3.50.0000.0237.02
4.3.40.0070.0277.02
4.3.30.0070.0237.02
4.3.20.0030.0207.02
4.3.10.0030.0277.02
4.3.00.0100.0209.33

preferences:
43.2 ms | 400 KiB | 5 Q