Skip to content

Commit

Permalink
Add progress bar
Browse files Browse the repository at this point in the history
  • Loading branch information
ichyo committed Jun 22, 2019
1 parent 1bec8aa commit 6107a93
Show file tree
Hide file tree
Showing 5 changed files with 223 additions and 10 deletions.
207 changes: 207 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ clap = "2.33.0"
glob = "0.3.0"
rand = "0.6.5"
rayon = "1.1.0"
indicatif = "0.11.0"

[lib]
name = "icfpc"
Expand Down
5 changes: 4 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use clap::{App, Arg};
use rayon::prelude::*;
use std::fs::File;
use std::io::Write;
use indicatif::ProgressBar;

use icfpc::models::*;
use icfpc::parse::read_all_inputs;
Expand Down Expand Up @@ -36,8 +37,8 @@ fn main() {
let output_root = matches.value_of("output");

let inputs = read_all_inputs(&input_root);
let progress_bar = ProgressBar::new(inputs.len() as u64);
inputs.into_par_iter().for_each(|input| {
eprintln!("{}", input.output_file_name());
let mut output_file: Box<Write> = match output_root {
Some(output_root) => {
let output_path = format!("{}/{}", output_root, input.output_file_name());
Expand All @@ -47,5 +48,7 @@ fn main() {
None => Box::new(std::io::stdout()),
};
solve(input.task, &mut output_file);
progress_bar.inc(1);
});
progress_bar.finish();
}
Loading

0 comments on commit 6107a93

Please sign in to comment.