Skip to content

Commit f679c9a

Browse files
committed
feat(server): warn if encoding takes >10ms
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
1 parent 3e738a9 commit f679c9a

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

crates/ironrdp-server/src/lib.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,16 @@ pub use handler::*;
2828
pub use helper::*;
2929
pub use server::*;
3030
pub use sound::*;
31+
32+
#[macro_export]
33+
macro_rules! time_warn {
34+
($context:expr, $threshold:expr, $op:expr) => {{
35+
let start = std::time::Instant::now();
36+
let result = $op;
37+
let duration = start.elapsed().as_millis();
38+
if duration > $threshold {
39+
::tracing::warn!("{} took {} ms!", $context, duration);
40+
}
41+
result
42+
}};
43+
}

crates/ironrdp-server/src/server.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ use crate::clipboard::CliprdrServerFactory;
3232
use crate::display::{DisplayUpdate, RdpServerDisplay};
3333
use crate::encoder::UpdateEncoder;
3434
use crate::handler::RdpServerInputHandler;
35-
use crate::{builder, capabilities, SoundServerFactory};
35+
use crate::{builder, capabilities, time_warn, SoundServerFactory};
3636

3737
#[derive(Clone)]
3838
pub struct RdpServerOptions {
@@ -417,7 +417,7 @@ impl RdpServer {
417417
let mut fragmenter = match update {
418418
DisplayUpdate::Bitmap(bitmap) => {
419419
let (enc, res) = task::spawn_blocking(move || {
420-
let res = encoder.bitmap(bitmap).map(|r| r.into_owned());
420+
let res = time_warn!("Encoding bitmap", 10, encoder.bitmap(bitmap).map(|r| r.into_owned()));
421421
(encoder, res)
422422
})
423423
.await?;

0 commit comments

Comments
 (0)