Skip to content

Support for ETA? #46

Open
Open

Description

@juliohm

One of the nicest features of ProgressMeter.jl is the ability to show the ETA. Can this package also show ETA in Pluto cells?

Activity

  1. cvigilv commented on Aug 19, 2026

    @cvigilv

    An example to solve this issue in a multithreaded for loop:

    """Log ETA in HH:MM:SS format"""
    function eta_hms(t0, tnow, total, done)
        s = round(Int, (tnow - t0) / done * (total - done))
        return string(
            lpad(s ÷ 3600, 2, '0'),
            ':',
            lpad(s % 3600 ÷ 60, 2, '0'),
            ':',
            lpad(s % 60, 2, '0')
        )
    end
    
    begin
        n = length(trees)
        D = Matrix{Float64}(undef, n, n)
    
        metric = RobinsonFoulds()   # or RobinsonFoulds()
    
        t0 = time()
        N_REPS = n * (n - 1) ÷ 2
    
        @withprogress begin
            it = Threads.Atomic{Int}(0)                                                   # *
            Threads.@threads for i in 1:n
                for j in (i + 1):n
                    d = metric(trees[i], trees[j])
                    D[i, j] = d
                    D[j, i] = d
                    Threads.atomic_add!(it, 1)                                            # *
                    if it[] % 1000 == 0 || it[] == N_REPS                                 # *
                        @logprogress "$(eta_hms(t0, time(), N_REPS, it[]))" it[] / N_REPS # *
                    end                                                                   # *
                end
                D[i, i] = 0.0
            end
        end
    end

    This is run inside a Pluto notebook (ignore the specifics of my example, the important parts are "highlighted" with the comments on the side)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions