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.60.0100.01018.55
8.3.50.0050.01121.39
8.3.40.0090.00619.01
8.3.30.0070.00720.34
8.3.20.0080.00020.20
8.3.10.0080.00022.11
8.3.00.0080.00022.43
8.2.180.0140.00718.54
8.2.170.0150.00022.96
8.2.160.0000.01520.42
8.2.150.0040.00424.18
8.2.140.0040.00424.66
8.2.130.0160.00326.16
8.2.120.0030.00519.68
8.2.110.0080.00319.31
8.2.100.0060.00617.97
8.2.90.0040.00419.16
8.2.80.0030.00617.97
8.2.70.0030.00617.88
8.2.60.0090.00617.92
8.2.50.0030.00618.07
8.2.40.0040.00418.22
8.2.30.0070.00018.12
8.2.20.0000.00717.97
8.2.10.0040.00417.94
8.2.00.0030.00617.89
8.1.280.0130.00625.92
8.1.270.0040.00423.99
8.1.260.0040.00426.35
8.1.250.0080.00028.09
8.1.240.0090.00022.22
8.1.230.0070.00419.12
8.1.220.0050.00317.89
8.1.210.0040.00418.77
8.1.200.0030.00617.48
8.1.190.0030.00617.48
8.1.180.0000.00818.10
8.1.170.0050.00318.90
8.1.160.0050.00218.87
8.1.150.0040.00418.79
8.1.140.0040.00417.57
8.1.130.0050.00317.89
8.1.120.0040.00417.68
8.1.110.0040.00417.67
8.1.100.0000.00817.67
8.1.90.0040.00417.63
8.1.80.0040.00417.58
8.1.70.0040.00417.62
8.1.60.0040.00717.67
8.1.50.0000.00817.70
8.1.40.0060.00317.73
8.1.30.0080.00017.90
8.1.20.0060.00317.73
8.1.10.0030.00617.74
8.1.00.0030.00617.58
8.0.300.0000.00718.77
8.0.290.0000.00817.13
8.0.280.0000.00718.57
8.0.270.0030.00317.38
8.0.260.0030.00316.94
8.0.250.0030.00317.25
8.0.240.0040.00417.11
8.0.230.0000.00717.19
8.0.220.0040.00417.17
8.0.210.0000.00717.12
8.0.200.0000.00717.16
8.0.190.0040.00417.24
8.0.180.0000.00717.06
8.0.170.0050.00217.14
8.0.160.0040.00417.00
8.0.150.0050.00216.99
8.0.140.0050.00317.09
8.0.130.0030.00313.61
8.0.120.0040.00417.11
8.0.110.0050.00317.03
8.0.100.0000.00717.12
8.0.90.0000.00717.10
8.0.80.0080.00817.12
8.0.70.0000.00717.05
8.0.60.0040.00416.96
8.0.50.0040.00417.01
8.0.30.0110.00817.33
8.0.20.0130.01017.50
8.0.10.0040.00417.23
8.0.00.0190.00616.90
7.4.330.0000.00515.00
7.4.320.0000.00616.84
7.4.300.0030.00316.78
7.4.290.0070.00016.68
7.4.280.0040.00416.85
7.4.270.0040.00416.87
7.4.260.0000.00716.86
7.4.250.0050.00216.78
7.4.240.0030.00416.80
7.4.230.0030.00316.77
7.4.220.0090.00616.94
7.4.210.0070.00816.75
7.4.200.0040.00416.86
7.4.190.0040.00416.71
7.4.160.0030.01416.82
7.4.150.0120.01617.40
7.4.140.0160.00917.86
7.4.130.0150.01016.71
7.4.120.0060.01116.81
7.4.110.0090.00916.80
7.4.100.0090.00916.92
7.4.90.0070.01116.73
7.4.80.0140.00319.39
7.4.70.0170.00716.99
7.4.60.0060.00916.71
7.4.50.0000.00816.79
7.4.40.0060.01022.77
7.4.30.0000.01616.71
7.4.10.0110.00715.21
7.4.00.0090.00815.18
7.3.330.0050.00013.41
7.3.320.0050.00013.47
7.3.310.0030.00316.64
7.3.300.0000.00716.53
7.3.290.0040.00916.60
7.3.280.0100.00616.50
7.3.270.0100.00617.40
7.3.260.0070.01016.72
7.3.250.0090.01016.70
7.3.240.0060.01216.66
7.3.230.0040.01516.55
7.3.210.0060.01316.70
7.3.200.0030.01319.39
7.3.190.0000.01616.50
7.3.180.0080.00816.66
7.3.170.0040.01216.39
7.3.160.0080.00816.64
7.3.130.0130.00315.04
7.3.120.0070.00815.07
7.3.110.0070.01215.07
7.3.100.0030.01215.07
7.3.90.0090.00614.99
7.3.80.0000.01314.70
7.3.70.0040.00814.91
7.3.60.0060.00515.05
7.3.50.0020.00814.93
7.3.40.0060.00714.87
7.3.30.0060.00714.78
7.3.20.0070.00716.89
7.3.10.0030.01316.81
7.3.00.0030.01016.70
7.2.330.0090.00917.08
7.2.320.0070.01716.84
7.2.310.0040.01216.73
7.2.300.0070.01616.80
7.2.290.0030.01916.93
7.2.260.0080.01115.05
7.2.250.0100.00915.45
7.2.240.0090.00715.41
7.2.230.0040.01315.03
7.2.220.0050.00915.22
7.2.210.0050.01015.25
7.2.200.0040.01115.35
7.2.190.0000.01115.30
7.2.180.0070.00415.04
7.2.170.0050.00815.26
7.2.160.0080.00415.36
7.2.150.0100.00317.13
7.2.140.0060.01317.22
7.2.130.0030.00617.11
7.2.120.0030.00916.93
7.2.110.0030.01216.88
7.2.100.0060.00617.19
7.2.90.0040.01117.19
7.2.80.0120.00617.12
7.2.70.0070.01017.05
7.2.60.0070.00716.90
7.2.50.0000.01717.01
7.2.40.0040.01417.04
7.2.30.0050.00517.32
7.2.20.0120.00017.11
7.2.10.0030.01017.27
7.2.00.0070.01017.09
7.1.330.0020.01216.07
7.1.320.0030.01215.86
7.1.310.0050.00615.89
7.1.300.0020.01016.02
7.1.290.0070.00615.89
7.1.280.0050.00615.80
7.1.270.0120.00515.85
7.1.260.0080.00516.00
7.1.250.0030.00815.68
7.1.240.0060.00616.08
7.1.230.0100.00616.06
7.1.220.0040.00416.02
7.1.210.0050.01115.91
7.1.200.0030.01016.08
7.1.190.0000.01215.73
7.1.180.0060.00615.87
7.1.170.0090.00315.86
7.1.160.0110.00315.95
7.1.150.0060.00616.03
7.1.140.0100.00315.81
7.1.130.0000.01016.20
7.1.120.0000.00815.93
7.1.110.0080.00415.70
7.1.100.0000.01115.95
7.1.90.0030.00516.04
7.1.80.0110.00016.14
7.1.70.0030.01116.57
7.1.60.0040.01617.71
7.1.50.0050.01416.70
7.1.40.0060.01215.92
7.1.30.0090.00916.01
7.1.20.0030.01015.95
7.1.10.0040.00815.96
7.1.00.0050.02319.04
7.0.330.0030.01015.41
7.0.320.0110.00015.38
7.0.310.0000.00915.59
7.0.300.0040.01115.46
7.0.290.0100.00715.47
7.0.280.0060.00315.31
7.0.270.0070.00715.81
7.0.260.0000.01115.27
7.0.250.0030.01415.64
7.0.240.0030.00915.76
7.0.230.0070.00715.46
7.0.220.0000.01415.72
7.0.210.0130.00315.75
7.0.200.0080.00715.39
7.0.190.0090.00415.36
7.0.180.0030.01015.79
7.0.170.0040.01115.34
7.0.160.0120.00315.64
7.0.150.0040.00815.38
7.0.140.0070.04018.74
7.0.130.0060.00315.47
7.0.120.0000.01415.75
7.0.110.0050.00515.53
7.0.100.0100.00715.68
7.0.90.0040.00715.48
7.0.80.0060.00915.39
7.0.70.0060.00315.54
7.0.60.0130.03017.83
7.0.50.0050.03516.92
7.0.40.0080.02716.88
7.0.30.0160.04316.90
7.0.20.0220.03716.89
7.0.10.0170.03817.07
7.0.00.0030.04616.95
5.6.400.0060.00614.84
5.6.390.0000.01514.86
5.6.380.0000.01214.44
5.6.370.0080.00814.76
5.6.360.0070.01014.32
5.6.350.0060.00614.22
5.6.340.0090.00614.54
5.6.330.0060.00614.76
5.6.320.0040.01214.82
5.6.310.0000.01214.45
5.6.300.0060.00614.78
5.6.290.0070.01014.71
5.6.280.0060.03617.74
5.6.270.0130.00314.64
5.6.260.0000.01514.73
5.6.250.0000.01314.50
5.6.240.0110.00414.27
5.6.230.0090.00614.59
5.6.220.0040.00714.67
5.6.210.0050.03517.46
5.6.200.0100.04216.45
5.6.190.0060.04917.59
5.6.180.0170.04417.41
5.6.170.0120.03217.50
5.6.160.0050.03317.45
5.6.150.0080.02916.54
5.6.140.0020.02816.39
5.6.130.0070.04416.30
5.6.120.0030.04917.80
5.6.110.0050.02717.70
5.6.100.0060.04517.87
5.6.90.0050.03717.76
5.6.80.0090.04417.38
5.6.70.0110.00414.74
5.6.60.0040.00414.41
5.6.50.0040.01114.71
5.6.40.0060.00614.17
5.6.30.0000.01514.51
5.6.20.0120.00014.29
5.6.10.0000.01414.42
5.6.00.0040.00414.56
5.5.380.0030.00914.24
5.5.370.0060.00614.73
5.5.360.0000.01314.44
5.5.350.0000.03617.45
5.5.340.0020.02916.32
5.5.330.0030.04517.51
5.5.320.0060.03317.63
5.5.310.0180.02217.57
5.5.300.0060.04516.25
5.5.290.0050.02516.37
5.5.280.0070.03717.56
5.5.270.0000.04117.73
5.5.260.0090.04517.54
5.5.250.0050.02317.51
5.5.240.0200.04017.32
5.5.230.0060.01014.21
5.5.220.0120.00314.75
5.5.210.0070.00714.65
5.5.200.0000.01414.62
5.5.190.0040.00714.61
5.5.180.0030.01014.51
5.5.170.0110.00314.44
5.5.160.0060.00314.32
5.5.150.0130.00314.46
5.5.140.0030.01114.38
5.5.130.0040.00714.34
5.5.120.0060.00914.73
5.5.110.0040.01214.49
5.5.100.0070.00714.40
5.5.90.0030.01314.61
5.5.80.0100.00314.56
5.5.70.0030.01314.32
5.5.60.0040.00814.40
5.5.50.0040.01414.50
5.5.40.0070.00714.30
5.5.30.0070.00714.60
5.5.20.0060.00314.31
5.5.10.0000.01314.47
5.5.00.0080.00314.14
5.4.450.0410.02315.30
5.4.440.0220.02315.53
5.4.430.0400.02515.31
5.4.420.0300.02615.28
5.4.410.0280.02415.18
5.4.400.0220.02115.18
5.4.390.0470.02315.10
5.4.380.0250.03815.02
5.4.370.0200.03815.02
5.4.360.0150.03114.95
5.4.350.0230.02815.11
5.4.340.0110.03615.00
5.4.330.0000.00611.23
5.4.320.0050.02911.93
5.4.310.0040.02311.79
5.4.300.0060.02411.92
5.4.290.0050.02211.89
5.4.280.0050.02211.82
5.4.270.0020.02611.90
5.4.260.0070.03115.03
5.4.250.0020.03415.10
5.4.240.0050.03015.25
5.4.230.0070.03315.17
5.4.220.0120.03515.12
5.4.210.0070.02914.85
5.4.200.0050.04215.08
5.4.190.0130.02515.05
5.4.180.0090.03015.01
5.4.170.0130.02514.89
5.4.160.0050.02915.12
5.4.150.0090.02714.94
5.4.140.0050.03113.88
5.4.130.0080.02713.97
5.4.120.0080.03113.70
5.4.110.0080.03113.99
5.4.100.0060.02813.85
5.4.90.0030.03213.92
5.4.80.0070.03713.82
5.4.70.0030.03213.93
5.4.60.0060.02813.84
5.4.50.0080.03613.86
5.4.40.0080.02713.85
5.4.30.0050.02713.96
5.4.20.0050.03213.91
5.4.10.0030.03213.80
5.4.00.0130.03013.52
5.3.290.0060.02411.81
5.3.280.0030.03112.78
5.3.270.0030.03412.68
5.3.260.0070.03012.80
5.3.250.0030.03012.66
5.3.240.0040.03512.61
5.3.230.0100.02712.55
5.3.220.0100.02712.56
5.3.210.0090.03112.49
5.3.200.0010.03312.67
5.3.190.0030.04212.71
5.3.180.0030.03812.61
5.3.170.0050.03712.68
5.3.160.0150.02512.76
5.3.150.0020.03312.75
5.3.140.0100.02912.79
5.3.130.0100.02312.59
5.3.120.0030.03312.73
5.3.110.0110.02512.76
5.3.100.0090.02712.39
5.3.90.0070.02912.38
5.3.80.0050.02612.27
5.3.70.0080.03512.32
5.3.60.0040.03012.37
5.3.50.0030.03012.34
5.3.40.0090.02712.34
5.3.30.0110.03212.18
5.3.20.0070.02512.12
5.3.10.0030.03912.12
5.3.00.0030.03812.13
5.2.170.0070.06011.18
5.2.160.0030.04011.18
5.2.150.0100.05711.18
5.2.140.0000.04311.35
5.2.130.0030.04311.13
5.2.120.0130.05011.23
5.2.110.0070.03711.21
5.2.100.0170.04711.20
5.2.90.0030.04711.20
5.2.80.0030.04311.27
5.2.70.0070.04311.18
5.2.60.0070.04711.05
5.2.50.0030.04711.04
5.2.40.0130.03311.02
5.2.30.0100.04311.16
5.2.20.0030.04710.96
5.2.10.0070.04310.89
5.2.00.0070.04010.65
5.1.60.0070.03310.23
5.1.50.0130.0379.87
5.1.40.0030.03710.08
5.1.30.0100.03310.54
5.1.20.0000.05710.47
5.1.10.0100.03710.07
5.1.00.0000.04010.09
5.0.50.0100.0238.68
5.0.40.0030.0308.55
5.0.30.0100.0478.37
5.0.20.0030.0308.39
5.0.10.0070.0278.46
5.0.00.0070.0408.21
4.4.90.0100.0236.00
4.4.80.0000.0236.00
4.4.70.0030.0236.00
4.4.60.0070.0206.00
4.4.50.0000.0306.03
4.4.40.0100.0376.00
4.4.30.0030.0206.00
4.4.20.0030.0236.00
4.4.10.0070.0176.00
4.4.00.0100.0276.00
4.3.110.0070.0306.00
4.3.100.0000.0236.00
4.3.90.0030.0206.00
4.3.80.0000.0376.00
4.3.70.0030.0206.00
4.3.60.0030.0206.00
4.3.50.0000.0336.00
4.3.40.0070.0276.00
4.3.30.0030.0206.00
4.3.20.0000.0276.00
4.3.10.0000.0236.00
4.3.00.0000.01314.51

preferences:
42.23 ms | 401 KiB | 5 Q