Skip to content

LandslideSIM/SimulationLogging.jl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

5 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

SimulationLogging.jl

CI Version AI

A lightweight and elegant progress bar for Julia, designed for long-running simulations and computations.

Note

The simulation information export function will be involved later.

Features

  • ✨ Minimal & Clean - Simple API with beautiful Unicode progress bars
  • ⚑ High Performance - Time-based throttling to avoid excessive updates
  • 🎨 Customizable - Configure colors, width, update intervals, and more
  • πŸ“Š ETA Display - Automatic estimation of remaining time
  • πŸ”§ Zero Dependencies - Only uses Julia's standard library

Installation

using Pkg
Pkg.add("SimulationLogging")

Quick Start

using SimulationLogging

# Create a progress bar
prog = MiniProgressBar(
    max = 100,
    header = "processing",
    color = :green,
    update_interval = 1.0  # Update every second
)

# Start tracking progress
start_progress(stdout, prog)

# Update progress in your loop
for i in 1:100
    prog.current = i
    show_progress(stdout, prog)
    
    # Your computation here
    sleep(0.05)
end

# Finish and show final result
end_progress(stdout, prog)

Output:

[ Info: processing ━━━━━━━━━━━━━━━━╺━━━━━━━━━━━━━━━━━━━━━━━ 41% ETA: 00:00:03 s

... (refresh in-place)

[ Info: processing ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ Time: 00:00:05 s

API Reference

MiniProgressBar

Create a progress bar with customizable options:

MiniProgressBar(;
    max::Int = 1,                      # Maximum value
    header::String = "",               # Header text
    color::Symbol = :nothing,          # Bar color (:green, :blue, :red, etc.)
    width::Int = 40,                   # Progress bar width
    current::Int = 0,                  # Current progress value
    indent::Int = 4,                   # Left indentation
    show_eta::Bool = true,             # Show estimated time remaining
    update_interval::Float64 = 3.0,    # Minimum seconds between updates
    always_reprint::Bool = false       # Force update every call
)

Functions

start_progress(io::IO, p::MiniProgressBar)

Initialize the progress bar and hide the cursor.

show_progress(io::IO, p::MiniProgressBar)

Display the current progress. Automatically throttled by update_interval.

end_progress(io::IO, p::MiniProgressBar; keep_bar::Bool = true)

Finalize the progress bar and restore the cursor.

  • keep_bar = true: Keep the bar visible on screen
  • keep_bar = false: Clear the bar from display

Examples

Custom Colors and Styles

prog = MiniProgressBar(
    max = 1000,
    header = "Training",
    color = :blue,
    width = 50,
    update_interval = 0.5
)

Disable ETA

prog = MiniProgressBar(
    max = 100,
    header = "Loading",
    show_eta = false
)

Fast Updates

prog = MiniProgressBar(
    max = 1000000,
    header = "Computing",
    update_interval = 0.1,  # Update every 100ms
    always_reprint = false   # Respect throttling
)

Performance Tips

  • Use time throttling: The default update_interval = 3.0 seconds prevents excessive terminal updates
  • Avoid small intervals: For very large loops (millions of iterations), use intervals β‰₯ 0.1s
  • Let it throttle: Even if you call show_progress() every iteration, it will automatically skip redundant updates

Requirements

  • Julia β‰₯ 1.11
  • No external dependencies

License

MIT License - see LICENSE file for details

Author & Acknowledgement

Caution

I primarily based my implementation on Pkg.jl, with the remaining features mainly developed using Claude Sonnet 4.5, including this very statement itself. πŸ€–

About

πŸ“ A logging system designed for simulation.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Languages