diff --git a/src/admin/tester/mod.rs b/src/admin/tester/mod.rs index 8350fe14..69dc7540 100644 --- a/src/admin/tester/mod.rs +++ b/src/admin/tester/mod.rs @@ -2,13 +2,41 @@ use ruma::events::room::message::RoomMessageEventContent; use crate::Result; -#[cfg_attr(test, derive(Debug))] #[derive(clap::Subcommand)] +#[cfg_attr(test, derive(Debug))] pub(super) enum TesterCommands { Tester, + Timer, } -pub(super) async fn process(command: TesterCommands, _body: Vec<&str>) -> Result { - Ok(match command { - TesterCommands::Tester => RoomMessageEventContent::notice_plain(String::from("completed")), - }) + +pub(super) async fn process(command: TesterCommands, body: Vec<&str>) -> Result { + match command { + TesterCommands::Tester => tester(body).await, + TesterCommands::Timer => timer(body).await, + } +} + +#[inline(never)] +#[rustfmt::skip] +#[allow(unused_variables)] +async fn tester(body: Vec<&str>) -> Result { + + Ok(RoomMessageEventContent::notice_plain("completed")) +} + +#[inline(never)] +#[rustfmt::skip] +async fn timer(body: Vec<&str>) -> Result { + let started = std::time::Instant::now(); + timed(&body); + + let elapsed = started.elapsed(); + Ok(RoomMessageEventContent::notice_plain(format!("completed in {elapsed:#?}"))) +} + +#[inline(never)] +#[rustfmt::skip] +#[allow(unused_variables)] +fn timed(body: &[&str]) { + }