mirror of
https://github.com/servo/servo.git
synced 2025-07-17 12:23:40 +01:00
Consolidate ProfilerMetadata and TimerMetadata.
There is no good reason to have the two types. This also means that the result of LayoutTask::profiler_metadata no longer borrows the LayoutTask, which I'll need later.
This commit is contained in:
parent
3780fb7fe0
commit
ff0acccc06
8 changed files with 28 additions and 37 deletions
|
@ -44,7 +44,7 @@ use opaque_node::OpaqueNodeMethods;
|
||||||
use parallel::{self, WorkQueueData};
|
use parallel::{self, WorkQueueData};
|
||||||
use profile_traits::mem::{self, Report, ReportKind, ReportsChan};
|
use profile_traits::mem::{self, Report, ReportKind, ReportsChan};
|
||||||
use profile_traits::time::{TimerMetadataFrameType, TimerMetadataReflowType};
|
use profile_traits::time::{TimerMetadataFrameType, TimerMetadataReflowType};
|
||||||
use profile_traits::time::{self, ProfilerMetadata, profile};
|
use profile_traits::time::{self, TimerMetadata, profile};
|
||||||
use query::{LayoutRPCImpl, process_content_box_request, process_content_boxes_request};
|
use query::{LayoutRPCImpl, process_content_box_request, process_content_boxes_request};
|
||||||
use query::{MarginPadding, MarginRetrievingFragmentBorderBoxIterator, PositionProperty};
|
use query::{MarginPadding, MarginRetrievingFragmentBorderBoxIterator, PositionProperty};
|
||||||
use query::{PositionRetrievingFragmentBorderBoxIterator, Side};
|
use query::{PositionRetrievingFragmentBorderBoxIterator, Side};
|
||||||
|
@ -1434,18 +1434,20 @@ impl LayoutTask {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns profiling information which is passed to the time profiler.
|
/// Returns profiling information which is passed to the time profiler.
|
||||||
fn profiler_metadata(&self) -> ProfilerMetadata {
|
fn profiler_metadata(&self) -> Option<TimerMetadata> {
|
||||||
Some((&self.url,
|
Some(TimerMetadata {
|
||||||
if self.is_iframe {
|
url: self.url.serialize(),
|
||||||
|
iframe: if self.is_iframe {
|
||||||
TimerMetadataFrameType::IFrame
|
TimerMetadataFrameType::IFrame
|
||||||
} else {
|
} else {
|
||||||
TimerMetadataFrameType::RootWindow
|
TimerMetadataFrameType::RootWindow
|
||||||
},
|
},
|
||||||
if self.first_reflow.get() {
|
incremental: if self.first_reflow.get() {
|
||||||
TimerMetadataReflowType::FirstReflow
|
TimerMetadataReflowType::FirstReflow
|
||||||
} else {
|
} else {
|
||||||
TimerMetadataReflowType::Incremental
|
TimerMetadataReflowType::Incremental
|
||||||
}))
|
},
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@ use context::{LayoutContext, SharedLayoutContext};
|
||||||
use flow::{self, Flow, MutableFlowUtils, PostorderFlowTraversal, PreorderFlowTraversal};
|
use flow::{self, Flow, MutableFlowUtils, PostorderFlowTraversal, PreorderFlowTraversal};
|
||||||
use flow_ref::{self, FlowRef};
|
use flow_ref::{self, FlowRef};
|
||||||
use gfx::display_list::OpaqueNode;
|
use gfx::display_list::OpaqueNode;
|
||||||
use profile_traits::time::{self, ProfilerMetadata, profile};
|
use profile_traits::time::{self, TimerMetadata, profile};
|
||||||
use std::mem;
|
use std::mem;
|
||||||
use std::sync::atomic::{AtomicIsize, Ordering};
|
use std::sync::atomic::{AtomicIsize, Ordering};
|
||||||
use traversal::PostorderNodeMutTraversal;
|
use traversal::PostorderNodeMutTraversal;
|
||||||
|
@ -465,7 +465,7 @@ pub fn traverse_dom_preorder(root: LayoutNode,
|
||||||
|
|
||||||
pub fn traverse_flow_tree_preorder(
|
pub fn traverse_flow_tree_preorder(
|
||||||
root: &mut FlowRef,
|
root: &mut FlowRef,
|
||||||
profiler_metadata: ProfilerMetadata,
|
profiler_metadata: Option<TimerMetadata>,
|
||||||
time_profiler_chan: time::ProfilerChan,
|
time_profiler_chan: time::ProfilerChan,
|
||||||
shared_layout_context: &SharedLayoutContext,
|
shared_layout_context: &SharedLayoutContext,
|
||||||
queue: &mut WorkQueue<SharedLayoutContext, WorkQueueData>) {
|
queue: &mut WorkQueue<SharedLayoutContext, WorkQueueData>) {
|
||||||
|
@ -488,7 +488,7 @@ pub fn traverse_flow_tree_preorder(
|
||||||
|
|
||||||
pub fn build_display_list_for_subtree(
|
pub fn build_display_list_for_subtree(
|
||||||
root: &mut FlowRef,
|
root: &mut FlowRef,
|
||||||
profiler_metadata: ProfilerMetadata,
|
profiler_metadata: Option<TimerMetadata>,
|
||||||
time_profiler_chan: time::ProfilerChan,
|
time_profiler_chan: time::ProfilerChan,
|
||||||
shared_layout_context: &SharedLayoutContext,
|
shared_layout_context: &SharedLayoutContext,
|
||||||
queue: &mut WorkQueue<SharedLayoutContext, WorkQueueData>) {
|
queue: &mut WorkQueue<SharedLayoutContext, WorkQueueData>) {
|
||||||
|
|
|
@ -8,6 +8,7 @@ use heartbeats;
|
||||||
use ipc_channel::ipc::{self, IpcReceiver};
|
use ipc_channel::ipc::{self, IpcReceiver};
|
||||||
use profile_traits::energy::{energy_interval_ms, read_energy_uj};
|
use profile_traits::energy::{energy_interval_ms, read_energy_uj};
|
||||||
use profile_traits::time::{ProfilerCategory, ProfilerChan, ProfilerMsg, TimerMetadata};
|
use profile_traits::time::{ProfilerCategory, ProfilerChan, ProfilerMsg, TimerMetadata};
|
||||||
|
use profile_traits::time::{TimerMetadataReflowType, TimerMetadataFrameType};
|
||||||
use std::borrow::ToOwned;
|
use std::borrow::ToOwned;
|
||||||
use std::cmp::Ordering;
|
use std::cmp::Ordering;
|
||||||
use std::collections::BTreeMap;
|
use std::collections::BTreeMap;
|
||||||
|
@ -31,8 +32,14 @@ impl Formattable for Option<TimerMetadata> {
|
||||||
} else {
|
} else {
|
||||||
url
|
url
|
||||||
};
|
};
|
||||||
let incremental = if meta.incremental { " yes" } else { " no " };
|
let incremental = match meta.incremental {
|
||||||
let iframe = if meta.iframe { " yes" } else { " no " };
|
TimerMetadataReflowType::Incremental => " yes",
|
||||||
|
TimerMetadataReflowType::FirstReflow => " no ",
|
||||||
|
};
|
||||||
|
let iframe = match meta.iframe {
|
||||||
|
TimerMetadataFrameType::RootWindow => " yes",
|
||||||
|
TimerMetadataFrameType::IFrame => " no ",
|
||||||
|
};
|
||||||
format!(" {:14} {:9} {:30}", incremental, iframe, url)
|
format!(" {:14} {:9} {:30}", incremental, iframe, url)
|
||||||
},
|
},
|
||||||
None =>
|
None =>
|
||||||
|
|
|
@ -13,10 +13,6 @@ energy-profiling = ["energymon", "energy-monitor"]
|
||||||
[dependencies.ipc-channel]
|
[dependencies.ipc-channel]
|
||||||
git = "https://github.com/pcwalton/ipc-channel"
|
git = "https://github.com/pcwalton/ipc-channel"
|
||||||
|
|
||||||
[dependencies.url]
|
|
||||||
version = "0.2"
|
|
||||||
features = [ "serde_serialization" ]
|
|
||||||
|
|
||||||
[dependencies.energymon]
|
[dependencies.energymon]
|
||||||
git = "https://github.com/energymon/energymon-rust.git"
|
git = "https://github.com/energymon/energymon-rust.git"
|
||||||
rev = "eba1d8a"
|
rev = "eba1d8a"
|
||||||
|
|
|
@ -3,18 +3,16 @@
|
||||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
extern crate time as std_time;
|
extern crate time as std_time;
|
||||||
extern crate url;
|
|
||||||
|
|
||||||
use energy::read_energy_uj;
|
use energy::read_energy_uj;
|
||||||
use ipc_channel::ipc::IpcSender;
|
use ipc_channel::ipc::IpcSender;
|
||||||
use self::std_time::precise_time_ns;
|
use self::std_time::precise_time_ns;
|
||||||
use self::url::Url;
|
|
||||||
|
|
||||||
#[derive(PartialEq, Clone, PartialOrd, Eq, Ord, Deserialize, Serialize)]
|
#[derive(PartialEq, Clone, PartialOrd, Eq, Ord, Deserialize, Serialize)]
|
||||||
pub struct TimerMetadata {
|
pub struct TimerMetadata {
|
||||||
pub url: String,
|
pub url: String,
|
||||||
pub iframe: bool,
|
pub iframe: TimerMetadataFrameType,
|
||||||
pub incremental: bool,
|
pub incremental: TimerMetadataReflowType,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Deserialize, Serialize)]
|
#[derive(Clone, Deserialize, Serialize)]
|
||||||
|
@ -77,23 +75,20 @@ pub enum ProfilerCategory {
|
||||||
ApplicationHeartbeat,
|
ApplicationHeartbeat,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Eq, PartialEq)]
|
#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Deserialize, Serialize)]
|
||||||
pub enum TimerMetadataFrameType {
|
pub enum TimerMetadataFrameType {
|
||||||
RootWindow,
|
RootWindow,
|
||||||
IFrame,
|
IFrame,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Eq, PartialEq)]
|
#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Deserialize, Serialize)]
|
||||||
pub enum TimerMetadataReflowType {
|
pub enum TimerMetadataReflowType {
|
||||||
Incremental,
|
Incremental,
|
||||||
FirstReflow,
|
FirstReflow,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub type ProfilerMetadata<'a> =
|
|
||||||
Option<(&'a Url, TimerMetadataFrameType, TimerMetadataReflowType)>;
|
|
||||||
|
|
||||||
pub fn profile<T, F>(category: ProfilerCategory,
|
pub fn profile<T, F>(category: ProfilerCategory,
|
||||||
meta: ProfilerMetadata,
|
meta: Option<TimerMetadata>,
|
||||||
profiler_chan: ProfilerChan,
|
profiler_chan: ProfilerChan,
|
||||||
callback: F)
|
callback: F)
|
||||||
-> T
|
-> T
|
||||||
|
@ -104,12 +99,6 @@ pub fn profile<T, F>(category: ProfilerCategory,
|
||||||
let val = callback();
|
let val = callback();
|
||||||
let end_time = precise_time_ns();
|
let end_time = precise_time_ns();
|
||||||
let end_energy = read_energy_uj();
|
let end_energy = read_energy_uj();
|
||||||
let meta = meta.map(|(url, iframe, reflow_type)|
|
|
||||||
TimerMetadata {
|
|
||||||
url: url.serialize(),
|
|
||||||
iframe: iframe == TimerMetadataFrameType::IFrame,
|
|
||||||
incremental: reflow_type == TimerMetadataReflowType::Incremental,
|
|
||||||
});
|
|
||||||
profiler_chan.send(ProfilerMsg::Time((category, meta),
|
profiler_chan.send(ProfilerMsg::Time((category, meta),
|
||||||
(start_time, end_time),
|
(start_time, end_time),
|
||||||
(start_energy, end_energy)));
|
(start_energy, end_energy)));
|
||||||
|
|
1
components/servo/Cargo.lock
generated
1
components/servo/Cargo.lock
generated
|
@ -1416,7 +1416,6 @@ dependencies = [
|
||||||
"serde 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"serde 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"serde_macros 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"serde_macros 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"time 0.1.32 (registry+https://github.com/rust-lang/crates.io-index)",
|
"time 0.1.32 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"url 0.2.37 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
|
1
ports/cef/Cargo.lock
generated
1
ports/cef/Cargo.lock
generated
|
@ -1350,7 +1350,6 @@ dependencies = [
|
||||||
"serde 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"serde 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"serde_macros 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"serde_macros 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"time 0.1.32 (registry+https://github.com/rust-lang/crates.io-index)",
|
"time 0.1.32 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"url 0.2.37 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
|
1
ports/gonk/Cargo.lock
generated
1
ports/gonk/Cargo.lock
generated
|
@ -1330,7 +1330,6 @@ dependencies = [
|
||||||
"serde 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"serde 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"serde_macros 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"serde_macros 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"time 0.1.32 (registry+https://github.com/rust-lang/crates.io-index)",
|
"time 0.1.32 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"url 0.2.37 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue