askn / progress Goto Github PK
View Code? Open in Web Editor NEW[==..] Progress bar for Crystal Programming Language
License: MIT License
[==..] Progress bar for Crystal Programming Language
License: MIT License
Hello,
I've checked your project and it's failing to build (or the specs failed) with the latest Crystal (0.26.1) or there are no any specs so the project cannot be validated to be up to date. Your project is in Awesome Crystal list, so I'd like to ask if the project maintained?
I'll initiate a PR to remove your project from the list if you don't respond positively within 7 days.
I'm sorry if I'm wrong, because I've been checking many shards with automated script.
Thanks,
Vlad.
Is it correct that #print is defined as private? Does deny to print the bar manually depend on some reason or it was by design?
Currently progress bar is using including some statistics written to stdout. Something like this:
2018-12-20 21:26:18 UTC Generation: 8884 Iterations: 150654
2018-12-20 21:34:26 UTC Generation: 8922 Iterations: 152000
2018-12-20 23:28:48 UTC Generation: 8940 Iterations: 165670
2018-12-20 23:39:51 UTC Generation: 8999 Iterations: 188872
[โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ] 45.34 %
Because of definition (which is correct):
print(new_percent) if new_percent != old_percent
there is no progress bar shown until a hundredth of a percent will be changed.
There can be used previous_def
to override original behaviour:
class ProgressBar
def print( value = percent ) : Void
previous_def
end
end
bar.print
some_loop do
run_heavy_logic
if statistics_changed?
print_some_statistics
bar.print
end
bar.inc
end
But it is not so beautiful.
"total" greater than 19999
will trigger a graphics bugs.
require "progress"
bar = ProgressBar.new
bar.total = 10000
bar.width = 40
10000.times { |ln| bar.inc; sleep(0.001) }
puts "overflow"
require "progress"
bar = ProgressBar.new
bar.total = 50000
bar.width = 40
50000.times { |ln| bar.inc; sleep(0.001) }
puts "overflow"
When using function set(n) or done().
It seems that your forgot to define print method without an argument, something like this:
private def print()
print(@current)
end
It seems that when bar size is very large (6k) the bar is just starching over half the terminal.
Is there a way to have a constant max size for the bar ? even if you want more "members" in it ?
I tried this shard in a project that worked through about 11 million rows.
I set bar.total
to the number of rows and at about 50% memory usage had grown to about 30 GB.
After removing the progress bar in replacing it with a print statement the memory usage dropped 15 MB.
crystal --version
Crystal 0.35.1 (2020-06-19)
LLVM: 10.0.0
Default target: x86_64-apple-macosx
Similar code ("do stuff" sends line to a channel):
require "progress"
File.open("data.txt", "r") do |f|
lines = 0
f.each_line { lines += 1 }
f.rewind
bar = ProgressBar.new
bar.total = lines
f.each_line.with_index do |line, index|
# do stuff
bar.inc
end
bar.done
end
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.