add debug timer time
to find out that the query took the longest: reading file took 3.9429631s parsing took 348.9919ms filtering took 22.2287ms string building took 8.4869ms
This commit is contained in:
1 parent
4deb4cee6d
commit
6df07f4b53
1 file changed
+13
-5
+13
-5
@@ -12,7 +12,8 @@ async fn filtered_ics(now: web::Data<NaiveDate>) -> impl Responder {
|
||||
let now: NaiveDate = **now;
|
||||
let client = Client::new();
|
||||
let ics_url = ICS_URL;
|
||||
|
||||
|
||||
let timer = tokio::time::Instant::now();
|
||||
// Fetch the .ics content
|
||||
let response = match client.get(ics_url).send().await {
|
||||
Ok(resp) => resp,
|
||||
@@ -26,7 +27,9 @@ async fn filtered_ics(now: web::Data<NaiveDate>) -> impl Responder {
|
||||
.body(format!("Failed to read response body: {e}"));
|
||||
}
|
||||
};
|
||||
|
||||
println!("reading file took {:?}", timer.elapsed());
|
||||
|
||||
let timer = tokio::time::Instant::now();
|
||||
// Parse the .ics content
|
||||
let calendar = match body.parse::<Calendar>() {
|
||||
Ok(cal) => cal,
|
||||
@@ -35,20 +38,25 @@ async fn filtered_ics(now: web::Data<NaiveDate>) -> impl Responder {
|
||||
.body(format!("Failed to parse ICS file: {e}"));
|
||||
}
|
||||
};
|
||||
|
||||
println!("parsing took {:?}", timer.elapsed());
|
||||
|
||||
let start_date = now - TimeDelta::days(365);
|
||||
let end_date = now + TimeDelta::days(365);
|
||||
// Filter events by summary and date range
|
||||
let timer = tokio::time::Instant::now();
|
||||
let filtered_events = filter_events_by_date_and_regex(calendar, start_date, end_date);
|
||||
|
||||
println!("filtering took {:?}", timer.elapsed());
|
||||
|
||||
// Create a new calendar with filtered events
|
||||
let filtered_calendar = Calendar {
|
||||
components: filtered_events,
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
|
||||
// Serialize the filtered calendar
|
||||
let timer = tokio::time::Instant::now();
|
||||
let ics_output = filtered_calendar.to_string();
|
||||
println!("string building took {:?}", timer.elapsed());
|
||||
|
||||
HttpResponse::Ok()
|
||||
.content_type("text/calendar")
|
||||
|
||||
Reference in new issue
Block a user