mirror of
https://github.com/YGGverse/aquatic-crawler.git
synced 2026-03-31 17:15:35 +00:00
add timing debug
This commit is contained in:
parent
7da1df7137
commit
76c2c1c0b8
1 changed files with 13 additions and 4 deletions
17
src/main.rs
17
src/main.rs
|
|
@ -24,10 +24,12 @@ use url::Url;
|
|||
|
||||
#[tokio::main]
|
||||
async fn main() -> Result<()> {
|
||||
use chrono::Local;
|
||||
use clap::Parser;
|
||||
use tokio::time;
|
||||
|
||||
// init components
|
||||
let time_init = Local::now();
|
||||
let config = Config::parse();
|
||||
if config.debug {
|
||||
tracing_subscriber::fmt::init()
|
||||
|
|
@ -73,7 +75,7 @@ async fn main() -> Result<()> {
|
|||
.await?;
|
||||
|
||||
// begin
|
||||
println!("Crawler started");
|
||||
println!("Crawler started on {time_init}");
|
||||
let mut index = Index::init(
|
||||
config.index_capacity,
|
||||
config.index_timeout,
|
||||
|
|
@ -82,8 +84,9 @@ async fn main() -> Result<()> {
|
|||
config.export_rss.is_some() && config.index_list,
|
||||
);
|
||||
loop {
|
||||
let time_queue = Local::now();
|
||||
if config.debug {
|
||||
println!("\tQueue crawl begin...")
|
||||
println!("\tQueue crawl begin on {time_queue}...")
|
||||
}
|
||||
index.refresh();
|
||||
for source in &config.infohash {
|
||||
|
|
@ -287,8 +290,14 @@ async fn main() -> Result<()> {
|
|||
}
|
||||
if config.debug {
|
||||
println!(
|
||||
"Queue completed, {} total, await {} seconds to continue...",
|
||||
"Queue completed on {time_queue}\n\ttotal: {}\n\ttime: {}s\n\tuptime: {}s\n\tawait {} seconds to continue...",
|
||||
index.len(),
|
||||
Local::now()
|
||||
.signed_duration_since(time_queue)
|
||||
.as_seconds_f32(),
|
||||
Local::now()
|
||||
.signed_duration_since(time_init)
|
||||
.as_seconds_f32(),
|
||||
config.sleep,
|
||||
)
|
||||
}
|
||||
|
|
@ -307,7 +316,7 @@ fn save_torrent_file(t: &Torrent, i: &str, b: &[u8], d: bool) {
|
|||
}
|
||||
}
|
||||
}
|
||||
Err(e) => eprintln!("Error on save torrent file `{i}`: {e}"),
|
||||
Err(e) => eprintln!("Error on save torrent file `{i}`: `{e}`"),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue