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)
| 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 |
no test coverage detected