Skip to content

Commit 02ae7ad

Browse files
committed
HACKS: Log frames per second of render loop
1 parent c927d61 commit 02ae7ad

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

helix-term/src/application.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,8 @@ impl Application {
278278
#[cfg(feature = "integration")]
279279
let mut idle_handled = false;
280280

281+
let mut iterations: usize = 0;
282+
281283
loop {
282284
if self.editor.should_close() {
283285
return false;
@@ -301,26 +303,31 @@ impl Application {
301303

302304
if last || self.last_render.elapsed() > LSP_DEADLINE {
303305
self.render();
306+
iterations = iterations.saturating_add(1);
304307
self.last_render = Instant::now();
305308
}
306309
}
307310
Some(payload) = self.editor.debugger_events.next() => {
308311
let needs_render = self.editor.handle_debugger_message(payload).await;
309312
if needs_render {
310313
self.render();
314+
iterations = iterations.saturating_add(1);
311315
}
312316
}
313317
Some(config_event) = self.editor.config_events.1.recv() => {
314318
self.handle_config_events(config_event);
315319
self.render();
320+
iterations = iterations.saturating_add(1);
316321
}
317322
Some(callback) = self.jobs.futures.next() => {
318323
self.jobs.handle_callback(&mut self.editor, &mut self.compositor, callback);
319324
self.render();
325+
iterations = iterations.saturating_add(1);
320326
}
321327
Some(callback) = self.jobs.wait_futures.next() => {
322328
self.jobs.handle_callback(&mut self.editor, &mut self.compositor, callback);
323329
self.render();
330+
iterations = iterations.saturating_add(1);
324331
}
325332
_ = &mut self.editor.idle_timer => {
326333
// idle timeout
@@ -332,6 +339,15 @@ impl Application {
332339
idle_handled = true;
333340
}
334341
}
342+
_ = &mut self.editor.frame_timer => {
343+
log::warn!("🏎️: {}", iterations);
344+
self.editor.frame_timer.as_mut().reset(tokio::time::Instant::now() + Duration::from_secs(1));
345+
iterations = 0;
346+
}
347+
_ = &mut self.editor.immediate_timer => {
348+
self.render();
349+
iterations = iterations.saturating_add(1);
350+
}
335351
}
336352

337353
// for integration tests only, reset the idle timer after every

helix-view/src/editor.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -676,6 +676,8 @@ pub struct Editor {
676676
pub auto_pairs: Option<AutoPairs>,
677677

678678
pub idle_timer: Pin<Box<Sleep>>,
679+
pub immediate_timer: Pin<Box<Sleep>>,
680+
pub frame_timer: Pin<Box<Sleep>>,
679681
pub last_motion: Option<Motion>,
680682

681683
pub last_completion: Option<CompleteAction>,
@@ -755,6 +757,8 @@ impl Editor {
755757
status_msg: None,
756758
autoinfo: None,
757759
idle_timer: Box::pin(sleep(conf.idle_timeout)),
760+
immediate_timer: Box::pin(sleep(Duration::from_millis(1))),
761+
frame_timer: Box::pin(sleep(Duration::from_secs(1))),
758762
last_motion: None,
759763
last_completion: None,
760764
config,

0 commit comments

Comments
 (0)