summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMica White <botahamec@outlook.com>2026-07-03 16:17:35 -0400
committerMica White <botahamec@outlook.com>2026-07-03 16:19:17 -0400
commitf31fda79035077a9dab8dee07a11d71fac3ba791 (patch)
treea3c8eb295fd18831cb7ff803c984c32b5a823c2b /src
parentbb7525206da1782fd9af49621aa52d87bd227838 (diff)
Profiling
Diffstat (limited to 'src')
-rw-r--r--src/buffer.rs1
-rw-r--r--src/input.rs1
-rw-r--r--src/main.rs6
-rw-r--r--src/script.rs1
4 files changed, 9 insertions, 0 deletions
diff --git a/src/buffer.rs b/src/buffer.rs
index 9e91ae7..999a32c 100644
--- a/src/buffer.rs
+++ b/src/buffer.rs
@@ -59,6 +59,7 @@ impl Buffer {
}
fn render(&mut self) -> std::io::Result<()> {
+ puffin::profile_function!();
self.cells.sort_unstable_by_key(|cell| cell.z);
queue!(self.stdout, BeginSynchronizedUpdate, Clear(ClearType::All))?;
for cell in &self.cells {
diff --git a/src/input.rs b/src/input.rs
index c86daf4..90ddbb2 100644
--- a/src/input.rs
+++ b/src/input.rs
@@ -18,6 +18,7 @@ impl InputManager {
}
pub fn reset_next_frame(&mut self) {
+ puffin::profile_function!();
self.pressed_keys.clear();
}
diff --git a/src/main.rs b/src/main.rs
index 81fffcf..14e3925 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -22,6 +22,7 @@ fn init_first_frame<'a>(_: &mut ScriptContext<'a>, state: &mut Box<[u8]>) {
}
fn render_frame_rate<'a>(ctx: &mut ScriptContext<'a>, state: &mut Box<[u8]>) {
+ puffin::profile_function!();
ctx.buffer.cells.clear();
let end = get_timestamp();
let last_frame_start = u128::from_ne_bytes(*state.as_array().unwrap());
@@ -47,6 +48,7 @@ fn render_frame_rate<'a>(ctx: &mut ScriptContext<'a>, state: &mut Box<[u8]>) {
}
fn exit_on_escape(ctx: &mut ScriptContext, _: &mut Box<[u8]>) {
+ puffin::profile_function!();
if ctx.input.is_key_pressed_this_frame(KeyCode::Esc) {
ctx.exit();
}
@@ -88,6 +90,9 @@ fn main() {
manifest.first_scene,
);
+ let server_addr = format!("127.0.0.1:{}", puffin_http::DEFAULT_PORT);
+ let _puffin_server = puffin_http::Server::new(&server_addr).unwrap();
+ puffin::set_scopes_on(true);
buffer
.render_loop(|buffer, event| match event {
Event::Key(event) => {
@@ -102,6 +107,7 @@ fn main() {
};
scripts.run_scripts(&mut context);
input.reset_next_frame();
+ puffin::GlobalProfiler::lock().new_frame();
}
})
.unwrap();
diff --git a/src/script.rs b/src/script.rs
index eeb943f..be7f6f4 100644
--- a/src/script.rs
+++ b/src/script.rs
@@ -117,6 +117,7 @@ impl<'a> ScriptManager<'a> {
}
pub fn run_scripts(&mut self, context: &mut ScriptContext<'_>) {
+ puffin::profile_function!();
for script_id in &self.active_scripts {
let Some(script) = self.scripts.get(*script_id) else {
unreachable!("The active script does not exist");