Skip to content

Commit 6e5cc2f

Browse files
committed
Auto-cleanup
1 parent fde4036 commit 6e5cc2f

2 files changed

Lines changed: 15 additions & 7 deletions

File tree

README.md

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,6 @@ If you have dedicated storage for worker, please provide docker access to the ex
1616
docker run --rm --network host --volume [path to storage folder]:/app/data -it subsquid/worker-benchmark:latest
1717
```
1818

19-
In this case you would need to clean up storage folder after run.
20-
21-
22-
No storage folder - no cleanup!
23-
2419
Expected output contains progress indicators, detailed performance breakdown and overall report.
2520

2621
Please note that as bulk of required bandwidth used to download initial data from infrastructure, we are measuring exactly this download speed. It may show numbers less than expected and usually not a dealbreaker as long as stated network speed is more or equal 1 Gigabit.
@@ -40,6 +35,7 @@ If you want to mess with internals, here are more details. If simply build and r
4035
- --config-url: URL to fetch benchmark description.
4136
- --config-file: filename to save benchmark description.
4237
- --force-update: re-download benchmark data even it is already downloaded.
38+
- --no-cleanup: disables auto-cleanup.
4339

4440
# 1000 samples
4541

src/main.rs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,9 @@ pub struct Cli {
8686

8787
#[arg(long, env, default_value = "false")]
8888
pub force_update: bool,
89+
90+
#[arg(long, env, default_value = "false")]
91+
pub no_cleanup: bool,
8992
}
9093

9194
#[tokio::main]
@@ -122,7 +125,7 @@ async fn main() {
122125
let mut download_speed: f64 = 0.;
123126
if should_download {
124127
let _ = download_file(&config_url, &config_file).await;
125-
let reader = fs::File::open(config_file).unwrap();
128+
let reader = fs::File::open(&config_file).unwrap();
126129
bench_set = serde_yaml::from_reader(reader).unwrap();
127130

128131
let url = bench_set.source.url.clone();
@@ -139,7 +142,7 @@ async fn main() {
139142
archive.unpack(".").unwrap();
140143
println!("Successfully decompressed and extracted");
141144
} else {
142-
let reader = fs::File::open(config_file).unwrap();
145+
let reader = fs::File::open(&config_file).unwrap();
143146
bench_set = serde_yaml::from_reader(reader).unwrap();
144147
}
145148

@@ -188,6 +191,15 @@ async fn main() {
188191
}
189192
pb.finish_with_message("Benchmarking done.");
190193

194+
// cleanup
195+
if !args.no_cleanup {
196+
for idx in 0..bench_set.len() {
197+
let path = bench_set.get_path(idx);
198+
let _ = std::fs::remove_dir_all(path);
199+
}
200+
let _ = std::fs::remove_file(config_file);
201+
}
202+
191203
let mut time_matrix: Vec<Vec<f64>> = Default::default();
192204
time_matrix.resize(width, Default::default());
193205
let chunks = time_collector.chunks(width);

0 commit comments

Comments
 (0)