2024-04-29 13:56:04 -07:00
|
|
|
use ruma::events::room::message::RoomMessageEventContent;
|
|
|
|
|
2024-07-27 00:11:41 +00:00
|
|
|
use crate::{admin_command, admin_command_dispatch, Result};
|
2024-04-29 13:56:04 -07:00
|
|
|
|
2024-07-27 00:11:41 +00:00
|
|
|
#[admin_command_dispatch]
|
2024-07-24 00:13:03 +00:00
|
|
|
#[derive(Debug, clap::Subcommand)]
|
2024-06-23 09:06:25 +00:00
|
|
|
pub(crate) enum TesterCommand {
|
2024-04-29 13:56:04 -07:00
|
|
|
Tester,
|
2024-06-23 07:11:00 +00:00
|
|
|
Timer,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[inline(never)]
|
|
|
|
#[rustfmt::skip]
|
|
|
|
#[allow(unused_variables)]
|
2024-07-27 00:11:41 +00:00
|
|
|
#[admin_command]
|
|
|
|
async fn tester(&self) -> Result<RoomMessageEventContent> {
|
2024-06-23 07:11:00 +00:00
|
|
|
|
|
|
|
Ok(RoomMessageEventContent::notice_plain("completed"))
|
|
|
|
}
|
|
|
|
|
|
|
|
#[inline(never)]
|
|
|
|
#[rustfmt::skip]
|
2024-07-27 00:11:41 +00:00
|
|
|
#[admin_command]
|
|
|
|
async fn timer(&self) -> Result<RoomMessageEventContent> {
|
2024-06-23 07:11:00 +00:00
|
|
|
let started = std::time::Instant::now();
|
2024-07-27 00:11:41 +00:00
|
|
|
timed(self.body);
|
2024-06-23 07:11:00 +00:00
|
|
|
|
|
|
|
let elapsed = started.elapsed();
|
|
|
|
Ok(RoomMessageEventContent::notice_plain(format!("completed in {elapsed:#?}")))
|
2024-04-29 13:56:04 -07:00
|
|
|
}
|
2024-06-23 07:11:00 +00:00
|
|
|
|
|
|
|
#[inline(never)]
|
|
|
|
#[rustfmt::skip]
|
|
|
|
#[allow(unused_variables)]
|
|
|
|
fn timed(body: &[&str]) {
|
|
|
|
|
2024-04-29 13:56:04 -07:00
|
|
|
}
|