Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature request: progress for unknown number of steps #101

Closed
tpapp opened this issue Jul 14, 2018 · 7 comments
Closed

feature request: progress for unknown number of steps #101

tpapp opened this issue Jul 14, 2018 · 7 comments

Comments

@tpapp
Copy link
Contributor

tpapp commented Jul 14, 2018

Suppose I am reading an ex ante unknown number of records from a large file. It would be nice to do something like

prog = ProgressOnline("reading records")
while !eof(io)
    line = readline(io)
    ProgressMeter.update!(prog) # would just increment a counter, no second arg
    ... # process line
end
ProgressMeter.update!(prog, nothing) # done

while would display something like

reading records: 42000
@tpapp
Copy link
Contributor Author

tpapp commented Jul 14, 2018

FWIW, one can mimic something close with

sentinel = typemin(N)
prog = ProgressThresh(sentinel, "doing stuff")
for i in 1:N
    sleep(0.1)
    ProgressMeter.update!(prog, -i)
end
ProgressMeter.update!(prog, sentinel)

but that's a hack.

@ChrisRackauckas
Copy link

This would be solved by #102 since that logging information lets you give the update percentage.

@tpapp
Copy link
Contributor Author

tpapp commented Jul 21, 2018

#102 is nice, but this issue is about the case where I don't know the percentage, since I don't know the total.

@zsunberg
Copy link
Collaborator

zsunberg commented Oct 17, 2018

Just out of curiosity, what is the advantage of this over just printing with a carriage return at the beginning?

i = 0
while !eof(io)
    line = readline(io)
    i += 1
    print("\rProcessed $i lines")
    ... # process line
end
println()

@saschatimme
Copy link
Contributor

@zsunberg The implementation in #115 has a couple of advantages over your suggested solutions.
It also automatically keeps track of the passed time and prints it nicely.
Also you can also easily specify additional values to be printed (with the showvalues keyword). Sure, you could all do this by your own, but it is also nice if everybody doesn't have to reinvent the wheel :)

Another major benefit of the implementation in #115 is that it updates the current information only every, let's say 0.1 seconds. Depending on the task this reduces the overhead of the progress bar immensely since IO operations are usually quite expensive.

@zsunberg
Copy link
Collaborator

zsunberg commented Oct 19, 2018 via email

@martinholters
Copy link
Collaborator

Closed by #115.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants