profile: Make the time and memory profilers run over IPC.

Uses the `Router` abstraction inside `ipc-channel` to avoid spawning new
threads.
This commit is contained in:
Patrick Walton 2015-07-14 18:28:57 -07:00
parent ed1b6a3513
commit f10c076180
19 changed files with 212 additions and 168 deletions

View file

@ -5,19 +5,19 @@
extern crate time as std_time;
extern crate url;
use ipc_channel::ipc::IpcSender;
use self::std_time::precise_time_ns;
use self::url::Url;
use std::sync::mpsc::Sender;
#[derive(PartialEq, Clone, PartialOrd, Eq, Ord)]
#[derive(PartialEq, Clone, PartialOrd, Eq, Ord, Deserialize, Serialize)]
pub struct TimerMetadata {
pub url: String,
pub iframe: bool,
pub incremental: bool,
}
#[derive(Clone)]
pub struct ProfilerChan(pub Sender<ProfilerMsg>);
#[derive(Clone, Deserialize, Serialize)]
pub struct ProfilerChan(pub IpcSender<ProfilerMsg>);
impl ProfilerChan {
pub fn send(&self, msg: ProfilerMsg) {
@ -26,7 +26,7 @@ impl ProfilerChan {
}
}
#[derive(Clone)]
#[derive(Clone, Deserialize, Serialize)]
pub enum ProfilerMsg {
/// Normal message used for reporting time
Time((ProfilerCategory, Option<TimerMetadata>), f64),
@ -37,7 +37,7 @@ pub enum ProfilerMsg {
}
#[repr(u32)]
#[derive(PartialEq, Clone, PartialOrd, Eq, Ord)]
#[derive(PartialEq, Clone, PartialOrd, Eq, Ord, Deserialize, Serialize)]
pub enum ProfilerCategory {
Compositing,
LayoutPerform,