tqdm v0.0.2 Tqdm

Tqdm easily adds a CLI progress bar to any enumerable.

Just wrap Lists, Maps, Streams, or anything else that implements Enumerable with Tqdm.tqdm:

for _ <- Tqdm.tqdm(1..1000) do
  :timer.sleep(10)
end

# or

1..1000
|> Tqdm.tqdm()
|> Enum.map(fn _ -> :timer.sleep(10) end)

# or even...

1..1000
|> Stream.map(fn -> :timer.sleep(10) end)
|> Tqdm.tqdm()
|> Stream.run()

# |###-------| 392/1000 39.0% [elapsed: 00:00:04.627479 left: 00:00:07, 84.71 iters/sec]

Summary

Functions

Wrap the given enumerable and print a CLI progress bar

Types

option ::
  {:description, String.t} |
  {:total, non_neg_integer} |
  {:clear, boolean} |
  {:device, IO.device} |
  {:min_interval, non_neg_integer} |
  {:min_iterations, non_neg_integer} |
  {:total_segments, non_neg_integer}

Functions

tqdm(enumerable, options \\ [])

Wrap the given enumerable and print a CLI progress bar.

options may be provided:

  • :description - a short string that is displayed on the progress bar. For example, if the string "Processing values" is provided for this option:

    # Processing values: |###-------| 349/1000 35.0% [elapsed: 00:00:06.501472 left: 00:00:12, 53.68 iters/sec]
  • :total - by default, Tdqm will use Enum.count to count how many elements are in the given enumerable. For large amounts of data, or streams, this may not be appropriate. You can provide your own total with this option. You may provide an estimate, and if the actual count exceeds this value, the progress bar will change to an indeterminate mode:

    # 296 [elapsed: 00:00:03.500038, 84.57 iters/sec]

    You can also force the indeterminate mode by passing 0.

  • :clear - by default, Tqdm will clear the progress bar after the enumeration is complete. If you pass false for this option, the progress bar will persist, instead.

  • :device - by default, Tqdm writes to :stderr. You can provide any IO.device to this option to use it instead of the default.

  • :min_interval - by default, Tqdm will only print progress updates every 100ms. You can increase or decrease this value using this option.

  • :min_iterations - by default, Tqdm will check if the :min_interval has passed for every iteration. Passing a value for this option will skip this check until at least :min_iterations iterations have passed.

  • :total_segments - by default, Tqdm will split its progress bar into 10 segments. You can customize this by passing a different value for this option.