MCPcopy Create free account
hub / github.com/bytecodealliance/wasmtime / sample

Method sample

crates/wasmtime/src/runtime/profiling.rs:203–214  ·  view source on GitHub ↗

Add a sample to the profile. This function collects a backtrace from any stack frames for allowed modules on the current stack. It should typically be called from a callback registered using [`Store::epoch_deadline_callback()`](crate::Store::epoch_deadline_callback). The `delta` parameter is the amount of CPU time that was used by this guest since the previous sample. It is allowed to pass `Durat

(&mut self, store: impl AsContext, delta: Duration)

Source from the content-addressed store, hash-verified

201 /// guest since the previous sample. It is allowed to pass `Duration::ZERO`
202 /// here if recording CPU usage information is not needed.
203 pub fn sample(&mut self, store: impl AsContext, delta: Duration) {
204 let now = Timestamp::from_nanos_since_reference(
205 self.start.elapsed().as_nanos().try_into().unwrap(),
206 );
207 let backtrace = Backtrace::new(store.as_context().0);
208 let frames = lookup_frames(&self.modules, &backtrace);
209 let stack = self
210 .profile
211 .intern_stack_frames(self.thread, frames.into_iter());
212 self.profile
213 .add_sample(self.thread, now, stack, delta.into(), 1);
214 }
215
216 /// Add a marker for transitions between guest and host to the profile.
217 /// This function should typically be called from a callback registered

Callers 1

Calls 6

lookup_framesFunction · 0.85
newFunction · 0.50
unwrapMethod · 0.45
try_intoMethod · 0.45
as_contextMethod · 0.45
into_iterMethod · 0.45

Tested by

no test coverage detected