mirror of
https://github.com/servo/servo.git
synced 2025-08-04 13:10:20 +01:00
Rename |Profiler| as |TimeProfiler|.
And likewise for |ProfilerChan|, |profiler_chan|, and so on. This contrasts nicely with the newly added |MemoryProfiler|.
This commit is contained in:
parent
fad919ccf7
commit
56dd5b943e
15 changed files with 118 additions and 118 deletions
|
@ -51,7 +51,7 @@ pub extern "C" fn cef_run_message_loop() {
|
||||||
cpu_painting: false,
|
cpu_painting: false,
|
||||||
tile_size: 512,
|
tile_size: 512,
|
||||||
device_pixels_per_px: None,
|
device_pixels_per_px: None,
|
||||||
profiler_period: None,
|
time_profiler_period: None,
|
||||||
memory_profiler_period: None,
|
memory_profiler_period: None,
|
||||||
layout_threads: 1,
|
layout_threads: 1,
|
||||||
//layout_threads: cmp::max(rt::default_sched_threads() * 3 / 4, 1),
|
//layout_threads: cmp::max(rt::default_sched_threads() * 3 / 4, 1),
|
||||||
|
|
|
@ -11,7 +11,7 @@ use platform::font_context::FontContextHandle;
|
||||||
use azure::azure_hl::BackendType;
|
use azure::azure_hl::BackendType;
|
||||||
use collections::hashmap::HashMap;
|
use collections::hashmap::HashMap;
|
||||||
use servo_util::cache::{Cache, LRUCache};
|
use servo_util::cache::{Cache, LRUCache};
|
||||||
use servo_util::time::ProfilerChan;
|
use servo_util::time::TimeProfilerChan;
|
||||||
|
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
use std::cell::RefCell;
|
use std::cell::RefCell;
|
||||||
|
@ -25,8 +25,8 @@ pub struct FontContextInfo {
|
||||||
/// Whether we need a font list.
|
/// Whether we need a font list.
|
||||||
pub needs_font_list: bool,
|
pub needs_font_list: bool,
|
||||||
|
|
||||||
/// A channel up to the profiler.
|
/// A channel up to the time profiler.
|
||||||
pub profiler_chan: ProfilerChan,
|
pub time_profiler_chan: TimeProfilerChan,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait FontContextHandleMethods {
|
pub trait FontContextHandleMethods {
|
||||||
|
@ -40,14 +40,14 @@ pub struct FontContext {
|
||||||
pub handle: FontContextHandle,
|
pub handle: FontContextHandle,
|
||||||
pub backend: BackendType,
|
pub backend: BackendType,
|
||||||
pub generic_fonts: HashMap<String,String>,
|
pub generic_fonts: HashMap<String,String>,
|
||||||
pub profiler_chan: ProfilerChan,
|
pub time_profiler_chan: TimeProfilerChan,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl FontContext {
|
impl FontContext {
|
||||||
pub fn new(info: FontContextInfo) -> FontContext {
|
pub fn new(info: FontContextInfo) -> FontContext {
|
||||||
let handle = FontContextHandle::new();
|
let handle = FontContextHandle::new();
|
||||||
let font_list = if info.needs_font_list {
|
let font_list = if info.needs_font_list {
|
||||||
Some(FontList::new(&handle, info.profiler_chan.clone()))
|
Some(FontList::new(&handle, info.time_profiler_chan.clone()))
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
};
|
};
|
||||||
|
@ -67,7 +67,7 @@ impl FontContext {
|
||||||
handle: handle,
|
handle: handle,
|
||||||
backend: info.backend,
|
backend: info.backend,
|
||||||
generic_fonts: generic_fonts,
|
generic_fonts: generic_fonts,
|
||||||
profiler_chan: info.profiler_chan.clone(),
|
time_profiler_chan: info.time_profiler_chan.clone(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@ use platform::font_context::FontContextHandle;
|
||||||
use platform::font_list::FontListHandle;
|
use platform::font_list::FontListHandle;
|
||||||
use style::computed_values::{font_weight, font_style};
|
use style::computed_values::{font_weight, font_style};
|
||||||
|
|
||||||
use servo_util::time::{ProfilerChan, profile};
|
use servo_util::time::{TimeProfilerChan, profile};
|
||||||
use servo_util::time;
|
use servo_util::time;
|
||||||
|
|
||||||
pub type FontFamilyMap = HashMap<String, FontFamily>;
|
pub type FontFamilyMap = HashMap<String, FontFamily>;
|
||||||
|
@ -25,18 +25,18 @@ trait FontListHandleMethods {
|
||||||
pub struct FontList {
|
pub struct FontList {
|
||||||
family_map: FontFamilyMap,
|
family_map: FontFamilyMap,
|
||||||
handle: FontListHandle,
|
handle: FontListHandle,
|
||||||
prof_chan: ProfilerChan,
|
time_profiler_chan: TimeProfilerChan,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl FontList {
|
impl FontList {
|
||||||
pub fn new(fctx: &FontContextHandle,
|
pub fn new(fctx: &FontContextHandle,
|
||||||
prof_chan: ProfilerChan)
|
time_profiler_chan: TimeProfilerChan)
|
||||||
-> FontList {
|
-> FontList {
|
||||||
let handle = FontListHandle::new(fctx);
|
let handle = FontListHandle::new(fctx);
|
||||||
let mut list = FontList {
|
let mut list = FontList {
|
||||||
handle: handle,
|
handle: handle,
|
||||||
family_map: HashMap::new(),
|
family_map: HashMap::new(),
|
||||||
prof_chan: prof_chan.clone(),
|
time_profiler_chan: time_profiler_chan.clone(),
|
||||||
};
|
};
|
||||||
list.refresh(fctx);
|
list.refresh(fctx);
|
||||||
list
|
list
|
||||||
|
@ -47,7 +47,7 @@ impl FontList {
|
||||||
// changed. Does OSX have a notification for this event?
|
// changed. Does OSX have a notification for this event?
|
||||||
//
|
//
|
||||||
// Should font families with entries be invalidated/refreshed too?
|
// Should font families with entries be invalidated/refreshed too?
|
||||||
profile(time::GfxRegenAvailableFontsCategory, self.prof_chan.clone(), || {
|
profile(time::GfxRegenAvailableFontsCategory, self.time_profiler_chan.clone(), || {
|
||||||
self.family_map = self.handle.get_available_families();
|
self.family_map = self.handle.get_available_families();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,7 +27,7 @@ use servo_util::geometry;
|
||||||
use servo_util::opts::Opts;
|
use servo_util::opts::Opts;
|
||||||
use servo_util::smallvec::{SmallVec, SmallVec1};
|
use servo_util::smallvec::{SmallVec, SmallVec1};
|
||||||
use servo_util::task::send_on_failure;
|
use servo_util::task::send_on_failure;
|
||||||
use servo_util::time::{ProfilerChan, profile};
|
use servo_util::time::{TimeProfilerChan, profile};
|
||||||
use servo_util::time;
|
use servo_util::time;
|
||||||
use std::comm::{Receiver, Sender, channel};
|
use std::comm::{Receiver, Sender, channel};
|
||||||
use std::task::TaskBuilder;
|
use std::task::TaskBuilder;
|
||||||
|
@ -108,8 +108,8 @@ pub struct RenderTask<C> {
|
||||||
font_ctx: Box<FontContext>,
|
font_ctx: Box<FontContext>,
|
||||||
opts: Opts,
|
opts: Opts,
|
||||||
|
|
||||||
/// A channel to the profiler.
|
/// A channel to the time profiler.
|
||||||
profiler_chan: ProfilerChan,
|
time_profiler_chan: TimeProfilerChan,
|
||||||
|
|
||||||
/// The graphics context to use.
|
/// The graphics context to use.
|
||||||
graphics_context: GraphicsContext,
|
graphics_context: GraphicsContext,
|
||||||
|
@ -161,7 +161,7 @@ impl<C:RenderListener + Send> RenderTask<C> {
|
||||||
constellation_chan: ConstellationChan,
|
constellation_chan: ConstellationChan,
|
||||||
failure_msg: Failure,
|
failure_msg: Failure,
|
||||||
opts: Opts,
|
opts: Opts,
|
||||||
profiler_chan: ProfilerChan,
|
time_profiler_chan: TimeProfilerChan,
|
||||||
shutdown_chan: Sender<()>) {
|
shutdown_chan: Sender<()>) {
|
||||||
let mut builder = TaskBuilder::new().named("RenderTask");
|
let mut builder = TaskBuilder::new().named("RenderTask");
|
||||||
let ConstellationChan(c) = constellation_chan.clone();
|
let ConstellationChan(c) = constellation_chan.clone();
|
||||||
|
@ -182,10 +182,10 @@ impl<C:RenderListener + Send> RenderTask<C> {
|
||||||
font_ctx: box FontContext::new(FontContextInfo {
|
font_ctx: box FontContext::new(FontContextInfo {
|
||||||
backend: opts.render_backend.clone(),
|
backend: opts.render_backend.clone(),
|
||||||
needs_font_list: false,
|
needs_font_list: false,
|
||||||
profiler_chan: profiler_chan.clone(),
|
time_profiler_chan: time_profiler_chan.clone(),
|
||||||
}),
|
}),
|
||||||
opts: opts,
|
opts: opts,
|
||||||
profiler_chan: profiler_chan,
|
time_profiler_chan: time_profiler_chan,
|
||||||
|
|
||||||
graphics_context: if cpu_painting {
|
graphics_context: if cpu_painting {
|
||||||
CpuGraphicsContext
|
CpuGraphicsContext
|
||||||
|
@ -280,7 +280,7 @@ impl<C:RenderListener + Send> RenderTask<C> {
|
||||||
/// FIXME(pcwalton): We will probably want to eventually send all layers belonging to a page in
|
/// FIXME(pcwalton): We will probably want to eventually send all layers belonging to a page in
|
||||||
/// one transaction, to avoid the user seeing inconsistent states.
|
/// one transaction, to avoid the user seeing inconsistent states.
|
||||||
fn render(&mut self, tiles: Vec<BufferRequest>, scale: f32, layer_id: LayerId) {
|
fn render(&mut self, tiles: Vec<BufferRequest>, scale: f32, layer_id: LayerId) {
|
||||||
time::profile(time::RenderingCategory, self.profiler_chan.clone(), || {
|
time::profile(time::RenderingCategory, self.time_profiler_chan.clone(), || {
|
||||||
// FIXME: Try not to create a new array here.
|
// FIXME: Try not to create a new array here.
|
||||||
let mut new_buffers = vec!();
|
let mut new_buffers = vec!();
|
||||||
|
|
||||||
|
@ -345,7 +345,7 @@ impl<C:RenderListener + Send> RenderTask<C> {
|
||||||
ctx.clear();
|
ctx.clear();
|
||||||
|
|
||||||
// Draw the display list.
|
// Draw the display list.
|
||||||
profile(time::RenderingDrawingCategory, self.profiler_chan.clone(), || {
|
profile(time::RenderingDrawingCategory, self.time_profiler_chan.clone(), || {
|
||||||
display_list.draw_into_context(&mut ctx);
|
display_list.draw_into_context(&mut ctx);
|
||||||
ctx.draw_target.flush();
|
ctx.draw_target.flush();
|
||||||
});
|
});
|
||||||
|
|
|
@ -36,7 +36,7 @@ use servo_msg::constellation_msg;
|
||||||
use servo_util::geometry::{DevicePixel, PagePx, ScreenPx, ViewportPx};
|
use servo_util::geometry::{DevicePixel, PagePx, ScreenPx, ViewportPx};
|
||||||
use servo_util::memory::MemoryProfilerChan;
|
use servo_util::memory::MemoryProfilerChan;
|
||||||
use servo_util::opts::Opts;
|
use servo_util::opts::Opts;
|
||||||
use servo_util::time::{profile, ProfilerChan};
|
use servo_util::time::{profile, TimeProfilerChan};
|
||||||
use servo_util::{memory, time, url};
|
use servo_util::{memory, time, url};
|
||||||
use std::io::timer::sleep;
|
use std::io::timer::sleep;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
|
@ -114,8 +114,8 @@ pub struct IOCompositor {
|
||||||
/// The channel on which messages can be sent to the constellation.
|
/// The channel on which messages can be sent to the constellation.
|
||||||
constellation_chan: ConstellationChan,
|
constellation_chan: ConstellationChan,
|
||||||
|
|
||||||
/// The channel on which messages can be sent to the profiler.
|
/// The channel on which messages can be sent to the time profiler.
|
||||||
profiler_chan: ProfilerChan,
|
time_profiler_chan: TimeProfilerChan,
|
||||||
|
|
||||||
/// The channel on which messages can be sent to the memory profiler.
|
/// The channel on which messages can be sent to the memory profiler.
|
||||||
memory_profiler_chan: MemoryProfilerChan,
|
memory_profiler_chan: MemoryProfilerChan,
|
||||||
|
@ -129,7 +129,7 @@ impl IOCompositor {
|
||||||
opts: Opts,
|
opts: Opts,
|
||||||
port: Receiver<Msg>,
|
port: Receiver<Msg>,
|
||||||
constellation_chan: ConstellationChan,
|
constellation_chan: ConstellationChan,
|
||||||
profiler_chan: ProfilerChan,
|
time_profiler_chan: TimeProfilerChan,
|
||||||
memory_profiler_chan: MemoryProfilerChan) -> IOCompositor {
|
memory_profiler_chan: MemoryProfilerChan) -> IOCompositor {
|
||||||
let window: Rc<Window> = WindowMethods::new(app, opts.output_file.is_none());
|
let window: Rc<Window> = WindowMethods::new(app, opts.output_file.is_none());
|
||||||
|
|
||||||
|
@ -164,7 +164,7 @@ impl IOCompositor {
|
||||||
load_complete: false,
|
load_complete: false,
|
||||||
compositor_layer: None,
|
compositor_layer: None,
|
||||||
constellation_chan: constellation_chan,
|
constellation_chan: constellation_chan,
|
||||||
profiler_chan: profiler_chan,
|
time_profiler_chan: time_profiler_chan,
|
||||||
memory_profiler_chan: memory_profiler_chan,
|
memory_profiler_chan: memory_profiler_chan,
|
||||||
fragment_point: None
|
fragment_point: None
|
||||||
}
|
}
|
||||||
|
@ -174,13 +174,13 @@ impl IOCompositor {
|
||||||
opts: Opts,
|
opts: Opts,
|
||||||
port: Receiver<Msg>,
|
port: Receiver<Msg>,
|
||||||
constellation_chan: ConstellationChan,
|
constellation_chan: ConstellationChan,
|
||||||
profiler_chan: ProfilerChan,
|
time_profiler_chan: TimeProfilerChan,
|
||||||
memory_profiler_chan: MemoryProfilerChan) {
|
memory_profiler_chan: MemoryProfilerChan) {
|
||||||
let mut compositor = IOCompositor::new(app,
|
let mut compositor = IOCompositor::new(app,
|
||||||
opts,
|
opts,
|
||||||
port,
|
port,
|
||||||
constellation_chan,
|
constellation_chan,
|
||||||
profiler_chan,
|
time_profiler_chan,
|
||||||
memory_profiler_chan);
|
memory_profiler_chan);
|
||||||
compositor.update_zoom_transform();
|
compositor.update_zoom_transform();
|
||||||
|
|
||||||
|
@ -240,8 +240,8 @@ impl IOCompositor {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Tell the profiler and memory profiler to shut down.
|
// Tell the profiler and memory profiler to shut down.
|
||||||
let ProfilerChan(ref profiler_chan) = self.profiler_chan;
|
let TimeProfilerChan(ref time_profiler_chan) = self.time_profiler_chan;
|
||||||
profiler_chan.send(time::ExitMsg);
|
time_profiler_chan.send(time::ExitMsg);
|
||||||
|
|
||||||
let MemoryProfilerChan(ref memory_profiler_chan) = self.memory_profiler_chan;
|
let MemoryProfilerChan(ref memory_profiler_chan) = self.memory_profiler_chan;
|
||||||
memory_profiler_chan.send(memory::ExitMsg);
|
memory_profiler_chan.send(memory::ExitMsg);
|
||||||
|
@ -743,7 +743,7 @@ impl IOCompositor {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn composite(&mut self) {
|
fn composite(&mut self) {
|
||||||
profile(time::CompositingCategory, self.profiler_chan.clone(), || {
|
profile(time::CompositingCategory, self.time_profiler_chan.clone(), || {
|
||||||
debug!("compositor: compositing");
|
debug!("compositor: compositing");
|
||||||
// Adjust the layer dimensions as necessary to correspond to the size of the window.
|
// Adjust the layer dimensions as necessary to correspond to the size of the window.
|
||||||
self.scene.size = self.window_size.as_f32().to_untyped();
|
self.scene.size = self.window_size.as_f32().to_untyped();
|
||||||
|
|
|
@ -18,7 +18,7 @@ use servo_msg::compositor_msg::{RenderListener, RenderState, ScriptListener, Scr
|
||||||
use servo_msg::constellation_msg::{ConstellationChan, PipelineId};
|
use servo_msg::constellation_msg::{ConstellationChan, PipelineId};
|
||||||
use servo_util::memory::MemoryProfilerChan;
|
use servo_util::memory::MemoryProfilerChan;
|
||||||
use servo_util::opts::Opts;
|
use servo_util::opts::Opts;
|
||||||
use servo_util::time::ProfilerChan;
|
use servo_util::time::TimeProfilerChan;
|
||||||
use std::comm::{channel, Sender, Receiver};
|
use std::comm::{channel, Sender, Receiver};
|
||||||
|
|
||||||
use url::Url;
|
use url::Url;
|
||||||
|
@ -225,7 +225,7 @@ impl CompositorTask {
|
||||||
pub fn create(opts: Opts,
|
pub fn create(opts: Opts,
|
||||||
port: Receiver<Msg>,
|
port: Receiver<Msg>,
|
||||||
constellation_chan: ConstellationChan,
|
constellation_chan: ConstellationChan,
|
||||||
profiler_chan: ProfilerChan,
|
time_profiler_chan: TimeProfilerChan,
|
||||||
memory_profiler_chan: MemoryProfilerChan) {
|
memory_profiler_chan: MemoryProfilerChan) {
|
||||||
|
|
||||||
let compositor = CompositorTask::new(opts.headless);
|
let compositor = CompositorTask::new(opts.headless);
|
||||||
|
@ -236,13 +236,13 @@ impl CompositorTask {
|
||||||
opts,
|
opts,
|
||||||
port,
|
port,
|
||||||
constellation_chan.clone(),
|
constellation_chan.clone(),
|
||||||
profiler_chan,
|
time_profiler_chan,
|
||||||
memory_profiler_chan)
|
memory_profiler_chan)
|
||||||
}
|
}
|
||||||
Headless => {
|
Headless => {
|
||||||
headless::NullCompositor::create(port,
|
headless::NullCompositor::create(port,
|
||||||
constellation_chan.clone(),
|
constellation_chan.clone(),
|
||||||
profiler_chan,
|
time_profiler_chan,
|
||||||
memory_profiler_chan)
|
memory_profiler_chan)
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -9,7 +9,7 @@ use geom::size::TypedSize2D;
|
||||||
use servo_msg::constellation_msg::{ConstellationChan, ExitMsg, ResizedWindowMsg, WindowSizeData};
|
use servo_msg::constellation_msg::{ConstellationChan, ExitMsg, ResizedWindowMsg, WindowSizeData};
|
||||||
use servo_util::memory::MemoryProfilerChan;
|
use servo_util::memory::MemoryProfilerChan;
|
||||||
use servo_util::memory;
|
use servo_util::memory;
|
||||||
use servo_util::time::ProfilerChan;
|
use servo_util::time::TimeProfilerChan;
|
||||||
use servo_util::time;
|
use servo_util::time;
|
||||||
|
|
||||||
/// Starts the compositor, which listens for messages on the specified port.
|
/// Starts the compositor, which listens for messages on the specified port.
|
||||||
|
@ -30,7 +30,7 @@ impl NullCompositor {
|
||||||
|
|
||||||
pub fn create(port: Receiver<Msg>,
|
pub fn create(port: Receiver<Msg>,
|
||||||
constellation_chan: ConstellationChan,
|
constellation_chan: ConstellationChan,
|
||||||
profiler_chan: ProfilerChan,
|
time_profiler_chan: TimeProfilerChan,
|
||||||
memory_profiler_chan: MemoryProfilerChan) {
|
memory_profiler_chan: MemoryProfilerChan) {
|
||||||
let compositor = NullCompositor::new(port);
|
let compositor = NullCompositor::new(port);
|
||||||
|
|
||||||
|
@ -54,7 +54,7 @@ impl NullCompositor {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
profiler_chan.send(time::ExitMsg);
|
time_profiler_chan.send(time::ExitMsg);
|
||||||
memory_profiler_chan.send(memory::ExitMsg);
|
memory_profiler_chan.send(memory::ExitMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,7 @@ use servo_net::resource_task::ResourceTask;
|
||||||
use servo_net::resource_task;
|
use servo_net::resource_task;
|
||||||
use servo_util::geometry::PagePx;
|
use servo_util::geometry::PagePx;
|
||||||
use servo_util::opts::Opts;
|
use servo_util::opts::Opts;
|
||||||
use servo_util::time::ProfilerChan;
|
use servo_util::time::TimeProfilerChan;
|
||||||
use servo_util::url::parse_url;
|
use servo_util::url::parse_url;
|
||||||
use servo_util::task::spawn_named;
|
use servo_util::task::spawn_named;
|
||||||
use std::cell::RefCell;
|
use std::cell::RefCell;
|
||||||
|
@ -48,7 +48,7 @@ pub struct Constellation {
|
||||||
next_pipeline_id: PipelineId,
|
next_pipeline_id: PipelineId,
|
||||||
pending_frames: Vec<FrameChange>,
|
pending_frames: Vec<FrameChange>,
|
||||||
pending_sizes: HashMap<(PipelineId, SubpageId), TypedRect<PagePx, f32>>,
|
pending_sizes: HashMap<(PipelineId, SubpageId), TypedRect<PagePx, f32>>,
|
||||||
pub profiler_chan: ProfilerChan,
|
pub time_profiler_chan: TimeProfilerChan,
|
||||||
pub window_size: WindowSizeData,
|
pub window_size: WindowSizeData,
|
||||||
pub opts: Opts,
|
pub opts: Opts,
|
||||||
}
|
}
|
||||||
|
@ -244,7 +244,7 @@ impl Constellation {
|
||||||
opts: &Opts,
|
opts: &Opts,
|
||||||
resource_task: ResourceTask,
|
resource_task: ResourceTask,
|
||||||
image_cache_task: ImageCacheTask,
|
image_cache_task: ImageCacheTask,
|
||||||
profiler_chan: ProfilerChan)
|
time_profiler_chan: TimeProfilerChan)
|
||||||
-> ConstellationChan {
|
-> ConstellationChan {
|
||||||
let (constellation_port, constellation_chan) = ConstellationChan::new();
|
let (constellation_port, constellation_chan) = ConstellationChan::new();
|
||||||
let constellation_chan_clone = constellation_chan.clone();
|
let constellation_chan_clone = constellation_chan.clone();
|
||||||
|
@ -261,7 +261,7 @@ impl Constellation {
|
||||||
next_pipeline_id: PipelineId(0),
|
next_pipeline_id: PipelineId(0),
|
||||||
pending_frames: vec!(),
|
pending_frames: vec!(),
|
||||||
pending_sizes: HashMap::new(),
|
pending_sizes: HashMap::new(),
|
||||||
profiler_chan: profiler_chan,
|
time_profiler_chan: time_profiler_chan,
|
||||||
window_size: WindowSizeData {
|
window_size: WindowSizeData {
|
||||||
visible_viewport: TypedSize2D(800_f32, 600_f32),
|
visible_viewport: TypedSize2D(800_f32, 600_f32),
|
||||||
initial_viewport: TypedSize2D(800_f32, 600_f32),
|
initial_viewport: TypedSize2D(800_f32, 600_f32),
|
||||||
|
@ -424,7 +424,7 @@ impl Constellation {
|
||||||
self.compositor_chan.clone(),
|
self.compositor_chan.clone(),
|
||||||
self.image_cache_task.clone(),
|
self.image_cache_task.clone(),
|
||||||
self.resource_task.clone(),
|
self.resource_task.clone(),
|
||||||
self.profiler_chan.clone(),
|
self.time_profiler_chan.clone(),
|
||||||
self.window_size,
|
self.window_size,
|
||||||
self.opts.clone(),
|
self.opts.clone(),
|
||||||
parse_url("about:failure", None));
|
parse_url("about:failure", None));
|
||||||
|
@ -451,7 +451,7 @@ impl Constellation {
|
||||||
self.compositor_chan.clone(),
|
self.compositor_chan.clone(),
|
||||||
self.image_cache_task.clone(),
|
self.image_cache_task.clone(),
|
||||||
self.resource_task.clone(),
|
self.resource_task.clone(),
|
||||||
self.profiler_chan.clone(),
|
self.time_profiler_chan.clone(),
|
||||||
self.window_size,
|
self.window_size,
|
||||||
self.opts.clone(),
|
self.opts.clone(),
|
||||||
url);
|
url);
|
||||||
|
@ -576,7 +576,7 @@ impl Constellation {
|
||||||
self.chan.clone(),
|
self.chan.clone(),
|
||||||
self.compositor_chan.clone(),
|
self.compositor_chan.clone(),
|
||||||
self.image_cache_task.clone(),
|
self.image_cache_task.clone(),
|
||||||
self.profiler_chan.clone(),
|
self.time_profiler_chan.clone(),
|
||||||
self.opts.clone(),
|
self.opts.clone(),
|
||||||
source_pipeline.clone(),
|
source_pipeline.clone(),
|
||||||
url)
|
url)
|
||||||
|
@ -589,7 +589,7 @@ impl Constellation {
|
||||||
self.compositor_chan.clone(),
|
self.compositor_chan.clone(),
|
||||||
self.image_cache_task.clone(),
|
self.image_cache_task.clone(),
|
||||||
self.resource_task.clone(),
|
self.resource_task.clone(),
|
||||||
self.profiler_chan.clone(),
|
self.time_profiler_chan.clone(),
|
||||||
self.window_size,
|
self.window_size,
|
||||||
self.opts.clone(),
|
self.opts.clone(),
|
||||||
url)
|
url)
|
||||||
|
@ -645,7 +645,7 @@ impl Constellation {
|
||||||
self.compositor_chan.clone(),
|
self.compositor_chan.clone(),
|
||||||
self.image_cache_task.clone(),
|
self.image_cache_task.clone(),
|
||||||
self.resource_task.clone(),
|
self.resource_task.clone(),
|
||||||
self.profiler_chan.clone(),
|
self.time_profiler_chan.clone(),
|
||||||
self.window_size,
|
self.window_size,
|
||||||
self.opts.clone(),
|
self.opts.clone(),
|
||||||
url);
|
url);
|
||||||
|
|
|
@ -49,7 +49,7 @@ use servo_util::geometry::Au;
|
||||||
use servo_util::geometry;
|
use servo_util::geometry;
|
||||||
use servo_util::opts::Opts;
|
use servo_util::opts::Opts;
|
||||||
use servo_util::smallvec::{SmallVec, SmallVec1};
|
use servo_util::smallvec::{SmallVec, SmallVec1};
|
||||||
use servo_util::time::{ProfilerChan, profile};
|
use servo_util::time::{TimeProfilerChan, profile};
|
||||||
use servo_util::time;
|
use servo_util::time;
|
||||||
use servo_util::task::send_on_failure;
|
use servo_util::task::send_on_failure;
|
||||||
use servo_util::workqueue::WorkQueue;
|
use servo_util::workqueue::WorkQueue;
|
||||||
|
@ -98,8 +98,8 @@ pub struct LayoutTask {
|
||||||
/// The workers that we use for parallel operation.
|
/// The workers that we use for parallel operation.
|
||||||
pub parallel_traversal: Option<WorkQueue<*mut LayoutContext,UnsafeFlow>>,
|
pub parallel_traversal: Option<WorkQueue<*mut LayoutContext,UnsafeFlow>>,
|
||||||
|
|
||||||
/// The channel on which messages can be sent to the profiler.
|
/// The channel on which messages can be sent to the time profiler.
|
||||||
pub profiler_chan: ProfilerChan,
|
pub time_profiler_chan: TimeProfilerChan,
|
||||||
|
|
||||||
/// The command-line options.
|
/// The command-line options.
|
||||||
pub opts: Opts,
|
pub opts: Opts,
|
||||||
|
@ -279,7 +279,7 @@ impl LayoutTask {
|
||||||
render_chan: RenderChan,
|
render_chan: RenderChan,
|
||||||
img_cache_task: ImageCacheTask,
|
img_cache_task: ImageCacheTask,
|
||||||
opts: Opts,
|
opts: Opts,
|
||||||
profiler_chan: ProfilerChan,
|
time_profiler_chan: TimeProfilerChan,
|
||||||
shutdown_chan: Sender<()>) {
|
shutdown_chan: Sender<()>) {
|
||||||
let mut builder = TaskBuilder::new().named("LayoutTask");
|
let mut builder = TaskBuilder::new().named("LayoutTask");
|
||||||
let ConstellationChan(con_chan) = constellation_chan.clone();
|
let ConstellationChan(con_chan) = constellation_chan.clone();
|
||||||
|
@ -294,7 +294,7 @@ impl LayoutTask {
|
||||||
render_chan,
|
render_chan,
|
||||||
img_cache_task,
|
img_cache_task,
|
||||||
&opts,
|
&opts,
|
||||||
profiler_chan);
|
time_profiler_chan);
|
||||||
layout.start();
|
layout.start();
|
||||||
}
|
}
|
||||||
shutdown_chan.send(());
|
shutdown_chan.send(());
|
||||||
|
@ -310,7 +310,7 @@ impl LayoutTask {
|
||||||
render_chan: RenderChan,
|
render_chan: RenderChan,
|
||||||
image_cache_task: ImageCacheTask,
|
image_cache_task: ImageCacheTask,
|
||||||
opts: &Opts,
|
opts: &Opts,
|
||||||
profiler_chan: ProfilerChan)
|
time_profiler_chan: TimeProfilerChan)
|
||||||
-> LayoutTask {
|
-> LayoutTask {
|
||||||
let local_image_cache = Arc::new(Mutex::new(LocalImageCache(image_cache_task.clone())));
|
let local_image_cache = Arc::new(Mutex::new(LocalImageCache(image_cache_task.clone())));
|
||||||
let screen_size = Size2D(Au(0), Au(0));
|
let screen_size = Size2D(Au(0), Au(0));
|
||||||
|
@ -334,7 +334,7 @@ impl LayoutTask {
|
||||||
display_list: None,
|
display_list: None,
|
||||||
stylist: box new_stylist(),
|
stylist: box new_stylist(),
|
||||||
parallel_traversal: parallel_traversal,
|
parallel_traversal: parallel_traversal,
|
||||||
profiler_chan: profiler_chan,
|
time_profiler_chan: time_profiler_chan,
|
||||||
opts: opts.clone(),
|
opts: opts.clone(),
|
||||||
dirty: Rect::zero(),
|
dirty: Rect::zero(),
|
||||||
}
|
}
|
||||||
|
@ -352,7 +352,7 @@ impl LayoutTask {
|
||||||
let font_context_info = FontContextInfo {
|
let font_context_info = FontContextInfo {
|
||||||
backend: self.opts.render_backend,
|
backend: self.opts.render_backend,
|
||||||
needs_font_list: true,
|
needs_font_list: true,
|
||||||
profiler_chan: self.profiler_chan.clone(),
|
time_profiler_chan: self.time_profiler_chan.clone(),
|
||||||
};
|
};
|
||||||
|
|
||||||
LayoutContext {
|
LayoutContext {
|
||||||
|
@ -374,13 +374,13 @@ impl LayoutTask {
|
||||||
match self.port.recv() {
|
match self.port.recv() {
|
||||||
AddStylesheetMsg(sheet) => self.handle_add_stylesheet(sheet),
|
AddStylesheetMsg(sheet) => self.handle_add_stylesheet(sheet),
|
||||||
ReflowMsg(data) => {
|
ReflowMsg(data) => {
|
||||||
profile(time::LayoutPerformCategory, self.profiler_chan.clone(), || {
|
profile(time::LayoutPerformCategory, self.time_profiler_chan.clone(), || {
|
||||||
self.handle_reflow(data);
|
self.handle_reflow(data);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
QueryMsg(query) => {
|
QueryMsg(query) => {
|
||||||
let mut query = Some(query);
|
let mut query = Some(query);
|
||||||
profile(time::LayoutQueryCategory, self.profiler_chan.clone(), || {
|
profile(time::LayoutQueryCategory, self.time_profiler_chan.clone(), || {
|
||||||
self.handle_query(query.take_unwrap());
|
self.handle_query(query.take_unwrap());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -529,7 +529,7 @@ impl LayoutTask {
|
||||||
// NOTE: this currently computes borders, so any pruning should separate that
|
// NOTE: this currently computes borders, so any pruning should separate that
|
||||||
// operation out.
|
// operation out.
|
||||||
parallel::traverse_flow_tree_preorder(layout_root,
|
parallel::traverse_flow_tree_preorder(layout_root,
|
||||||
self.profiler_chan.clone(),
|
self.time_profiler_chan.clone(),
|
||||||
layout_context,
|
layout_context,
|
||||||
traversal);
|
traversal);
|
||||||
}
|
}
|
||||||
|
@ -600,7 +600,7 @@ impl LayoutTask {
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut layout_root = profile(time::LayoutStyleRecalcCategory,
|
let mut layout_root = profile(time::LayoutStyleRecalcCategory,
|
||||||
self.profiler_chan.clone(),
|
self.time_profiler_chan.clone(),
|
||||||
|| {
|
|| {
|
||||||
// Perform CSS selector matching and flow construction.
|
// Perform CSS selector matching and flow construction.
|
||||||
match self.parallel_traversal {
|
match self.parallel_traversal {
|
||||||
|
@ -630,7 +630,7 @@ impl LayoutTask {
|
||||||
self.verify_flow_tree(&mut layout_root);
|
self.verify_flow_tree(&mut layout_root);
|
||||||
|
|
||||||
// Propagate damage.
|
// Propagate damage.
|
||||||
profile(time::LayoutDamagePropagateCategory, self.profiler_chan.clone(), || {
|
profile(time::LayoutDamagePropagateCategory, self.time_profiler_chan.clone(), || {
|
||||||
layout_root.get_mut().traverse_preorder(&mut PropagateDamageTraversal {
|
layout_root.get_mut().traverse_preorder(&mut PropagateDamageTraversal {
|
||||||
all_style_damage: all_style_damage
|
all_style_damage: all_style_damage
|
||||||
});
|
});
|
||||||
|
@ -639,7 +639,7 @@ impl LayoutTask {
|
||||||
|
|
||||||
// Perform the primary layout passes over the flow tree to compute the locations of all
|
// Perform the primary layout passes over the flow tree to compute the locations of all
|
||||||
// the boxes.
|
// the boxes.
|
||||||
profile(time::LayoutMainCategory, self.profiler_chan.clone(), || {
|
profile(time::LayoutMainCategory, self.time_profiler_chan.clone(), || {
|
||||||
match self.parallel_traversal {
|
match self.parallel_traversal {
|
||||||
None => {
|
None => {
|
||||||
// Sequential mode.
|
// Sequential mode.
|
||||||
|
@ -654,7 +654,7 @@ impl LayoutTask {
|
||||||
|
|
||||||
// Build the display list if necessary, and send it to the renderer.
|
// Build the display list if necessary, and send it to the renderer.
|
||||||
if data.goal == ReflowForDisplay {
|
if data.goal == ReflowForDisplay {
|
||||||
profile(time::LayoutDispListBuildCategory, self.profiler_chan.clone(), || {
|
profile(time::LayoutDispListBuildCategory, self.time_profiler_chan.clone(), || {
|
||||||
layout_ctx.dirty = flow::base(layout_root.get()).position.clone();
|
layout_ctx.dirty = flow::base(layout_root.get()).position.clone();
|
||||||
|
|
||||||
match self.parallel_traversal {
|
match self.parallel_traversal {
|
||||||
|
@ -666,7 +666,7 @@ impl LayoutTask {
|
||||||
}
|
}
|
||||||
Some(ref mut traversal) => {
|
Some(ref mut traversal) => {
|
||||||
parallel::build_display_list_for_subtree(&mut layout_root,
|
parallel::build_display_list_for_subtree(&mut layout_root,
|
||||||
self.profiler_chan.clone(),
|
self.time_profiler_chan.clone(),
|
||||||
&mut layout_ctx,
|
&mut layout_ctx,
|
||||||
traversal);
|
traversal);
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,7 @@ use layout::wrapper::{layout_node_to_unsafe_layout_node, layout_node_from_unsafe
|
||||||
use layout::wrapper::{ThreadSafeLayoutNode, UnsafeLayoutNode};
|
use layout::wrapper::{ThreadSafeLayoutNode, UnsafeLayoutNode};
|
||||||
|
|
||||||
use gfx::display_list::OpaqueNode;
|
use gfx::display_list::OpaqueNode;
|
||||||
use servo_util::time::{ProfilerChan, profile};
|
use servo_util::time::{TimeProfilerChan, profile};
|
||||||
use servo_util::time;
|
use servo_util::time;
|
||||||
use servo_util::workqueue::{WorkQueue, WorkUnit, WorkerProxy};
|
use servo_util::workqueue::{WorkQueue, WorkUnit, WorkerProxy};
|
||||||
use std::mem;
|
use std::mem;
|
||||||
|
@ -526,14 +526,14 @@ pub fn recalc_style_for_subtree(root_node: &LayoutNode,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn traverse_flow_tree_preorder(root: &mut FlowRef,
|
pub fn traverse_flow_tree_preorder(root: &mut FlowRef,
|
||||||
profiler_chan: ProfilerChan,
|
time_profiler_chan: TimeProfilerChan,
|
||||||
layout_context: &mut LayoutContext,
|
layout_context: &mut LayoutContext,
|
||||||
queue: &mut WorkQueue<*mut LayoutContext,UnsafeFlow>) {
|
queue: &mut WorkQueue<*mut LayoutContext,UnsafeFlow>) {
|
||||||
unsafe {
|
unsafe {
|
||||||
queue.data = mem::transmute(layout_context)
|
queue.data = mem::transmute(layout_context)
|
||||||
}
|
}
|
||||||
|
|
||||||
profile(time::LayoutParallelWarmupCategory, profiler_chan, || {
|
profile(time::LayoutParallelWarmupCategory, time_profiler_chan, || {
|
||||||
queue.push(WorkUnit {
|
queue.push(WorkUnit {
|
||||||
fun: assign_widths,
|
fun: assign_widths,
|
||||||
data: mut_owned_flow_to_unsafe_flow(root),
|
data: mut_owned_flow_to_unsafe_flow(root),
|
||||||
|
@ -546,14 +546,14 @@ pub fn traverse_flow_tree_preorder(root: &mut FlowRef,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn build_display_list_for_subtree(root: &mut FlowRef,
|
pub fn build_display_list_for_subtree(root: &mut FlowRef,
|
||||||
profiler_chan: ProfilerChan,
|
time_profiler_chan: TimeProfilerChan,
|
||||||
layout_context: &mut LayoutContext,
|
layout_context: &mut LayoutContext,
|
||||||
queue: &mut WorkQueue<*mut LayoutContext,UnsafeFlow>) {
|
queue: &mut WorkQueue<*mut LayoutContext,UnsafeFlow>) {
|
||||||
unsafe {
|
unsafe {
|
||||||
queue.data = mem::transmute(layout_context)
|
queue.data = mem::transmute(layout_context)
|
||||||
}
|
}
|
||||||
|
|
||||||
profile(time::LayoutParallelWarmupCategory, profiler_chan, || {
|
profile(time::LayoutParallelWarmupCategory, time_profiler_chan, || {
|
||||||
queue.push(WorkUnit {
|
queue.push(WorkUnit {
|
||||||
fun: compute_absolute_position,
|
fun: compute_absolute_position,
|
||||||
data: mut_owned_flow_to_unsafe_flow(root),
|
data: mut_owned_flow_to_unsafe_flow(root),
|
||||||
|
|
|
@ -16,7 +16,7 @@ use servo_msg::constellation_msg::WindowSizeData;
|
||||||
use servo_net::image_cache_task::ImageCacheTask;
|
use servo_net::image_cache_task::ImageCacheTask;
|
||||||
use servo_net::resource_task::ResourceTask;
|
use servo_net::resource_task::ResourceTask;
|
||||||
use servo_util::opts::Opts;
|
use servo_util::opts::Opts;
|
||||||
use servo_util::time::ProfilerChan;
|
use servo_util::time::TimeProfilerChan;
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
use url::Url;
|
use url::Url;
|
||||||
|
|
||||||
|
@ -49,7 +49,7 @@ impl Pipeline {
|
||||||
constellation_chan: ConstellationChan,
|
constellation_chan: ConstellationChan,
|
||||||
compositor_chan: CompositorChan,
|
compositor_chan: CompositorChan,
|
||||||
image_cache_task: ImageCacheTask,
|
image_cache_task: ImageCacheTask,
|
||||||
profiler_chan: ProfilerChan,
|
time_profiler_chan: TimeProfilerChan,
|
||||||
opts: Opts,
|
opts: Opts,
|
||||||
script_pipeline: Rc<Pipeline>,
|
script_pipeline: Rc<Pipeline>,
|
||||||
url: Url)
|
url: Url)
|
||||||
|
@ -70,7 +70,7 @@ impl Pipeline {
|
||||||
constellation_chan.clone(),
|
constellation_chan.clone(),
|
||||||
failure.clone(),
|
failure.clone(),
|
||||||
opts.clone(),
|
opts.clone(),
|
||||||
profiler_chan.clone(),
|
time_profiler_chan.clone(),
|
||||||
render_shutdown_chan);
|
render_shutdown_chan);
|
||||||
|
|
||||||
LayoutTask::create(id,
|
LayoutTask::create(id,
|
||||||
|
@ -82,7 +82,7 @@ impl Pipeline {
|
||||||
render_chan.clone(),
|
render_chan.clone(),
|
||||||
image_cache_task.clone(),
|
image_cache_task.clone(),
|
||||||
opts.clone(),
|
opts.clone(),
|
||||||
profiler_chan,
|
time_profiler_chan,
|
||||||
layout_shutdown_chan);
|
layout_shutdown_chan);
|
||||||
|
|
||||||
let new_layout_info = NewLayoutInfo {
|
let new_layout_info = NewLayoutInfo {
|
||||||
|
@ -111,7 +111,7 @@ impl Pipeline {
|
||||||
compositor_chan: CompositorChan,
|
compositor_chan: CompositorChan,
|
||||||
image_cache_task: ImageCacheTask,
|
image_cache_task: ImageCacheTask,
|
||||||
resource_task: ResourceTask,
|
resource_task: ResourceTask,
|
||||||
profiler_chan: ProfilerChan,
|
time_profiler_chan: TimeProfilerChan,
|
||||||
window_size: WindowSizeData,
|
window_size: WindowSizeData,
|
||||||
opts: Opts,
|
opts: Opts,
|
||||||
url: Url)
|
url: Url)
|
||||||
|
@ -152,7 +152,7 @@ impl Pipeline {
|
||||||
constellation_chan.clone(),
|
constellation_chan.clone(),
|
||||||
failure.clone(),
|
failure.clone(),
|
||||||
opts.clone(),
|
opts.clone(),
|
||||||
profiler_chan.clone(),
|
time_profiler_chan.clone(),
|
||||||
render_shutdown_chan);
|
render_shutdown_chan);
|
||||||
|
|
||||||
LayoutTask::create(id,
|
LayoutTask::create(id,
|
||||||
|
@ -164,7 +164,7 @@ impl Pipeline {
|
||||||
render_chan.clone(),
|
render_chan.clone(),
|
||||||
image_cache_task,
|
image_cache_task,
|
||||||
opts.clone(),
|
opts.clone(),
|
||||||
profiler_chan,
|
time_profiler_chan,
|
||||||
layout_shutdown_chan);
|
layout_shutdown_chan);
|
||||||
|
|
||||||
pipeline
|
pipeline
|
||||||
|
|
|
@ -63,7 +63,7 @@ use servo_net::image_cache_task::{ImageCacheTask, SyncImageCacheTask};
|
||||||
#[cfg(not(test))]
|
#[cfg(not(test))]
|
||||||
use servo_net::resource_task::ResourceTask;
|
use servo_net::resource_task::ResourceTask;
|
||||||
#[cfg(not(test))]
|
#[cfg(not(test))]
|
||||||
use servo_util::time::Profiler;
|
use servo_util::time::TimeProfiler;
|
||||||
#[cfg(not(test))]
|
#[cfg(not(test))]
|
||||||
use servo_util::memory::MemoryProfiler;
|
use servo_util::memory::MemoryProfiler;
|
||||||
|
|
||||||
|
@ -170,11 +170,11 @@ pub fn run(opts: opts::Opts) {
|
||||||
let mut pool = green::SchedPool::new(pool_config);
|
let mut pool = green::SchedPool::new(pool_config);
|
||||||
|
|
||||||
let (compositor_port, compositor_chan) = CompositorChan::new();
|
let (compositor_port, compositor_chan) = CompositorChan::new();
|
||||||
let profiler_chan = Profiler::create(opts.profiler_period);
|
let time_profiler_chan = TimeProfiler::create(opts.time_profiler_period);
|
||||||
let memory_profiler_chan = MemoryProfiler::create(opts.memory_profiler_period);
|
let memory_profiler_chan = MemoryProfiler::create(opts.memory_profiler_period);
|
||||||
|
|
||||||
let opts_clone = opts.clone();
|
let opts_clone = opts.clone();
|
||||||
let profiler_chan_clone = profiler_chan.clone();
|
let time_profiler_chan_clone = time_profiler_chan.clone();
|
||||||
|
|
||||||
let (result_chan, result_port) = channel();
|
let (result_chan, result_port) = channel();
|
||||||
pool.spawn(TaskOpts::new(), proc() {
|
pool.spawn(TaskOpts::new(), proc() {
|
||||||
|
@ -193,7 +193,7 @@ pub fn run(opts: opts::Opts) {
|
||||||
opts,
|
opts,
|
||||||
resource_task,
|
resource_task,
|
||||||
image_cache_task,
|
image_cache_task,
|
||||||
profiler_chan_clone);
|
time_profiler_chan_clone);
|
||||||
|
|
||||||
// Send the URL command to the constellation.
|
// Send the URL command to the constellation.
|
||||||
for filename in opts.urls.iter() {
|
for filename in opts.urls.iter() {
|
||||||
|
@ -220,7 +220,7 @@ pub fn run(opts: opts::Opts) {
|
||||||
CompositorTask::create(opts,
|
CompositorTask::create(opts,
|
||||||
compositor_port,
|
compositor_port,
|
||||||
constellation_chan,
|
constellation_chan,
|
||||||
profiler_chan,
|
time_profiler_chan,
|
||||||
memory_profiler_chan);
|
memory_profiler_chan);
|
||||||
|
|
||||||
pool.shutdown();
|
pool.shutdown();
|
||||||
|
|
|
@ -53,8 +53,8 @@ impl MemoryProfiler {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
None => {
|
None => {
|
||||||
// No-op to handle profiler messages when the memory profiler
|
// No-op to handle messages when the memory profiler is
|
||||||
// is inactive.
|
// inactive.
|
||||||
spawn_named("Memory profiler", proc() {
|
spawn_named("Memory profiler", proc() {
|
||||||
loop {
|
loop {
|
||||||
match port.recv_opt() {
|
match port.recv_opt() {
|
||||||
|
|
|
@ -41,9 +41,9 @@ pub struct Opts {
|
||||||
/// platform default setting.
|
/// platform default setting.
|
||||||
pub device_pixels_per_px: Option<ScaleFactor<ScreenPx, DevicePixel, f32>>,
|
pub device_pixels_per_px: Option<ScaleFactor<ScreenPx, DevicePixel, f32>>,
|
||||||
|
|
||||||
/// `None` to disable the profiler or `Some` with an interval in seconds to enable it and cause
|
/// `None` to disable the time profiler or `Some` with an interval in seconds to enable it and
|
||||||
/// it to produce output on that interval (`-p`).
|
/// cause it to produce output on that interval (`-p`).
|
||||||
pub profiler_period: Option<f64>,
|
pub time_profiler_period: Option<f64>,
|
||||||
|
|
||||||
/// `None` to disable the memory profiler or `Some` with an interval in seconds to enable it
|
/// `None` to disable the memory profiler or `Some` with an interval in seconds to enable it
|
||||||
/// and cause it to produce output on that interval (`-m`).
|
/// and cause it to produce output on that interval (`-m`).
|
||||||
|
@ -153,7 +153,7 @@ pub fn from_cmdline_args(args: &[String]) -> Option<Opts> {
|
||||||
};
|
};
|
||||||
|
|
||||||
// If only the flag is present, default to a 5 second period for both profilers.
|
// If only the flag is present, default to a 5 second period for both profilers.
|
||||||
let profiler_period = opt_match.opt_default("p", "5").map(|period| {
|
let time_profiler_period = opt_match.opt_default("p", "5").map(|period| {
|
||||||
from_str(period.as_slice()).unwrap()
|
from_str(period.as_slice()).unwrap()
|
||||||
});
|
});
|
||||||
let memory_profiler_period = opt_match.opt_default("m", "5").map(|period| {
|
let memory_profiler_period = opt_match.opt_default("m", "5").map(|period| {
|
||||||
|
@ -174,7 +174,7 @@ pub fn from_cmdline_args(args: &[String]) -> Option<Opts> {
|
||||||
cpu_painting: cpu_painting,
|
cpu_painting: cpu_painting,
|
||||||
tile_size: tile_size,
|
tile_size: tile_size,
|
||||||
device_pixels_per_px: device_pixels_per_px,
|
device_pixels_per_px: device_pixels_per_px,
|
||||||
profiler_period: profiler_period,
|
time_profiler_period: time_profiler_period,
|
||||||
memory_profiler_period: memory_profiler_period,
|
memory_profiler_period: memory_profiler_period,
|
||||||
layout_threads: layout_threads,
|
layout_threads: layout_threads,
|
||||||
exit_after_load: opt_match.opt_present("x"),
|
exit_after_load: opt_match.opt_present("x"),
|
||||||
|
|
|
@ -14,18 +14,18 @@ use task::{spawn_named};
|
||||||
|
|
||||||
// front-end representation of the profiler used to communicate with the profiler
|
// front-end representation of the profiler used to communicate with the profiler
|
||||||
#[deriving(Clone)]
|
#[deriving(Clone)]
|
||||||
pub struct ProfilerChan(pub Sender<ProfilerMsg>);
|
pub struct TimeProfilerChan(pub Sender<TimeProfilerMsg>);
|
||||||
|
|
||||||
impl ProfilerChan {
|
impl TimeProfilerChan {
|
||||||
pub fn send(&self, msg: ProfilerMsg) {
|
pub fn send(&self, msg: TimeProfilerMsg) {
|
||||||
let ProfilerChan(ref c) = *self;
|
let TimeProfilerChan(ref c) = *self;
|
||||||
c.send(msg);
|
c.send(msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub enum ProfilerMsg {
|
pub enum TimeProfilerMsg {
|
||||||
/// Normal message used for reporting time
|
/// Normal message used for reporting time
|
||||||
TimeMsg(ProfilerCategory, f64),
|
TimeMsg(TimeProfilerCategory, f64),
|
||||||
/// Message used to force print the profiling metrics
|
/// Message used to force print the profiling metrics
|
||||||
PrintMsg,
|
PrintMsg,
|
||||||
/// Tells the profiler to shut down.
|
/// Tells the profiler to shut down.
|
||||||
|
@ -34,7 +34,7 @@ pub enum ProfilerMsg {
|
||||||
|
|
||||||
#[repr(u32)]
|
#[repr(u32)]
|
||||||
#[deriving(Eq, Clone, Ord, TotalEq, TotalOrd)]
|
#[deriving(Eq, Clone, Ord, TotalEq, TotalOrd)]
|
||||||
pub enum ProfilerCategory {
|
pub enum TimeProfilerCategory {
|
||||||
CompositingCategory,
|
CompositingCategory,
|
||||||
LayoutQueryCategory,
|
LayoutQueryCategory,
|
||||||
LayoutPerformCategory,
|
LayoutPerformCategory,
|
||||||
|
@ -54,14 +54,14 @@ pub enum ProfilerCategory {
|
||||||
NumBuckets,
|
NumBuckets,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ProfilerCategory {
|
impl TimeProfilerCategory {
|
||||||
// convenience function to not have to cast every time
|
// convenience function to not have to cast every time
|
||||||
pub fn num_buckets() -> uint {
|
pub fn num_buckets() -> uint {
|
||||||
NumBuckets as uint
|
NumBuckets as uint
|
||||||
}
|
}
|
||||||
|
|
||||||
// enumeration of all ProfilerCategory types
|
// enumeration of all TimeProfilerCategory types
|
||||||
fn empty_buckets() -> ProfilerBuckets {
|
fn empty_buckets() -> TimeProfilerBuckets {
|
||||||
let mut buckets = TreeMap::new();
|
let mut buckets = TreeMap::new();
|
||||||
buckets.insert(CompositingCategory, vec!());
|
buckets.insert(CompositingCategory, vec!());
|
||||||
buckets.insert(LayoutQueryCategory, vec!());
|
buckets.insert(LayoutQueryCategory, vec!());
|
||||||
|
@ -100,23 +100,23 @@ impl ProfilerCategory {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
type ProfilerBuckets = TreeMap<ProfilerCategory, Vec<f64>>;
|
type TimeProfilerBuckets = TreeMap<TimeProfilerCategory, Vec<f64>>;
|
||||||
|
|
||||||
// back end of the profiler that handles data aggregation and performance metrics
|
// back end of the profiler that handles data aggregation and performance metrics
|
||||||
pub struct Profiler {
|
pub struct TimeProfiler {
|
||||||
pub port: Receiver<ProfilerMsg>,
|
pub port: Receiver<TimeProfilerMsg>,
|
||||||
buckets: ProfilerBuckets,
|
buckets: TimeProfilerBuckets,
|
||||||
pub last_msg: Option<ProfilerMsg>,
|
pub last_msg: Option<TimeProfilerMsg>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Profiler {
|
impl TimeProfiler {
|
||||||
pub fn create(period: Option<f64>) -> ProfilerChan {
|
pub fn create(period: Option<f64>) -> TimeProfilerChan {
|
||||||
let (chan, port) = channel();
|
let (chan, port) = channel();
|
||||||
match period {
|
match period {
|
||||||
Some(period) => {
|
Some(period) => {
|
||||||
let period = (period * 1000f64) as u64;
|
let period = (period * 1000f64) as u64;
|
||||||
let chan = chan.clone();
|
let chan = chan.clone();
|
||||||
spawn_named("Profiler timer", proc() {
|
spawn_named("Time profiler timer", proc() {
|
||||||
loop {
|
loop {
|
||||||
sleep(period);
|
sleep(period);
|
||||||
if chan.send_opt(PrintMsg).is_err() {
|
if chan.send_opt(PrintMsg).is_err() {
|
||||||
|
@ -124,15 +124,15 @@ impl Profiler {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
// Spawn the profiler
|
// Spawn the time profiler.
|
||||||
spawn_named("Profiler", proc() {
|
spawn_named("Time profiler", proc() {
|
||||||
let mut profiler = Profiler::new(port);
|
let mut profiler = TimeProfiler::new(port);
|
||||||
profiler.start();
|
profiler.start();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
None => {
|
None => {
|
||||||
// no-op to handle profiler messages when the profiler is inactive
|
// No-op to handle messages when the time profiler is inactive.
|
||||||
spawn_named("Profiler", proc() {
|
spawn_named("Time profiler", proc() {
|
||||||
loop {
|
loop {
|
||||||
match port.recv_opt() {
|
match port.recv_opt() {
|
||||||
Err(_) | Ok(ExitMsg) => break,
|
Err(_) | Ok(ExitMsg) => break,
|
||||||
|
@ -143,13 +143,13 @@ impl Profiler {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ProfilerChan(chan)
|
TimeProfilerChan(chan)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new(port: Receiver<ProfilerMsg>) -> Profiler {
|
pub fn new(port: Receiver<TimeProfilerMsg>) -> TimeProfiler {
|
||||||
Profiler {
|
TimeProfiler {
|
||||||
port: port,
|
port: port,
|
||||||
buckets: ProfilerCategory::empty_buckets(),
|
buckets: TimeProfilerCategory::empty_buckets(),
|
||||||
last_msg: None,
|
last_msg: None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -168,7 +168,7 @@ impl Profiler {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn handle_msg(&mut self, msg: ProfilerMsg) -> bool {
|
fn handle_msg(&mut self, msg: TimeProfilerMsg) -> bool {
|
||||||
match msg {
|
match msg {
|
||||||
TimeMsg(category, t) => self.buckets.find_mut(&category).unwrap().push(t),
|
TimeMsg(category, t) => self.buckets.find_mut(&category).unwrap().push(t),
|
||||||
PrintMsg => match self.last_msg {
|
PrintMsg => match self.last_msg {
|
||||||
|
@ -210,15 +210,15 @@ impl Profiler {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
pub fn profile<T>(category: ProfilerCategory,
|
pub fn profile<T>(category: TimeProfilerCategory,
|
||||||
profiler_chan: ProfilerChan,
|
time_profiler_chan: TimeProfilerChan,
|
||||||
callback: || -> T)
|
callback: || -> T)
|
||||||
-> T {
|
-> T {
|
||||||
let start_time = precise_time_ns();
|
let start_time = precise_time_ns();
|
||||||
let val = callback();
|
let val = callback();
|
||||||
let end_time = precise_time_ns();
|
let end_time = precise_time_ns();
|
||||||
let ms = (end_time - start_time) as f64 / 1000000f64;
|
let ms = (end_time - start_time) as f64 / 1000000f64;
|
||||||
profiler_chan.send(TimeMsg(category, ms));
|
time_profiler_chan.send(TimeMsg(category, ms));
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -236,6 +236,6 @@ pub fn time<T>(msg: &str, callback: || -> T) -> T{
|
||||||
// ensure that the order of the buckets matches the order of the enum categories
|
// ensure that the order of the buckets matches the order of the enum categories
|
||||||
#[test]
|
#[test]
|
||||||
fn check_order() {
|
fn check_order() {
|
||||||
let buckets = ProfilerCategory::empty_buckets();
|
let buckets = TimeProfilerCategory::empty_buckets();
|
||||||
assert!(buckets.len() == NumBuckets as uint);
|
assert!(buckets.len() == NumBuckets as uint);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue