3v4l.org

run code in 300+ PHP versions simultaneously
<?php use Symfony\Component\Finder\Finder; class BonesSingleton { public static $instance; public static function getInstance() { if (null === static::$instance) { static::$instance = new static(); } return static::$instance; } protected function __construct() { } private function __clone() { } private function __wakeup() { } } class TwigSingleton extends BonesSingleton { public $twig = false; public $templates = array(); protected function __construct() { $this->getTemplates(); $loader = new Twig_Loader_Array($this->templates); $twigEnv = new Twig_Environment($loader, array('debug' => true)); $imageFunc = new Twig_SimpleFunction('imagesrc', 'show_image', array('is_safe' => array('html'))); $doShortcodeFunc = new Twig_SimpleFunction('do_shortcode', function ($content, $ignore_html = false) { return do_shortcode($content, $ignore_html); }, array('is_safe' => array('html'))); $doBlockFunc = new Twig_SimpleFunction('localize_url', function ($url, $ignore_html = false) { return localize_url($url); }, array('is_safe' => array('html'))); $addEncoFunc = new Twig_SimpleFunction('add_enc',function($redirect_page){ return '<input type="hidden" name="uenc" value="'. Mage::helper('core')->urlEncode(Mage::helper('cms/page')->getPageUrl($redirect_page)).'"/>'; }, array('is_safe' => array('html'))); $twigEnv->addExtension(new Twig_Extension_Debug()); $twigEnv->addFunction($imageFunc); $twigEnv->addFunction($doShortcodeFunc); $twigEnv->addFunction($doBlockFunc); $twigEnv->addFunction($addEncoFunc); $this->twig = $twigEnv; } public function getTwig() { return $this->twig; } public function getTemplates() { //execute all the pattern portfolio parts $this->get_templates_for('04-pages', 'pages'); $this->get_templates_for('03-templates', 'templates'); $this->get_templates_for('02-organisms', 'organisms'); $this->get_templates_for('01-molecules', 'molecules'); $this->get_templates_for('00-atoms', 'atoms'); } private function get_templates_for($folder, $prefix) { $pages = new Finder(); $pages->files()->in(PATTERNS_TEMPLATES . '/' . $folder)->name('*.twig'); foreach ($pages as $file) { $this->templates[$this->prepare_name($file, $prefix . '-')] = $file->getContents(); } } private function prepare_name($file, $prefix = '') { return $prefix . preg_replace('/^[_0-9\-]*/', '', $file->getBasename('.twig')); } } define('PATTERNS_TEMPLATES', dirname(ABSPATH) . '/skin/frontend/sophiehulme/uk/styleguide/source/_patterns'); function create_sh_link($link) { return $link; } function show_image($img, $size, $title = false, $classes = '', $animTarget = false, $lazyload) { $imgHtml = '<img class="block image auto-height js-anim-image ' . $classes . '" width="' . $img['width'] . '" height="' . $img['height'] . '" alt="' . $img['name'] . '" srcset="' . get_image_group_srcset($img, $size) . '"' . ($animTarget ? ' data-anim-target="' . $animTarget . '"' : '') . ' sizes="'. get_image_group_size($size).'">'; if ($title && is_string($title)) { return "<figure class='figure'> $imgHtml <figcaption class='figcaption t-header-small psy1'>$title</figcaption> </figure>"; } else { echo $imgHtml; } } function date_to_unix($date) { $dateTime = DateTime::createFromFormat('d/m/Y', $date); return $dateTime->getTimestamp(); } function should_be_visible($from, $to) { $currentTime = strtotime('now'); return (date_to_unix($from) < $currentTime && $currentTime < date_to_unix($to)); } //small singleton (Yeah I know) //lazy person loader function twig_render($name, $data, $debug) { return TwigSingleton::getInstance()->getTwig()->render($name, $data); }

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.0090.00616.75
8.3.50.0120.00817.93
8.3.40.0080.01118.98
8.3.30.0120.00318.78
8.3.20.0000.00720.34
8.3.10.0080.00021.85
8.3.00.0060.00319.38
8.2.180.0120.00416.88
8.2.170.0090.00622.96
8.2.160.0150.00320.45
8.2.150.0030.00624.18
8.2.140.0080.00024.66
8.2.130.0060.00317.50
8.2.120.0080.00026.35
8.2.110.0110.00022.11
8.2.100.0090.00317.97
8.2.90.0030.00519.36
8.2.80.0080.00017.97
8.2.70.0000.00817.63
8.2.60.0030.00617.90
8.2.50.0060.00318.07
8.2.40.0040.00519.43
8.2.30.0040.00420.71
8.2.20.0060.00317.76
8.2.10.0000.00718.14
8.2.00.0040.00418.25
8.1.280.0090.00625.92
8.1.270.0030.00723.96
8.1.260.0040.00428.09
8.1.250.0080.00028.09
8.1.240.0030.00723.91
8.1.230.0040.00719.16
8.1.220.0000.00817.79
8.1.210.0040.00418.77
8.1.200.0060.00317.48
8.1.190.0050.00317.35
8.1.180.0050.00318.10
8.1.170.0080.00018.89
8.1.160.0040.00422.10
8.1.150.0000.00818.85
8.1.140.0030.00519.59
8.1.130.0040.00417.73
8.1.120.0000.00717.51
8.1.110.0050.00217.38
8.1.100.0030.00517.46
8.1.90.0050.00317.49
8.1.80.0000.00817.52
8.1.70.0070.00017.43
8.1.60.0000.00817.64
8.1.50.0050.00317.59
8.1.40.0000.00917.48
8.1.30.0060.00317.64
8.1.20.0080.00017.63
8.1.10.0000.00717.64
8.1.00.0040.00817.59
8.0.300.0080.00018.77
8.0.290.0040.00417.00
8.0.280.0070.00018.54
8.0.270.0000.00717.38
8.0.260.0030.00317.41
8.0.250.0030.00317.15
8.0.240.0000.00717.11
8.0.230.0000.00717.02
8.0.220.0040.00417.04
8.0.210.0040.00416.96
8.0.200.0040.00417.07
8.0.190.0000.00817.03
8.0.180.0070.00017.06
8.0.170.0000.00817.07
8.0.160.0080.00016.96
8.0.150.0000.00816.96
8.0.140.0070.00017.00
8.0.130.0000.00713.41
8.0.120.0040.00415.19
8.0.110.0080.00215.19
8.0.100.0040.00615.19
8.0.90.0050.00415.26
8.0.80.0110.00315.20
8.0.70.0050.00715.27
8.0.60.0050.00515.15
8.0.50.0060.00415.26
8.0.30.0090.00615.87
8.0.20.0100.00716.45
8.0.10.0090.00115.33
8.0.00.0060.01016.04
7.4.330.0000.00516.70
7.4.320.0000.00716.62
7.4.300.0060.00016.67
7.4.290.0030.00316.43
7.4.280.0070.00016.42
7.4.270.0000.00716.68
7.4.260.0030.00316.61
7.4.250.0050.00314.96
7.4.240.0020.00715.46
7.4.230.0090.00115.03
7.4.220.0020.01314.83
7.4.210.0060.00814.96
7.4.200.0060.00414.86
7.4.190.0000.01213.36
7.4.180.0060.00613.38
7.4.160.0040.01014.89
7.4.150.0110.00415.35
7.4.140.0100.00816.28
7.4.130.0090.00914.89
7.4.120.0130.00315.45
7.4.110.0090.00614.90
7.4.100.0060.00914.97
7.4.90.0030.01214.91
7.4.80.0120.00516.27
7.4.70.0070.00714.77
7.4.60.0090.00714.89
7.4.50.0040.00814.72
7.4.40.0130.00314.80
7.4.30.0060.01014.81
7.4.20.0080.00213.20
7.4.10.0100.00313.20
7.4.00.0050.00914.41
7.3.330.0000.00513.39
7.3.320.0050.00513.26
7.3.310.0030.00314.89
7.3.300.0020.00514.80
7.3.290.0060.00715.60
7.3.280.0090.00715.63
7.3.270.0070.00815.40
7.3.260.0070.00414.85
7.3.250.0050.00013.40
7.3.240.0060.00815.38
7.3.230.0050.00914.82
7.3.220.0030.00313.33
7.3.210.0060.00514.82
7.3.200.0030.01114.81
7.3.190.0070.00514.79
7.3.180.0050.00615.01
7.3.170.0100.00414.92
7.3.160.0050.00614.96
7.3.150.0000.00513.28
7.3.140.0060.00013.30
7.3.130.0000.00613.14
7.3.120.0010.00813.98
7.3.110.0030.01014.00
7.3.100.0050.00614.05
7.3.90.0040.00614.19
7.3.80.0000.01014.01
7.3.70.0030.00414.02
7.3.60.0030.00714.00
7.3.50.0070.00514.06
7.3.40.0020.00714.09
7.3.30.0020.00714.08
7.3.20.0090.00115.92
7.3.10.0070.00316.02
7.3.00.0050.00616.19
7.2.340.0100.00213.34
7.2.330.0040.01414.88
7.2.320.0090.00614.88
7.2.310.0070.01114.73
7.2.300.0120.00315.00
7.2.290.0070.00815.04
7.2.280.0080.00413.18
7.2.270.0060.00613.21
7.2.260.0130.00013.37
7.2.250.0110.00514.30
7.2.240.0030.01314.14
7.2.230.0040.00814.01
7.2.220.0090.00213.89
7.2.210.0080.00714.26
7.2.200.0050.00814.30
7.2.190.0080.00914.12
7.2.180.0070.00714.14
7.2.170.0060.00714.07
7.2.160.0120.00013.32
7.2.150.0130.00015.11
7.2.140.0040.00915.11
7.2.130.0110.00215.94
7.2.120.0070.00716.09
7.2.110.0060.00616.00
7.2.100.0080.00616.09
7.2.90.0090.00516.09
7.2.80.0070.00515.99
7.2.70.0080.00715.94
7.2.60.0080.00616.16
7.2.50.0070.00616.07
7.2.40.0080.00616.06
7.2.30.0080.00716.04
7.2.20.0110.00416.13
7.2.10.0050.00816.14
7.2.00.0050.01117.10
7.1.330.0060.00614.94
7.1.320.0090.00214.98
7.1.310.0120.00215.05
7.1.300.0090.00314.93
7.1.290.0060.00714.95
7.1.280.0070.00514.86
7.1.270.0040.00815.05
7.1.260.0070.00414.90
7.1.250.0030.01014.80
7.1.240.0120.00014.04
7.1.230.0060.00614.23
7.1.220.0070.00514.09
7.1.210.0120.00014.20
7.1.200.0070.00715.05
7.1.190.0100.00214.05
7.1.180.0000.01214.17
7.1.170.0060.00614.27
7.1.160.0060.00614.17
7.1.150.0000.01214.03
7.1.140.0070.00514.25
7.1.130.0120.00014.18
7.1.120.0040.00814.18
7.1.110.0070.00414.18
7.1.100.0070.00416.14
7.1.90.0130.00014.30
7.1.80.0080.00414.27
7.1.70.0080.00515.43
7.1.60.0060.01216.63
7.1.50.0050.01015.57
7.1.40.0000.01214.12
7.1.30.0060.00614.24
7.1.20.0060.00614.07
7.1.10.0000.01213.93
7.1.00.0060.03818.30
7.0.330.0070.00414.09
7.0.320.0120.00014.08
7.0.310.0120.00014.02
7.0.300.0100.00214.11
7.0.290.0040.00814.13
7.0.280.0110.00014.13
7.0.270.0090.00313.89
7.0.260.0080.00413.97
7.0.250.0060.00614.24
7.0.240.0090.00314.21
7.0.230.0090.00314.19
7.0.220.0090.00214.02
7.0.210.0080.00414.16
7.0.200.0040.00615.37
7.0.190.0090.00313.96
7.0.180.0090.00314.19
7.0.170.0120.00014.21
7.0.160.0090.00314.09
7.0.150.0060.00614.08
7.0.140.0120.00014.02
7.0.130.0060.00614.18
7.0.120.0130.00014.19
7.0.110.0060.00614.06
7.0.100.0120.04016.96
7.0.90.0070.03317.12
7.0.80.0060.02816.97
7.0.70.0110.04016.96
7.0.60.0110.04016.98
7.0.50.0120.03717.17
7.0.40.0090.04617.02
7.0.30.0070.04517.06
7.0.20.0070.02817.04
7.0.10.0100.04717.03
7.0.00.0050.03317.01
5.6.400.0100.00212.80
5.6.390.0040.00712.69
5.6.380.0000.01112.46
5.6.370.0000.01112.73
5.6.360.0110.00012.44
5.6.350.0060.00612.68
5.6.340.0060.00612.65
5.6.330.0110.00012.55
5.6.320.0120.00012.68
5.6.310.0060.00612.51
5.6.300.0120.00012.53
5.6.290.0070.00412.65
5.6.280.0040.01816.82
5.6.270.0070.00312.51
5.6.260.0050.00512.48
5.6.250.0080.04316.53
5.6.240.0140.03316.64
5.6.230.0080.04016.79
5.6.220.0110.03916.66
5.6.210.0080.04516.61
5.6.200.0050.02616.86
5.6.190.0130.03016.93
5.6.180.0080.04616.91
5.6.170.0110.04216.90
5.6.160.0070.04216.97
5.6.150.0120.03216.87
5.6.140.0090.04116.82
5.6.130.0090.02616.92
5.6.120.0120.04016.91
5.6.110.0100.03216.80
5.6.100.0050.04716.79
5.6.90.0060.04416.81
5.6.80.0070.04216.65
5.6.70.0070.04216.58
5.6.60.0100.03716.56
5.6.50.0090.03716.52
5.6.40.0030.04616.54
5.6.30.0060.04516.66
5.6.20.0140.02816.57
5.6.10.0100.03516.44
5.6.00.0070.04016.54
5.5.380.0160.03516.60
5.5.370.0080.03916.63
5.5.360.0070.03216.54
5.5.350.0100.04116.55
5.5.340.0210.03116.79
5.5.330.0070.03716.76
5.5.320.0060.04216.74
5.5.310.0120.03716.64
5.5.300.0120.03516.66
5.5.290.0120.03916.69
5.5.280.0070.03016.77
5.5.270.0090.03016.79
5.5.260.0100.04016.76
5.5.250.0050.04316.79
5.5.240.0110.03616.41
5.5.230.0060.03816.50
5.5.220.0140.03716.50
5.5.210.0100.03816.37
5.5.200.0090.04016.36
5.5.190.0070.04216.43
5.5.180.0070.04316.35
5.5.170.0110.00012.52
5.5.160.0100.03016.43
5.5.150.0090.03316.23
5.5.140.0090.03716.22
5.5.130.0110.04016.25
5.5.120.0070.04016.25
5.5.110.0070.04216.30
5.5.100.0140.03516.47
5.5.90.0080.03816.44
5.5.80.0100.04016.32
5.5.70.0090.04016.43
5.5.60.0050.04016.36
5.5.50.0090.03816.45
5.5.40.0090.03716.44
5.5.30.0050.03016.27
5.5.20.0080.04316.48
5.5.10.0080.04116.25
5.5.00.0100.04216.34

preferences:
54.62 ms | 401 KiB | 5 Q