No way to reset start time in helper BaseConsole::showProgress #1293

Closed
sergebezborodov opened this Issue Nov 22, 2013 · 1 comment

Comments

Projects
None yet
2 participants
@sergebezborodov
Contributor

sergebezborodov commented Nov 22, 2013

Hi

My console app have several long time operations which i show with Console::showProgress. But it uses internal static var $start.

It is no way to reset it for next operations.

@ghost ghost assigned cebe Nov 22, 2013

@cebe cebe closed this in be911e1 Dec 11, 2013

@cebe

This comment has been minimized.

Show comment
Hide comment
@cebe

cebe Dec 11, 2013

Member

Created a better implementation with three methods:

Usage:

Console::startProgress(0, 1000);
for ($n = 0; $n <= 1000; $n++) {
    usleep(10000);
    Console::updateProgress($n, 1000);
}
Console::endProgress();
[=====>                                                ] 14% (140/1000) ETA: 12 sec.

A git clone like progress is also possible:

Console::startProgress(0, 1000, 'Counting objects: ', false);
for ($n = 0; $n <= 1000; $n++) {
    usleep(10000);
    Console::updateProgress($n, 1000);
}
Console::endProgress('done.' . PHP_EOL);
Counting objects: 14% (140/1000) ETA: 12 sec.
Member

cebe commented Dec 11, 2013

Created a better implementation with three methods:

Usage:

Console::startProgress(0, 1000);
for ($n = 0; $n <= 1000; $n++) {
    usleep(10000);
    Console::updateProgress($n, 1000);
}
Console::endProgress();
[=====>                                                ] 14% (140/1000) ETA: 12 sec.

A git clone like progress is also possible:

Console::startProgress(0, 1000, 'Counting objects: ', false);
for ($n = 0; $n <= 1000; $n++) {
    usleep(10000);
    Console::updateProgress($n, 1000);
}
Console::endProgress('done.' . PHP_EOL);
Counting objects: 14% (140/1000) ETA: 12 sec.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment