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('<?=','?>'),$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.60.0000.01418.80
8.3.50.0140.00322.05
8.3.40.0120.00619.04
8.3.30.0150.00019.26
8.3.20.0000.00820.34
8.3.10.0080.00021.95
8.3.00.0080.00022.58
8.2.180.0100.01016.75
8.2.170.0130.00322.96
8.2.160.0040.01120.74
8.2.150.0040.00424.18
8.2.140.0040.00424.66
8.2.130.0030.00526.16
8.2.120.0000.00819.61
8.2.110.0030.00719.17
8.2.100.0080.00417.91
8.2.90.0090.00019.34
8.2.80.0040.00417.97
8.2.70.0090.00017.88
8.2.60.0060.00317.93
8.2.50.0040.00418.07
8.2.40.0000.00818.16
8.2.30.0000.00718.30
8.2.20.0040.00417.98
8.2.10.0000.00819.81
8.2.00.0040.00418.05
8.1.280.0120.00925.92
8.1.270.0090.00022.12
8.1.260.0040.00426.35
8.1.250.0040.00428.09
8.1.240.0040.00422.59
8.1.230.0110.00022.75
8.1.220.0040.00417.79
8.1.210.0050.00318.77
8.1.200.0030.00717.47
8.1.190.0030.00617.64
8.1.180.0000.00918.77
8.1.170.0040.00418.96
8.1.160.0000.00822.07
8.1.150.0000.00718.80
8.1.140.0040.00417.58
8.1.130.0040.00417.86
8.1.120.0040.00417.66
8.1.110.0050.00217.59
8.1.100.0000.00717.53
8.1.90.0000.00717.68
8.1.80.0030.00417.64
8.1.70.0000.00717.66
8.1.60.0040.00417.81
8.1.50.0000.00817.68
8.1.40.0050.00317.70
8.1.30.0000.00917.70
8.1.20.0030.00517.85
8.1.10.0030.00617.66
8.1.00.0000.00817.67
8.0.300.0040.00418.77
8.0.290.0040.00417.18
8.0.280.0000.00718.55
8.0.270.0060.00317.32
8.0.260.0040.00417.02
8.0.250.0030.00317.28
8.0.240.0030.00317.27
8.0.230.0070.00017.18
8.0.220.0030.00317.11
8.0.210.0000.00717.19
8.0.200.0000.00617.16
8.0.190.0040.00717.25
8.0.180.0000.00817.18
8.0.170.0000.00717.14
8.0.160.0050.00217.09
8.0.150.0000.01017.18
8.0.140.0040.00417.07
8.0.130.0070.00013.55
8.0.120.0040.00417.10
8.0.110.0070.00017.08
8.0.100.0000.00716.99
8.0.90.0000.00717.02
8.0.80.0110.00417.19
8.0.70.0040.00416.95
8.0.60.0070.00017.18
8.0.50.0040.00417.13
8.0.30.0110.01217.45
8.0.20.0120.00617.40
8.0.10.0040.00417.31
8.0.00.0250.01516.93
7.4.330.0000.00515.00
7.4.320.0070.00016.75
7.4.300.0000.00616.80
7.4.290.0030.00316.75
7.4.280.0000.00716.79
7.4.270.0000.00716.88
7.4.260.0050.00316.64
7.4.250.0080.00016.82
7.4.240.0060.00216.82
7.4.230.0030.00316.88
7.4.220.0130.00716.96
7.4.210.0090.00716.87
7.4.200.0000.00716.59
7.4.190.0070.00016.66
7.4.160.0120.00416.70
7.4.150.0040.01517.40
7.4.140.0130.00817.86
7.4.130.0130.00716.76
7.4.120.0090.01016.68
7.4.110.0030.01416.84
7.4.100.0090.01216.77
7.4.90.0140.01117.02
7.4.80.0130.01019.39
7.4.70.0080.00816.70
7.4.60.0170.00016.70
7.4.50.0030.00616.74
7.4.40.0030.01222.77
7.4.30.0050.01016.63
7.4.00.0050.01115.29
7.3.330.0050.00013.45
7.3.320.0020.00213.59
7.3.310.0070.00016.49
7.3.300.0000.00716.55
7.3.290.0040.01016.61
7.3.280.0080.00816.59
7.3.270.0130.00717.40
7.3.260.0080.00816.53
7.3.250.0090.00816.74
7.3.240.0070.01116.88
7.3.230.0080.01416.64
7.3.210.0110.00616.71
7.3.200.0030.01319.39
7.3.190.0070.01116.56
7.3.180.0080.00816.55
7.3.170.0090.00616.54
7.3.160.0110.00816.62
7.3.120.0090.00714.97
7.3.110.0030.00915.02
7.3.100.0060.00914.71
7.3.90.0040.01114.72
7.3.80.0100.00715.07
7.3.70.0100.00315.05
7.3.60.0030.01014.90
7.3.50.0030.00715.16
7.3.40.0090.00315.10
7.3.30.0030.01015.05
7.3.20.0070.01016.79
7.3.10.0080.00416.97
7.3.00.0050.00916.68
7.2.330.0060.01617.05
7.2.320.0030.01317.02
7.2.310.0080.00816.76
7.2.300.0060.01117.03
7.2.290.0120.00617.00
7.2.250.0070.01315.29
7.2.240.0070.01115.37
7.2.230.0070.00715.29
7.2.220.0070.00315.30
7.2.210.0030.01115.22
7.2.200.0070.00714.98
7.2.190.0000.01015.25
7.2.180.0070.00715.30
7.2.170.0000.01315.38
7.2.130.0030.00616.82
7.2.120.0070.01017.19
7.2.110.0040.00716.90
7.2.100.0000.00917.18
7.2.90.0090.00616.95
7.2.80.0000.01417.13
7.2.70.0030.00916.91
7.2.60.0150.00616.99
7.2.50.0080.00517.18
7.2.40.0070.00717.14
7.2.30.0070.00717.15
7.2.20.0090.00617.10
7.2.10.0070.00417.18
7.2.00.0040.00918.39
7.1.330.0100.00315.90
7.1.320.0030.01016.06
7.1.310.0030.01415.81
7.1.300.0070.00315.98
7.1.290.0100.00716.00
7.1.280.0030.01016.00
7.1.270.0040.01115.90
7.1.260.0030.01016.07
7.1.250.0070.00316.14
7.1.200.0030.00915.92
7.1.100.0060.00618.47
7.1.70.0000.00817.46
7.1.60.0030.02019.82
7.1.50.0100.01317.27
7.1.00.0100.06322.49
7.0.200.0030.00516.99
7.0.140.0030.07022.01
7.0.60.0070.07319.91
7.0.50.0130.07317.94
7.0.40.0000.04720.17
7.0.30.0370.07320.21
7.0.20.0200.04020.24
7.0.10.0270.08020.15
7.0.00.0130.04320.24
5.6.280.0100.06021.17
5.6.210.0030.08020.71
5.6.200.0100.06318.16
5.6.190.0070.04020.55
5.6.180.3870.04020.61
5.6.170.0170.04020.47
5.6.160.0070.08320.54
5.6.150.0070.07318.22
5.6.140.0130.03318.21
5.6.130.0130.07718.17
5.6.120.0130.08021.14
5.6.110.0100.08321.02
5.6.100.0130.06321.04
5.6.90.0200.04321.12
5.6.80.0070.08020.41
5.6.70.0330.06320.30
5.5.350.0030.08720.45
5.5.340.0030.08317.99
5.5.330.0100.04720.19
5.5.320.0170.06720.42
5.5.310.0030.05020.27
5.5.300.0100.07717.97
5.5.290.0030.04717.98
5.5.280.0030.04720.79
5.5.270.0100.08020.98
5.5.260.0030.09020.85
5.5.250.0030.04320.71
5.5.240.0100.07720.38
5.4.450.0230.03719.56
5.4.440.0130.04319.55
5.4.430.0270.06019.54
5.4.420.0230.03019.48
5.4.410.0230.03019.28
5.4.400.0130.04319.00
5.4.390.0370.03318.84
5.4.380.0170.03719.00
5.4.370.0100.04319.00
5.4.360.0170.04019.13
5.4.350.0170.03719.22
5.4.340.0170.03719.05
5.4.320.0170.03718.95
5.4.310.0200.03319.32
5.4.300.0170.03719.03
5.4.290.0200.03719.13
5.4.280.0130.05019.09
5.4.270.0200.04018.88
5.4.260.0170.03719.14
5.4.250.0100.04719.21
5.4.240.0100.03019.19
5.4.230.0130.05019.14
5.4.220.0100.04318.97
5.4.210.0230.04018.99
5.4.200.0170.04718.85
5.4.190.0100.05319.13
5.4.180.0230.03319.21
5.4.170.0170.03719.21
5.4.160.0300.05319.07
5.4.150.0230.04719.07
5.4.140.0300.03716.38
5.4.130.0130.03716.33
5.4.120.0170.03716.38
5.4.110.0130.03716.26
5.4.100.0230.04316.45
5.4.90.0230.02716.29
5.4.80.0200.03316.57
5.4.70.0200.03016.62
5.4.60.0200.03016.38
5.4.50.0300.03316.38
5.4.40.0200.05716.51
5.4.30.0200.03316.43
5.4.20.0170.04716.25
5.4.10.0200.03316.39
5.4.00.0170.03715.80
5.3.290.0130.04014.66
5.3.280.0170.03714.63
5.3.270.0330.06014.86
5.3.260.0200.05714.55
5.3.250.0200.03714.74
5.3.240.0200.07314.85
5.3.230.0200.03014.62
5.3.220.0030.07714.48
5.3.210.0930.05014.59
5.3.200.2000.03314.61
5.3.190.2170.03314.61
5.3.180.2000.03714.73
5.3.170.2000.04014.73
5.3.160.2000.03714.57
5.3.150.2170.05014.58
5.3.140.2000.04714.81
5.3.130.2130.03014.56
5.3.120.2400.04014.55
5.3.110.2270.04014.56
5.3.100.2170.04314.29
5.3.90.2000.03714.05
5.3.80.2430.04014.09
5.3.70.2200.04713.97
5.3.60.2400.03314.26
5.3.50.2370.04313.90
5.3.40.2300.03014.05
5.3.30.2300.04013.86
5.3.20.2330.03313.84
5.3.10.2200.05013.59
5.3.00.2230.03713.89
5.2.170.1870.03011.26
5.2.160.0930.03311.25
5.2.150.0000.03311.10
5.2.140.0130.05011.08
5.2.130.0070.04311.05
5.2.120.0600.03011.05
5.2.110.1730.03011.18
5.2.100.1900.03311.03
5.2.90.1970.03711.21
5.2.80.1930.03711.13
5.2.70.1770.03311.11
5.2.60.1700.02711.05
5.2.50.1670.03011.12
5.2.40.1370.02711.19
5.2.30.1200.02710.92
5.2.20.1370.02711.07
5.2.10.1630.03310.90
5.2.00.1630.03010.68
5.1.60.1700.0279.96
5.1.50.1430.03010.01
5.1.40.1200.0309.94
5.1.30.1500.03010.34
5.1.20.1400.02310.35
5.1.10.0730.03010.09
5.1.00.1100.02710.09
5.0.50.0700.0208.82
5.0.40.0530.0108.45
5.0.30.0700.0308.17
5.0.20.0700.0178.23
5.0.10.0630.0208.21
5.0.00.0600.0438.11
4.4.90.0630.0178.08
4.4.80.0670.0178.08
4.4.70.0700.0178.08
4.4.60.0570.0138.08
4.4.50.0670.0178.08
4.4.40.0630.0238.08
4.4.30.0730.0138.08
4.4.20.0700.0138.08
4.4.10.0700.0178.08
4.4.00.0800.0278.08
4.3.110.0630.0178.08
4.3.100.0470.0138.08
4.3.90.0630.0208.08
4.3.80.0630.0278.08
4.3.70.0700.0138.08
4.3.60.0730.0138.08
4.3.50.0530.0178.08
4.3.40.0730.0208.08
4.3.30.0200.0138.08
4.3.20.0370.0138.08
4.3.10.0400.0108.08
4.3.00.0370.0138.08

preferences:
47.29 ms | 401 KiB | 5 Q