3v4l.org

run code in 300+ PHP versions simultaneously
<?php <?php /** * Progress bar for a lengthy PHP process * http://spidgorny.blogspot.com/2012/02/progress-bar-for-lengthy-php-process.html */ class ProgressBar { var $percentDone = 0; var $pbid; var $pbarid; var $tbarid; var $textid; var $decimals = 1; function __construct($percentDone = 0) { $this->pbid = 'pb'; $this->pbarid = 'progress-bar'; $this->tbarid = 'transparent-bar'; $this->textid = 'pb_text'; $this->percentDone = $percentDone; } function render() { //print ($GLOBALS['CONTENT']); //$GLOBALS['CONTENT'] = ''; print($this->getContent()); $this->flush(); //$this->setProgressBarProgress(0); } function getContent() { $this->percentDone = floatval($this->percentDone); $percentDone = number_format($this->percentDone, $this->decimals, '.', '') .'%'; $content .= '<div id="'.$this->pbid.'" class="pb_container"> <div id="'.$this->textid.'" class="'.$this->textid.'">'.$percentDone.'</div> <div class="pb_bar"> <div id="'.$this->pbarid.'" class="pb_before" style="width: '.$percentDone.';"></div> <div id="'.$this->tbarid.'" class="pb_after"></div> </div> <br style="height: 1px; font-size: 1px;"/> </div> <style> .pb_container { position: relative; } .pb_bar { width: 100%; height: 1.3em; border: 1px solid silver; -moz-border-radius-topleft: 5px; -moz-border-radius-topright: 5px; -moz-border-radius-bottomleft: 5px; -moz-border-radius-bottomright: 5px; -webkit-border-top-left-radius: 5px; -webkit-border-top-right-radius: 5px; -webkit-border-bottom-left-radius: 5px; -webkit-border-bottom-right-radius: 5px; } .pb_before { float: left; height: 1.3em; background-color: #43b6df; -moz-border-radius-topleft: 5px; -moz-border-radius-bottomleft: 5px; -webkit-border-top-left-radius: 5px; -webkit-border-bottom-left-radius: 5px; } .pb_after { float: left; background-color: #FEFEFE; -moz-border-radius-topright: 5px; -moz-border-radius-bottomright: 5px; -webkit-border-top-right-radius: 5px; -webkit-border-bottom-right-radius: 5px; } .pb_text { padding-top: 0.1em; position: absolute; left: 48%; } </style>'."\r\n"; return $content; } function setProgressBarProgress($percentDone, $text = '') { $this->percentDone = $percentDone; $text = $text ? $text : number_format($this->percentDone, $this->decimals, '.', '').'%'; print(' <script type="text/javascript"> if (document.getElementById("'.$this->pbarid.'")) { document.getElementById("'.$this->pbarid.'").style.width = "'.$percentDone.'%";'); if ($percentDone == 100) { print('document.getElementById("'.$this->pbid.'").style.display = "none";'); } else { print('document.getElementById("'.$this->tbarid.'").style.width = "'.(100-$percentDone).'%";'); } if ($text) { print('document.getElementById("'.$this->textid.'").innerHTML = "'.htmlspecialchars($text).'";'); } print('}</script>'."\n"); $this->flush(); } function flush() { print str_pad('', intval(ini_get('output_buffering')))."\n"; //ob_end_flush(); flush(); } } echo 'Starting&hellip;<br />'; $p = new ProgressBar(); echo '<div style="width: 300px;">'; $p->render(); echo '</div>'; for ($i = 0; $i < ($size = 100); $i++) { $p->setProgressBarProgress($i*100/$size); usleep(1000000*0.1); } $p->setProgressBarProgress(100); echo 'Done.<br />';

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)
5.4.320.0080.03512.50
5.4.310.0070.03912.49
5.4.300.0060.03912.50
5.4.290.0080.04912.49
5.4.280.0080.03612.39
5.4.270.0070.04112.39
5.4.260.0080.03712.39
5.4.250.0080.04212.39
5.4.240.0080.03712.39
5.4.230.0070.03712.38
5.4.220.0060.03912.38
5.4.210.0080.04412.38
5.4.200.0070.03712.38
5.4.190.0080.03712.38
5.4.180.0050.03712.38
5.4.170.0070.03912.39
5.4.160.0050.04012.38
5.4.150.0090.03412.38
5.4.140.0070.03612.07
5.4.130.0070.03612.05
5.4.120.0070.04112.01
5.4.110.0080.03512.01
5.4.100.0070.03812.01
5.4.90.0060.04412.01
5.4.80.0080.03812.01
5.4.70.0060.03712.00
5.4.60.0070.03612.00
5.4.50.0080.03812.01
5.4.40.0050.03712.00
5.4.30.0080.03911.99
5.4.20.0070.03711.99
5.4.10.0050.03811.99
5.4.00.0070.03411.49
5.3.290.0080.04012.80
5.3.280.0070.04012.71
5.3.270.0060.03912.72
5.3.260.0070.04112.72
5.3.250.0050.03812.72
5.3.240.0060.03712.72
5.3.230.0070.04212.71
5.3.220.0090.03712.68
5.3.210.0060.04012.68
5.3.200.0070.03712.68
5.3.190.0080.04512.68
5.3.180.0090.04012.67
5.3.170.0070.04312.67
5.3.160.0100.04212.68
5.3.150.0070.04112.67
5.3.140.0080.03912.66
5.3.130.0070.04212.66
5.3.120.0090.04012.66
5.3.110.0060.03912.66
5.3.100.0070.03912.12
5.3.90.0050.03712.09
5.3.80.0060.04112.08
5.3.70.0060.03612.08
5.3.60.0090.04012.06
5.3.50.0060.03812.00
5.3.40.0070.04212.00
5.3.30.0060.03511.95
5.3.20.0070.03511.73
5.3.10.0090.03911.70
5.3.00.0070.03711.69
5.2.170.0060.0319.18
5.2.160.0060.0339.19
5.2.150.0050.0369.18
5.2.140.0070.0309.18
5.2.130.0060.0309.14
5.2.120.0050.0339.14
5.2.110.0050.0299.15
5.2.100.0050.0299.14
5.2.90.0050.0339.15
5.2.80.0090.0309.14
5.2.70.0040.0329.14
5.2.60.0040.0349.09
5.2.50.0060.0339.06
5.2.40.0060.0279.04
5.2.30.0050.0309.02
5.2.20.0060.0289.01
5.2.10.0040.0308.93
5.2.00.0040.0318.79
5.1.60.0050.0238.07
5.1.50.0040.0258.07
5.1.40.0040.0268.05
5.1.30.0050.0278.40
5.1.20.0050.0278.42
5.1.10.0060.0258.14
5.1.00.0050.0278.14
5.0.50.0040.0206.63
5.0.40.0060.0176.48
5.0.30.0030.0326.30
5.0.20.0040.0206.27
5.0.10.0040.0216.24
5.0.00.0030.0346.23
4.4.90.0040.0154.78
4.4.80.0030.0204.76
4.4.70.0040.0174.75
4.4.60.0040.0154.75
4.4.50.0040.0164.77
4.4.40.0010.0264.71
4.4.30.0030.0154.76
4.4.20.0030.0154.84
4.4.10.0030.0174.85
4.4.00.0020.0254.76
4.3.110.0030.0174.67
4.3.100.0030.0164.66
4.3.90.0040.0164.63
4.3.80.0020.0264.58
4.3.70.0040.0174.63
4.3.60.0040.0154.63
4.3.50.0040.0164.63
4.3.40.0020.0254.54
4.3.30.0020.0163.28
4.3.20.0020.0163.26
4.3.10.0040.0143.22
4.3.00.0070.01018.23

preferences:
138.08 ms | 1398 KiB | 7 Q