diff options
| -rw-r--r-- | Cargo.lock | 52 | ||||
| -rw-r--r-- | Cargo.toml | 2 | ||||
| -rw-r--r-- | src/buffer.rs | 1 | ||||
| -rw-r--r-- | src/input.rs | 1 | ||||
| -rw-r--r-- | src/main.rs | 6 | ||||
| -rw-r--r-- | src/script.rs | 1 |
6 files changed, 63 insertions, 0 deletions
@@ -33,6 +33,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "683d7910e743518b0e34f1186f92494becacb047c7b6bf616c96772180fef923" [[package]] +name = "anyhow" +version = "1.0.103" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2a4385e2e34eb35d6b3efe798b9eb88096925d87726c0798709bf56d9ed84af3" + +[[package]] name = "arbitrary" version = "1.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -194,6 +200,15 @@ dependencies = [ ] [[package]] +name = "bincode" +version = "1.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1f45e9417d87227c7a56d22e471c6206462cba514c7590c09aff4cf6d1ddcad" +dependencies = [ + "serde", +] + +[[package]] name = "bindgen" version = "0.72.1" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -1142,6 +1157,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "953f07c43838f8e6f9758cab68bf5bed85465e7587ebe0b823f1bcd81978ad3a" [[package]] +name = "lz4_flex" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ef0d4ed8669f8f8826eb00dc878084aa8f253506c4fd5e8f58f5bce72ddb97e" + +[[package]] name = "mach2" version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -1441,6 +1462,35 @@ dependencies = [ ] [[package]] +name = "puffin" +version = "0.20.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "84b514d95a258be801fde8a1ff1c974f4a4841d9750f5d1d6690fc07a5ad4049" +dependencies = [ + "anyhow", + "bincode", + "byteorder", + "cfg-if", + "itertools 0.14.0", + "lz4_flex", + "parking_lot", + "serde", +] + +[[package]] +name = "puffin_http" +version = "0.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4f912991aab1adae69d2be9455e8db0f41e5ad3da87706ab2de64908678c2c76" +dependencies = [ + "anyhow", + "crossbeam-channel", + "log", + "parking_lot", + "puffin", +] + +[[package]] name = "quote" version = "1.0.45" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -1964,6 +2014,8 @@ dependencies = [ "getrandom", "mimalloc", "postcard", + "puffin", + "puffin_http", "rustc-hash", "serde", "smol", @@ -9,6 +9,8 @@ crossterm = "0.29" getrandom = "0.4" mimalloc = "0.1" postcard = "1" +puffin = "0.20" +puffin_http = "0.17" rustc-hash = "2" serde = { version = "1", features = ["derive"] } smol = "2" 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"); |
