mirror of
https://github.com/servo/servo.git
synced 2025-07-08 07:53:40 +01:00
Add support for IpcBytesReceiver in profile_traits::ipc - #21704
This commit is contained in:
parent
fc0c191246
commit
3e8f7fcefd
4 changed files with 55 additions and 0 deletions
|
@ -151,6 +151,7 @@ impl Formattable for ProfilerCategory {
|
|||
ProfilerCategory::TimeToFirstContentfulPaint => "Time To First Contentful Paint",
|
||||
ProfilerCategory::TimeToInteractive => "Time to Interactive",
|
||||
ProfilerCategory::IpcReceiver => "Blocked at IPC Receive",
|
||||
ProfilerCategory::IpcBytesReceiver => "Blocked at IPC Bytes Receive",
|
||||
ProfilerCategory::ApplicationHeartbeat => "Application Heartbeat",
|
||||
};
|
||||
format!("{}{}", padding, name)
|
||||
|
|
|
@ -53,3 +53,33 @@ where
|
|||
};
|
||||
Ok((ipc_sender, profiled_ipc_receiver))
|
||||
}
|
||||
|
||||
pub struct IpcBytesReceiver
|
||||
{
|
||||
ipc_bytes_receiver: ipc::IpcBytesReceiver,
|
||||
time_profile_chan: ProfilerChan,
|
||||
}
|
||||
|
||||
impl IpcBytesReceiver
|
||||
{
|
||||
pub fn recv(&self) -> Result<Vec<u8>, bincode::Error> {
|
||||
time::profile(
|
||||
ProfilerCategory::IpcBytesReceiver,
|
||||
None,
|
||||
self.time_profile_chan.clone(),
|
||||
move || self.ipc_bytes_receiver.recv(),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
pub fn bytes_channel(
|
||||
time_profile_chan: ProfilerChan,
|
||||
) -> Result<(ipc::IpcBytesSender, IpcBytesReceiver), Error>
|
||||
{
|
||||
let (ipc_bytes_sender, ipc_bytes_receiver) = ipc::bytes_channel()?;
|
||||
let profiled_ipc_bytes_receiver = IpcBytesReceiver {
|
||||
ipc_bytes_receiver,
|
||||
time_profile_chan,
|
||||
};
|
||||
Ok((ipc_bytes_sender, profiled_ipc_bytes_receiver))
|
||||
}
|
||||
|
|
|
@ -110,6 +110,7 @@ pub enum ProfilerCategory {
|
|||
TimeToFirstContentfulPaint = 0x81,
|
||||
TimeToInteractive = 0x82,
|
||||
IpcReceiver = 0x83,
|
||||
IpcBytesReceiver = 0x84,
|
||||
ApplicationHeartbeat = 0x90,
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue