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 => $pappa in $posts %} {% if $post <= 0 %} {{ $post==3 ? 'Yes' : 'No' }} {% end %} {% 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('.implode(' ',$fragments).'):'; break; case 'for': $stack[] = 'foreach'; $tmp = explode(' in ',implode(' ',$fragments)); return 'foreach('.$tmp[1].' as '.$tmp[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.00619.09
8.3.30.0120.00319.21
8.3.20.0000.00820.16
8.3.10.0040.00422.00
8.3.00.0040.00422.45
8.2.170.0060.00922.96
8.2.160.0070.00720.89
8.2.150.0040.00424.18
8.2.140.0080.00024.66
8.2.130.0050.00226.16
8.2.120.0040.00420.93
8.2.110.0060.00322.08
8.2.100.0120.00018.03
8.2.90.0050.00318.08
8.2.80.0090.00017.97
8.2.70.0090.00017.72
8.2.60.0000.00818.04
8.2.50.0040.00418.07
8.2.40.0040.00418.16
8.2.30.0000.00718.05
8.2.20.0050.00318.03
8.2.10.0030.00519.61
8.2.00.0030.00518.05
8.1.270.0050.00323.99
8.1.260.0070.00026.35
8.1.250.0030.00628.09
8.1.240.0130.00322.53
8.1.230.0080.00321.05
8.1.220.0050.00517.79
8.1.210.0100.00019.04
8.1.200.0060.00317.38
8.1.190.0060.00317.53
8.1.180.0040.00420.40
8.1.170.0050.00318.59
8.1.160.0020.00522.07
8.1.150.0040.00418.82
8.1.140.0060.00317.67
8.1.130.0000.00717.73
8.1.120.0000.00817.57
8.1.110.0000.00717.62
8.1.100.0030.00517.65
8.1.90.0040.00417.52
8.1.80.0070.00017.64
8.1.70.0030.00317.59
8.1.60.0040.00417.79
8.1.50.0040.00417.60
8.1.40.0050.00217.59
8.1.30.0050.00317.78
8.1.20.0060.00317.84
8.1.10.0000.00817.73
8.1.00.0030.00617.63
8.0.300.0050.00219.96
8.0.290.0080.00017.18
8.0.280.0040.00418.41
8.0.270.0070.00017.18
8.0.260.0040.00417.05
8.0.250.0070.00017.16
8.0.240.0030.00317.19
8.0.230.0000.00717.09
8.0.220.0030.00317.22
8.0.210.0030.00317.13
8.0.200.0040.00417.15
8.0.190.0100.00017.05
8.0.180.0050.00317.03
8.0.170.0050.00317.07
8.0.160.0000.00717.15
8.0.150.0000.00717.07
8.0.140.0000.00917.07
8.0.130.0060.00013.51
8.0.120.0040.00417.10
8.0.110.0040.00417.14
8.0.100.0020.00517.17
8.0.90.0050.00216.91
8.0.80.0130.00317.00
8.0.70.0040.00416.95
8.0.60.0000.00816.95
8.0.50.0030.00517.15
8.0.30.0140.00917.27
8.0.20.0110.00817.40
8.0.10.0080.00017.30
8.0.00.0140.00616.99
7.4.330.0020.00215.00
7.4.320.0060.00016.64
7.4.300.0060.00016.75
7.4.290.0070.00016.75
7.4.280.0080.00016.82
7.4.270.0030.00316.72
7.4.260.0040.00416.70
7.4.250.0040.00416.72
7.4.240.0050.00216.85
7.4.230.0040.00416.81
7.4.220.0090.01316.58
7.4.210.0110.00416.72
7.4.200.0060.00316.93
7.4.190.0030.00416.90
7.4.160.0160.00016.91
7.4.150.0140.00317.40
7.4.140.0060.01217.86
7.4.130.0090.00816.78
7.4.120.0090.00816.78
7.4.110.0100.00716.61
7.4.100.0140.01116.60
7.4.90.0090.00916.73
7.4.80.0120.00819.39
7.4.70.0090.00916.80
7.4.60.0130.00416.63
7.4.50.0060.00016.77
7.4.40.0060.00922.77
7.4.30.0070.01016.73
7.4.10.0130.00315.42
7.4.00.0070.00715.22
7.3.330.0030.00313.61
7.3.320.0050.00013.52
7.3.310.0080.00016.63
7.3.300.0030.00316.47
7.3.290.0100.00516.57
7.3.280.0060.01116.54
7.3.270.0120.00917.40
7.3.260.0140.00316.52
7.3.250.0080.01416.67
7.3.240.0050.01116.61
7.3.230.0060.01216.55
7.3.210.0040.01216.47
7.3.200.0100.00719.39
7.3.190.0090.00916.63
7.3.180.0090.01216.76
7.3.170.0130.00316.79
7.3.160.0080.00816.51
7.3.130.0130.00715.27
7.3.120.0040.01015.07
7.3.110.0100.00715.08
7.3.100.0050.00914.78
7.3.90.0100.00615.23
7.3.80.0060.00514.91
7.3.70.0050.01014.97
7.3.60.0080.00514.90
7.3.50.0060.00614.94
7.3.40.0060.00815.05
7.3.30.0050.00915.06
7.3.20.0030.01316.86
7.3.10.0060.00616.69
7.3.00.0080.00816.91
7.2.330.0080.01117.01
7.2.320.0100.00716.82
7.2.310.0090.00916.86
7.2.300.0000.01616.85
7.2.290.0060.01017.02
7.2.260.0030.01615.41
7.2.250.0070.01315.34
7.2.240.0060.00615.33
7.2.230.0050.01115.21
7.2.220.0050.01115.22
7.2.210.0040.01015.25
7.2.200.0090.00715.29
7.2.190.0050.01015.14
7.2.180.0040.01115.05
7.2.170.0080.00715.33
7.2.160.0070.00415.22
7.2.150.0080.00517.21
7.2.140.0040.01017.19
7.2.130.0070.00717.13
7.2.120.0060.00717.08
7.2.110.0030.01216.98
7.2.100.0060.00617.09
7.2.90.0060.00717.25
7.2.80.0080.00817.20
7.2.70.0050.01017.23
7.2.60.0030.01016.95
7.2.50.0060.00917.11
7.2.40.0060.00917.17
7.2.30.0070.00817.04
7.2.20.0080.00817.07
7.2.10.0080.00417.16
7.2.00.0050.00917.68
7.1.330.0050.00715.99
7.1.320.0070.00716.11
7.1.310.0070.00616.03
7.1.300.0030.00915.94
7.1.290.0070.00716.00
7.1.280.0100.00415.90
7.1.270.0020.01115.91
7.1.260.0030.00915.75
7.1.250.0070.00715.88
7.1.240.0040.01416.04
7.1.230.0060.00316.02
7.1.220.0030.01015.82
7.1.210.0030.01016.04
7.1.200.0090.00616.13
7.1.190.0050.00516.16
7.1.180.0000.00915.95
7.1.170.0060.00616.15
7.1.160.0060.00915.87
7.1.150.0070.00716.20
7.1.140.0040.00815.78
7.1.130.0000.01116.13
7.1.120.0000.01316.12
7.1.110.0030.00616.10
7.1.100.0030.00817.27
7.1.90.0000.01116.20
7.1.80.0040.01116.15
7.1.70.0020.00916.69
7.1.60.0070.01017.93
7.1.50.0140.00625.43
7.1.40.0050.00415.72
7.1.30.0070.01016.10
7.1.20.0070.00715.95
7.1.10.0030.01115.66
7.1.00.0090.03919.19
7.0.330.0070.00715.53
7.0.320.0060.00615.56
7.0.310.0100.00615.71
7.0.300.0100.00615.27
7.0.290.0030.00915.47
7.0.280.0000.01415.32
7.0.270.0000.01415.67
7.0.260.0030.00715.46
7.0.250.0100.00315.76
7.0.240.0030.00715.56
7.0.230.0070.00715.48
7.0.220.0070.00415.71
7.0.210.0030.00715.49
7.0.200.0100.00516.34
7.0.190.0080.00515.54
7.0.180.0060.00615.68
7.0.170.0030.00815.57
7.0.160.0070.00715.60
7.0.150.0000.00815.74
7.0.140.0060.03818.79
7.0.130.0060.00315.52
7.0.120.0080.00615.73
7.0.110.0060.00915.54
7.0.100.0070.00715.75
7.0.90.0030.01015.66
7.0.80.0070.00715.46
7.0.70.0070.00715.35
7.0.60.0100.03617.72
7.0.50.0030.03516.60
7.0.40.0080.04216.84
7.0.30.0120.03016.97
7.0.20.0180.04216.95
7.0.10.0170.04816.99
7.0.00.0090.04716.88
5.6.400.0060.00314.66
5.6.390.0040.01214.36
5.6.380.0060.00314.43
5.6.370.0140.00314.85
5.6.360.0000.01014.84
5.6.350.0100.00714.35
5.6.340.0030.01014.44
5.6.330.0000.01014.54
5.6.320.0060.00614.80
5.6.310.0130.00014.48
5.6.300.0070.01014.46
5.6.290.0060.00914.66
5.6.280.0040.04017.85
5.6.270.0100.00314.70
5.6.260.0060.00914.43
5.6.250.0000.00914.80
5.6.240.0000.01114.82
5.6.230.0090.00914.71
5.6.220.0110.00314.86
5.6.210.0050.04617.68
5.6.200.0060.03816.34
5.6.190.0080.02317.60
5.6.180.1700.02717.50
5.6.170.0200.03417.51
5.6.160.0020.03317.54
5.6.150.0050.05016.39
5.6.140.0020.03916.34
5.6.130.0150.03716.36
5.6.120.0050.04417.73
5.6.110.0030.02517.77
5.6.100.0090.03017.83
5.6.90.0050.02717.89
5.6.80.0060.04617.48
5.6.70.0180.03817.47
5.6.60.0090.00314.45
5.6.50.0030.00914.43
5.6.40.0030.01214.56
5.6.30.0040.01114.39
5.6.20.0030.00714.55
5.6.10.0070.00714.34
5.6.00.0070.00714.11
5.5.380.0060.01214.40
5.5.370.0000.01514.79
5.5.360.0120.00314.65
5.5.350.0050.04717.55
5.5.340.0070.03916.10
5.5.330.0050.02517.26
5.5.320.0170.01817.44
5.5.310.0150.04517.35
5.5.300.0050.02516.29
5.5.290.0130.03616.16
5.5.280.0060.02417.85
5.5.270.0050.02817.39
5.5.260.0030.02517.60
5.5.250.0180.03217.55
5.5.240.0020.02217.43
5.5.230.0090.00314.75
5.5.220.0030.01314.63
5.5.210.0070.00414.28
5.5.200.0120.00314.58
5.5.190.0030.01014.10
5.5.180.0090.00614.48
5.5.170.0070.00714.55
5.5.160.0060.00614.43
5.5.150.0140.00014.67
5.5.140.0060.00314.49
5.5.130.0090.00614.79
5.5.120.0040.00814.45
5.5.110.0060.01014.55
5.5.100.0040.01114.34
5.5.90.0000.01414.42
5.5.80.0080.00414.61
5.5.70.0040.01114.28
5.5.60.0040.00814.34
5.5.50.0060.00614.35
5.5.40.0060.00314.66
5.5.30.0070.00714.11
5.5.20.0030.01014.53
5.5.10.0000.00814.11
5.5.00.0060.00614.13
5.4.450.0230.03516.02
5.4.440.0300.03316.13
5.4.430.0100.03016.07
5.4.420.0100.03916.12
5.4.410.0030.03515.83
5.4.400.0590.00015.73
5.4.390.0770.00315.70
5.4.380.0130.03115.71
5.4.370.0160.02415.57
5.4.360.0200.02815.66
5.4.350.0120.02715.68
5.4.340.0130.03215.65
5.4.330.0000.01012.56
5.4.320.0040.02712.54
5.4.310.0060.02812.54
5.4.300.0040.02412.54
5.4.290.0050.02512.54
5.4.280.0080.02512.49
5.4.270.0020.02412.49
5.4.260.0070.02815.83
5.4.250.0050.03115.70
5.4.240.0090.03815.68
5.4.230.0090.02715.74
5.4.220.0050.03015.82
5.4.210.0050.02815.73
5.4.200.0060.03415.79
5.4.190.0070.02815.76
5.4.180.0080.02915.79
5.4.170.0020.04815.64
5.4.160.0120.02515.59
5.4.150.0070.03515.78
5.4.140.0080.02614.57
5.4.130.0070.02814.57
5.4.120.0080.02814.59
5.4.110.0080.02514.55
5.4.100.0050.02814.54
5.4.90.0050.02814.58
5.4.80.0080.02914.46
5.4.70.0050.02714.57
5.4.60.0070.03914.49
5.4.50.0060.02714.51
5.4.40.0050.03114.55
5.4.30.0090.02314.54
5.4.20.0040.02914.50
5.4.10.0100.02714.46
5.4.00.0030.03014.29
5.3.290.0090.02512.68
5.3.280.0080.02713.58
5.3.270.0050.03413.59
5.3.260.0130.02313.58
5.3.250.0080.03313.56
5.3.240.0020.03213.64
5.3.230.0070.02713.58
5.3.220.0110.02413.62
5.3.210.0070.02713.62
5.3.200.0040.03013.62
5.3.190.0070.03713.66
5.3.180.0030.03313.54
5.3.170.0070.02713.57
5.3.160.0080.02513.58
5.3.150.0050.03213.66
5.3.140.0070.02613.68
5.3.130.0050.02713.57
5.3.120.0030.03013.57
5.3.110.0030.03213.61
5.3.100.0080.03713.35
5.3.90.0070.02813.34
5.3.80.0050.03513.34
5.3.70.0100.02413.26
5.3.60.0100.02513.33
5.3.50.0080.02313.36
5.3.40.0080.02413.31
5.3.30.0030.03013.20
5.3.20.0050.02913.18
5.3.10.0070.02313.16
5.3.00.0120.03213.20
5.2.170.0000.04311.30
5.2.160.0030.04011.29
5.2.150.0000.04711.03
5.2.140.0000.04711.05
5.2.130.0100.03711.21
5.2.120.0170.02711.21
5.2.110.0100.03311.02
5.2.100.0070.03711.03
5.2.90.0000.04311.25
5.2.80.0070.04011.24
5.2.70.0000.04710.99
5.2.60.0100.05311.05
5.2.50.0030.04010.91
5.2.40.0070.03711.15
5.2.30.0070.03710.89
5.2.20.0230.03710.97
5.2.10.0070.03710.84
5.2.00.0070.04710.78
5.1.60.0000.0379.92
5.1.50.0130.0379.85
5.1.40.0070.0409.83
5.1.30.0030.03710.16
5.1.20.0070.03710.51
5.1.10.0070.03310.16
5.1.00.0030.03710.30
5.0.50.0000.0308.61
5.0.40.0030.0278.34
5.0.30.0030.0608.24
5.0.20.0070.0238.15
5.0.10.0000.0308.14
5.0.00.0030.0408.19
4.4.90.0000.0337.02
4.4.80.0070.0177.02
4.4.70.0070.0177.02
4.4.60.0000.0237.02
4.4.50.0030.0207.02
4.4.40.0030.0377.02
4.4.30.0030.0237.02
4.4.20.0000.0237.02
4.4.10.0030.0207.02
4.4.00.0030.0337.02
4.3.110.0000.0277.02
4.3.100.0030.0207.02
4.3.90.0030.0177.02
4.3.80.0030.0307.02
4.3.70.0070.0177.02
4.3.60.0070.0177.02
4.3.50.0100.0137.02
4.3.40.0100.0307.02
4.3.30.0000.0277.02
4.3.20.0070.0177.02
4.3.10.0030.0277.02
4.3.00.0030.0277.32

preferences:
36.98 ms | 400 KiB | 5 Q