From 059a7bcd7f4fe573604ea698e7ca7a1246a42143 Mon Sep 17 00:00:00 2001 From: "B. Petersen" Date: Sat, 20 Jun 2020 00:56:43 +0200 Subject: [PATCH] print time needed to build chatlist in repl tool the chatlist is the most complicated list to get from sql and is also the most used list, so it makes sense to keep an eye on the timing of that. --- examples/repl/cmdline.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/examples/repl/cmdline.rs b/examples/repl/cmdline.rs index 619988837..82b3f8c4d 100644 --- a/examples/repl/cmdline.rs +++ b/examples/repl/cmdline.rs @@ -488,6 +488,7 @@ pub async fn cmdline(context: Context, line: &str, chat_id: &mut ChatId) -> Resu } "listchats" | "listarchived" | "chats" => { let listflags = if arg0 == "listarchived" { 0x01 } else { 0 }; + let time_start = std::time::SystemTime::now(); let chatlist = Chatlist::try_load( &context, listflags, @@ -495,6 +496,9 @@ pub async fn cmdline(context: Context, line: &str, chat_id: &mut ChatId) -> Resu None, ) .await?; + let time_needed = std::time::SystemTime::now() + .duration_since(time_start) + .unwrap_or_default(); let cnt = chatlist.len(); if cnt > 0 { @@ -553,6 +557,7 @@ pub async fn cmdline(context: Context, line: &str, chat_id: &mut ChatId) -> Resu println!("Location streaming enabled."); } println!("{} chats", cnt); + println!("{:?} to create this list", time_needed); } "chat" => { if sel_chat.is_none() && arg1.is_empty() {