I’m not sure whether this is a Julia question, or a Jupyter question, but anyway … I’m working with Julia in a Jupyter notebook (within VSCode on Windows). This is an environment I’m very happy with, and it suits me well. The trouble is that I have some functions that - for particular values of their parameters - take a long time to compute. And a progress bar, or even an occasional println statement during execution would be helpful. But in Jupyter (at least in VSCode), there is no output from the cell until it is completed.
Is there any nice way of getting information about execution of a function actually during its execution?
Thank you - yes ProgressMeter works well on an indexed loop. The trouble is that I’m using a function from the Graphs package, which is known to be slow (requires a lot of computation), and I’m not sure how to meter it. I might ask on its GitHub page.
Offtopic, there are some problems here that I should point out:
If you compare to the eccentricities(g) implementation, you can see that you are calculating weights(G) over and over (or is this function just a “free” view?). Possibly better to compute distmx = weights(G) outside the loop, and then call eccentricity(G,v,distmx).
eccs =  is an Any array, whereas concretely typed collections are generally preferred, e.g. eccs = eltype(distmx) where distmx = weights(G) as above.
append!(eccs, [eccentricity(G,v)]) allocates a 1-element array just to append it … better to do push!(eccs, eccentricity(G,v)). (You could also pre-allocate the array eccs and then just assign to it, since the length is known in advance, but probably not worth the trouble since eccentricity is expensive and push! is cheap. You could also use ProgressMeter.progress.map)
Many thanks indeed! That is excellent advice - you will see I’m somewhat of a Julia/Graphs newbie. (I’ve worked with Julia before, but I’ve done very little computations with graphs, in any language.) Using push instead of append! is something I guess I should have known … but bad habits from other languages die hard. And in fact most of my previous computations have been small enough that efficiency tweaks are unnecessary. I’m usually quite satisfied if something just works!
Thank you again - I very much appreciate your detailed and generous response.