ext/pf2/src/signal_scheduler.rs in pf2-0.5.2 vs ext/pf2/src/signal_scheduler.rs in pf2-0.6.0
- old
+ new
@@ -3,10 +3,11 @@
use crate::profile::Profile;
use crate::profile_serializer::ProfileSerializer;
use crate::ruby_internal_apis::rb_thread_getcpuclockid;
use crate::sample::Sample;
use crate::scheduler::Scheduler;
+use crate::serialization::serializer::ProfileSerializer2;
use crate::session::configuration::{self, Configuration};
use core::panic;
use std::ffi::{c_int, c_void, CString};
use std::mem::ManuallyDrop;
@@ -44,20 +45,25 @@
fn stop(&self) -> VALUE {
// Finalize
match self.profile.try_write() {
Ok(mut profile) => {
profile.flush_temporary_sample_buffer();
+ profile.end_instant = Some(std::time::Instant::now());
}
Err(_) => {
println!("[pf2 ERROR] stop: Failed to acquire profile lock.");
return Qfalse.into();
}
}
let profile = self.profile.try_read().unwrap();
log::debug!("Number of samples: {}", profile.samples.len());
- let serialized = ProfileSerializer::serialize(&profile);
+ let serialized = if self.configuration.use_experimental_serializer {
+ ProfileSerializer2::new().serialize(&profile)
+ } else {
+ ProfileSerializer::serialize(&profile)
+ };
let serialized = CString::new(serialized).unwrap();
unsafe { rb_str_new_cstr(serialized.as_ptr()) }
}
fn on_new_thread(&self, thread: VALUE) {