diff --git a/deltachat-repl/src/cmdline.rs b/deltachat-repl/src/cmdline.rs index 079486fb2..b8db71e41 100644 --- a/deltachat-repl/src/cmdline.rs +++ b/deltachat-repl/src/cmdline.rs @@ -358,6 +358,7 @@ pub async fn cmdline(context: Context, line: &str, chat_id: &mut ChatId) -> Resu dellocations\n\ getlocations []\n\ send \n\ + send-sync \n\ sendempty\n\ sendimage []\n\ sendsticker []\n\ @@ -908,6 +909,23 @@ pub async fn cmdline(context: Context, line: &str, chat_id: &mut ChatId) -> Resu chat::send_text_msg(&context, sel_chat.as_ref().unwrap().get_id(), msg).await?; } + "send-sync" => { + ensure!(sel_chat.is_some(), "No chat selected."); + ensure!(!arg1.is_empty(), "No message text given."); + + // Send message over a dedicated SMTP connection + // and measure time. + // + // This can be used to benchmark SMTP connection establishment. + let time_start = std::time::Instant::now(); + + let msg = format!("{arg1} {arg2}"); + let mut msg = Message::new_text(msg); + chat::send_msg_sync(&context, sel_chat.as_ref().unwrap().get_id(), &mut msg).await?; + + let time_needed = time_start.elapsed(); + println!("Sent message in {time_needed:?}."); + } "sendempty" => { ensure!(sel_chat.is_some(), "No chat selected."); chat::send_text_msg(&context, sel_chat.as_ref().unwrap().get_id(), "".into()).await?; diff --git a/deltachat-repl/src/main.rs b/deltachat-repl/src/main.rs index bea6bac99..3b63667fe 100644 --- a/deltachat-repl/src/main.rs +++ b/deltachat-repl/src/main.rs @@ -179,7 +179,7 @@ const DB_COMMANDS: [&str; 11] = [ "housekeeping", ]; -const CHAT_COMMANDS: [&str; 38] = [ +const CHAT_COMMANDS: [&str; 39] = [ "listchats", "listarchived", "start-realtime", @@ -199,6 +199,7 @@ const CHAT_COMMANDS: [&str; 38] = [ "dellocations", "getlocations", "send", + "send-sync", "sendempty", "sendimage", "sendsticker",