summaryrefslogtreecommitdiff
path: root/src/render_frametime.rs
diff options
context:
space:
mode:
authorMica White <botahamec@outlook.com>2026-10-31 12:38:00 -0400
committerMica White <botahamec@outlook.com>2026-10-31 12:38:00 -0400
commit3b39c7561ec71dadb0cb03a153550e9a6e2cddff (patch)
treec4d5dd4b4314371a818053c4c6741209967089b3 /src/render_frametime.rs
parent2987e310e8e6eaeaa60546bb92a61d9c3713263a (diff)
OptimizationHEADmain
Diffstat (limited to 'src/render_frametime.rs')
-rw-r--r--src/render_frametime.rs37
1 files changed, 37 insertions, 0 deletions
diff --git a/src/render_frametime.rs b/src/render_frametime.rs
new file mode 100644
index 0000000..6756fa7
--- /dev/null
+++ b/src/render_frametime.rs
@@ -0,0 +1,37 @@
+use alloc::format;
+use tortuise_script::{buffer::Cell, TortuiseScript};
+
+use crate::CONFIG;
+
+pub const RENDER_FRAMETIME: TortuiseScript = TortuiseScript {
+ start: |mut cx| {
+ let config = CONFIG.load_mut(&mut cx);
+ let fps_limit = config.framerate_limit;
+ drop(config);
+ cx.set_framerate_limit(fps_limit);
+ },
+ update: |mut cx| {
+ let frametime = cx.delta_time().as_micros();
+ let fps = 1_000_000u128.checked_div(frametime).unwrap_or(u128::MAX);
+ let frametime = format!("{frametime:05} us");
+ let counter = format!("{fps} FPS");
+
+ for (x, character) in (9..).zip(frametime.chars()) {
+ cx.add_cell(Cell {
+ character,
+ y: 14,
+ x,
+ ..Cell::default()
+ });
+ }
+ for (x, character) in (9..).zip(counter.chars()) {
+ cx.add_cell(Cell {
+ character,
+ y: 15,
+ x,
+ ..Cell::default()
+ });
+ }
+ },
+ ..TortuiseScript::empty()
+};