Merge pull request #17 from tgabi333/master
More precise progress indication
This commit is contained in:
commit
efc4ca21a6
1 changed files with 9 additions and 4 deletions
|
|
@ -152,15 +152,20 @@ abstract class ProgressHelper implements HelperInterface
|
||||||
$currentDuration = $this->convertDuration($matches[2]);
|
$currentDuration = $this->convertDuration($matches[2]);
|
||||||
$currentTime = $this->microtimeFloat();
|
$currentTime = $this->microtimeFloat();
|
||||||
$currentSize = trim(str_replace('kb', '', strtolower(($matches[1]))));
|
$currentSize = trim(str_replace('kb', '', strtolower(($matches[1]))));
|
||||||
$percent = $currentDuration/ $this->duration;
|
$percent = max(0, min(1, $currentDuration / $this->duration));
|
||||||
|
|
||||||
if ($this->lastOutput !== null) {
|
if ($this->lastOutput !== null) {
|
||||||
$delta = $currentTime - $this->lastOutput;
|
$delta = $currentTime - $this->lastOutput;
|
||||||
$deltaSize = $currentSize - $this->currentSize;
|
$deltaSize = $currentSize - $this->currentSize;
|
||||||
$rate = $deltaSize * $delta;
|
$rate = $deltaSize * $delta;
|
||||||
$totalDuration = $this->totalSize / $rate;
|
if ($rate > 0) {
|
||||||
$this->remaining = floor($totalDuration - ($totalDuration * $percent));
|
$totalDuration = $this->totalSize / $rate;
|
||||||
$this->rate = floor($rate);
|
$this->remaining = floor($totalDuration - ($totalDuration * $percent));
|
||||||
|
$this->rate = floor($rate);
|
||||||
|
} else {
|
||||||
|
$this->remaining = 0;
|
||||||
|
$this->rate = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->percent = floor($percent * 100);
|
$this->percent = floor($percent * 100);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue