diff options
| author | Mica White <botahamec@outlook.com> | 2026-07-03 16:17:35 -0400 |
|---|---|---|
| committer | Mica White <botahamec@outlook.com> | 2026-07-03 16:17:35 -0400 |
| commit | e8fe3415e86e18ac97216ada94002d0a03ee3c8a (patch) | |
| tree | ace0f8fd335729e8c4bb4c7d5eadbdd948e50286 /src/main.rs | |
| parent | 73ffbee638c03da132aea0e5d600ca5e8144fd8e (diff) | |
Profiling
Diffstat (limited to 'src/main.rs')
| -rw-r--r-- | src/main.rs | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/main.rs b/src/main.rs index 7c4f249..1a62ca2 100644 --- a/src/main.rs +++ b/src/main.rs @@ -14,7 +14,7 @@ use tortuise::{ static GLOBAL: MiMalloc = MiMalloc; fn get_timestamp() -> u128 { - SystemTime::UNIX_EPOCH.elapsed().unwrap().as_micros() + SystemTime::UNIX_EPOCH.elapsed().unwrap().as_nanos() } fn init_first_frame(_: &mut ScriptContext, state: &mut Box<[u8]>) { @@ -22,6 +22,7 @@ fn init_first_frame(_: &mut ScriptContext, state: &mut Box<[u8]>) { } fn render_frame_rate(ctx: &mut ScriptContext, state: &mut Box<[u8]>) { + puffin::profile_function!(); let end = get_timestamp(); let last_frame_start = u128::from_ne_bytes(*state.as_array().unwrap()); let frame_time = end - last_frame_start + 1; @@ -46,6 +47,7 @@ fn render_frame_rate(ctx: &mut ScriptContext, 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(); } @@ -91,6 +93,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) => { @@ -105,6 +110,7 @@ fn main() { }; scripts.run_scripts(&mut context, &wasm_runner, &mut files); input.reset_next_frame(); + puffin::GlobalProfiler::lock().new_frame(); } }) .unwrap(); |
