luaur_common/methods/
optional_tail_scope_optional_tail_scope_time_trace.rs1use crate::functions::get_clock_microseconds::get_clock_microseconds;
2use crate::functions::get_thread_context::get_thread_context;
3use crate::records::optional_tail_scope::OptionalTailScope;
4use crate::FFlag::DebugLuauTimeTracing;
5
6impl OptionalTailScope {
7 pub fn optional_tail_scope(token: u16, threshold: u32) -> Self {
8 let context = get_thread_context();
9 let mut scope = Self {
10 context: context as *mut _,
11 token,
12 threshold,
13 microsec: 0,
14 pos: 0,
15 };
16
17 if DebugLuauTimeTracing.get() {
18 scope.pos = context.events.len() as u32;
19 scope.microsec = get_clock_microseconds();
20 }
21
22 scope
23 }
24}