$|=1; or $|++; will turn off buffering globally and that might not be what you want because it will slow down disk writes. I guess this could be called a "cheater method", but if you 'print STDERR "progress\n"', that output shows up immediately on the console because stderr is not buffered (stdout is). Alternatively, you can call flush() on a filehandle to flush the buffers.
But for console commands that take awhile, consider just printing the status to STDERR instead of the default print of STDOUT. Of course there are some "yeah, but's" with that which are application specific.
I do congratulate you on the idea of presenting an indication of progress that actually means something! I hate this Windows graphic like when you copy files...it is a separate doo-dad that has nothing at all do with any "real" progress - the real program can hang and that thing merrily goes along with its graphical fake out.
If you wind up calling some progress bar graphical thing, be aware that graphical output is "expensive" CPU wise. Call it only when necessary (ie you expect that the progress bar will actually move on the screen).
As another point, the first time I saw this in Windows, I was really surprised because I was used to O/S'es that printed to the console so fast that you could hardly tell that it happened! But Windows is slow when it prints to the console. I don't know why that is. But that appears to be the case. And sometimes the program speeds up quite a bit when you print less.
In reply to Re: Real Time Progress Bar in console
by Marshall
in thread Real Time Progress Bar in console
by westrock2000
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |