Auto merge of #19516 - ferjm:pwm.url, r=jdm

Print url of recorded PWM

This makes it a bit easier to compare results with other browsers.

- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/19516)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2017-12-07 14:54:03 -06:00 committed by GitHub
commit c4482ebe77
10 changed files with 45 additions and 9 deletions

2
Cargo.lock generated
View file

@ -1782,6 +1782,7 @@ dependencies = [
"profile_traits 0.0.1", "profile_traits 0.0.1",
"script_traits 0.0.1", "script_traits 0.0.1",
"servo_config 0.0.1", "servo_config 0.0.1",
"servo_url 0.0.1",
"time 0.1.37 (registry+https://github.com/rust-lang/crates.io-index)", "time 0.1.37 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
@ -1797,6 +1798,7 @@ dependencies = [
"msg 0.0.1", "msg 0.0.1",
"net_traits 0.0.1", "net_traits 0.0.1",
"profile_traits 0.0.1", "profile_traits 0.0.1",
"servo_url 0.0.1",
"style 0.0.1", "style 0.0.1",
"time 0.1.37 (registry+https://github.com/rust-lang/crates.io-index)", "time 0.1.37 (registry+https://github.com/rust-lang/crates.io-index)",
] ]

View file

@ -489,7 +489,8 @@ impl UnprivilegedPipelineContent {
let paint_time_metrics = PaintTimeMetrics::new(self.id, let paint_time_metrics = PaintTimeMetrics::new(self.id,
self.time_profiler_chan.clone(), self.time_profiler_chan.clone(),
self.layout_to_constellation_chan.clone(), self.layout_to_constellation_chan.clone(),
self.script_chan.clone()); self.script_chan.clone(),
self.load_data.url.clone());
let layout_pair = STF::create(InitialScriptState { let layout_pair = STF::create(InitialScriptState {
id: self.id, id: self.id,
browsing_context_id: self.browsing_context_id, browsing_context_id: self.browsing_context_id,

View file

@ -20,4 +20,5 @@ msg = {path = "../msg"}
profile_traits = {path = "../profile_traits"} profile_traits = {path = "../profile_traits"}
script_traits = {path = "../script_traits"} script_traits = {path = "../script_traits"}
servo_config = {path = "../config"} servo_config = {path = "../config"}
servo_url = {path = "../url"}
time = "0.1" time = "0.1"

View file

@ -14,6 +14,7 @@ extern crate msg;
extern crate profile_traits; extern crate profile_traits;
extern crate script_traits; extern crate script_traits;
extern crate servo_config; extern crate servo_config;
extern crate servo_url;
extern crate time; extern crate time;
use gfx::display_list::{DisplayItem, DisplayList}; use gfx::display_list::{DisplayItem, DisplayList};
@ -24,6 +25,7 @@ use profile_traits::time::{ProfilerChan, ProfilerCategory, send_profile_data};
use profile_traits::time::TimerMetadata; use profile_traits::time::TimerMetadata;
use script_traits::{ConstellationControlMsg, LayoutMsg, ProgressiveWebMetricType}; use script_traits::{ConstellationControlMsg, LayoutMsg, ProgressiveWebMetricType};
use servo_config::opts; use servo_config::opts;
use servo_url::ServoUrl;
use std::cell::{Cell, RefCell}; use std::cell::{Cell, RefCell};
use std::cmp::Ordering; use std::cmp::Ordering;
use std::collections::HashMap; use std::collections::HashMap;
@ -38,6 +40,7 @@ pub trait ProgressiveWebMetric {
fn set_navigation_start(&mut self, time: u64); fn set_navigation_start(&mut self, time: u64);
fn get_time_profiler_chan(&self) -> &ProfilerChan; fn get_time_profiler_chan(&self) -> &ProfilerChan;
fn send_queued_constellation_msg(&self, name: ProgressiveWebMetricType, time: u64); fn send_queued_constellation_msg(&self, name: ProgressiveWebMetricType, time: u64);
fn get_url(&self) -> &ServoUrl;
} }
/// TODO make this configurable /// TODO make this configurable
@ -62,7 +65,8 @@ fn set_metric<U: ProgressiveWebMetric>(
metric_type: ProgressiveWebMetricType, metric_type: ProgressiveWebMetricType,
category: ProfilerCategory, category: ProfilerCategory,
attr: &Cell<Option<u64>>, attr: &Cell<Option<u64>>,
metric_time: Option<u64>) metric_time: Option<u64>,
url: &ServoUrl)
{ {
let navigation_start = match pwm.get_navigation_start() { let navigation_start = match pwm.get_navigation_start() {
Some(time) => time, Some(time) => time,
@ -95,7 +99,7 @@ fn set_metric<U: ProgressiveWebMetric>(
// Print the metric to console if the print-pwm option was given. // Print the metric to console if the print-pwm option was given.
if opts::get().print_pwm { if opts::get().print_pwm {
println!("Navigation start: {}", pwm.get_navigation_start().unwrap().to_ms()); println!("Navigation start: {}", pwm.get_navigation_start().unwrap().to_ms());
println!("{:?} {:?}", metric_type, time.to_ms()); println!("{:?} {:?} {:?}", url, metric_type, time.to_ms());
} }
} }
@ -117,6 +121,7 @@ pub struct InteractiveMetrics {
time_to_interactive: Cell<Option<u64>>, time_to_interactive: Cell<Option<u64>>,
#[ignore_malloc_size_of = "can't measure channels"] #[ignore_malloc_size_of = "can't measure channels"]
time_profiler_chan: ProfilerChan, time_profiler_chan: ProfilerChan,
url: ServoUrl
} }
#[derive(Clone, Copy, Debug, MallocSizeOf)] #[derive(Clone, Copy, Debug, MallocSizeOf)]
@ -157,13 +162,14 @@ pub enum InteractiveFlag {
} }
impl InteractiveMetrics { impl InteractiveMetrics {
pub fn new(time_profiler_chan: ProfilerChan) -> InteractiveMetrics { pub fn new(time_profiler_chan: ProfilerChan, url: ServoUrl) -> InteractiveMetrics {
InteractiveMetrics { InteractiveMetrics {
navigation_start: None, navigation_start: None,
dom_content_loaded: Cell::new(None), dom_content_loaded: Cell::new(None),
main_thread_available: Cell::new(None), main_thread_available: Cell::new(None),
time_to_interactive: Cell::new(None), time_to_interactive: Cell::new(None),
time_profiler_chan: time_profiler_chan, time_profiler_chan: time_profiler_chan,
url,
} }
} }
@ -221,7 +227,9 @@ impl InteractiveMetrics {
ProgressiveWebMetricType::TimeToInteractive, ProgressiveWebMetricType::TimeToInteractive,
ProfilerCategory::TimeToInteractive, ProfilerCategory::TimeToInteractive,
&self.time_to_interactive, &self.time_to_interactive,
Some(metric_time)); Some(metric_time),
&self.url,
);
} }
pub fn get_tti(&self) -> Option<u64> { pub fn get_tti(&self) -> Option<u64> {
@ -247,6 +255,10 @@ impl ProgressiveWebMetric for InteractiveMetrics {
fn get_time_profiler_chan(&self) -> &ProfilerChan { fn get_time_profiler_chan(&self) -> &ProfilerChan {
&self.time_profiler_chan &self.time_profiler_chan
} }
fn get_url(&self) -> &ServoUrl {
&self.url
}
} }
pub struct PaintTimeMetrics { pub struct PaintTimeMetrics {
@ -258,6 +270,7 @@ pub struct PaintTimeMetrics {
time_profiler_chan: ProfilerChan, time_profiler_chan: ProfilerChan,
constellation_chan: IpcSender<LayoutMsg>, constellation_chan: IpcSender<LayoutMsg>,
script_chan: IpcSender<ConstellationControlMsg>, script_chan: IpcSender<ConstellationControlMsg>,
url: ServoUrl,
} }
impl PaintTimeMetrics { impl PaintTimeMetrics {
@ -265,7 +278,8 @@ impl PaintTimeMetrics {
pipeline_id: PipelineId, pipeline_id: PipelineId,
time_profiler_chan: ProfilerChan, time_profiler_chan: ProfilerChan,
constellation_chan: IpcSender<LayoutMsg>, constellation_chan: IpcSender<LayoutMsg>,
script_chan: IpcSender<ConstellationControlMsg>) script_chan: IpcSender<ConstellationControlMsg>,
url: ServoUrl)
-> PaintTimeMetrics { -> PaintTimeMetrics {
PaintTimeMetrics { PaintTimeMetrics {
pending_metrics: RefCell::new(HashMap::new()), pending_metrics: RefCell::new(HashMap::new()),
@ -276,6 +290,7 @@ impl PaintTimeMetrics {
time_profiler_chan, time_profiler_chan,
constellation_chan, constellation_chan,
script_chan, script_chan,
url,
} }
} }
@ -294,6 +309,7 @@ impl PaintTimeMetrics {
ProfilerCategory::TimeToFirstPaint, ProfilerCategory::TimeToFirstPaint,
&self.first_paint, &self.first_paint,
None, None,
&self.url,
); );
} }
@ -354,6 +370,7 @@ impl PaintTimeMetrics {
ProfilerCategory::TimeToFirstPaint, ProfilerCategory::TimeToFirstPaint,
&self.first_paint, &self.first_paint,
Some(paint_time), Some(paint_time),
&self.url,
); );
if pending_metric.1 { if pending_metric.1 {
@ -364,6 +381,7 @@ impl PaintTimeMetrics {
ProfilerCategory::TimeToFirstContentfulPaint, ProfilerCategory::TimeToFirstContentfulPaint,
&self.first_contentful_paint, &self.first_contentful_paint,
Some(paint_time), Some(paint_time),
&self.url,
); );
} }
} }
@ -397,4 +415,8 @@ impl ProgressiveWebMetric for PaintTimeMetrics {
fn get_time_profiler_chan(&self) -> &ProfilerChan { fn get_time_profiler_chan(&self) -> &ProfilerChan {
&self.time_profiler_chan &self.time_profiler_chan
} }
fn get_url(&self) -> &ServoUrl {
&self.url
}
} }

View file

@ -2186,7 +2186,7 @@ impl Document {
(DocumentReadyState::Complete, true) (DocumentReadyState::Complete, true)
}; };
let interactive_time = InteractiveMetrics::new(window.time_profiler_chan().clone()); let interactive_time = InteractiveMetrics::new(window.time_profiler_chan().clone(), url.clone());
Document { Document {
node: Node::new_document_node(), node: Node::new_document_node(),

View file

@ -1557,7 +1557,8 @@ impl ScriptThread {
paint_time_metrics: PaintTimeMetrics::new(new_pipeline_id, paint_time_metrics: PaintTimeMetrics::new(new_pipeline_id,
self.time_profiler_chan.clone(), self.time_profiler_chan.clone(),
self.layout_to_constellation_chan.clone(), self.layout_to_constellation_chan.clone(),
self.control_chan.clone()), self.control_chan.clone(),
load_data.url.clone()),
}); });
// Pick a layout thread, any layout thread // Pick a layout thread, any layout thread

View file

@ -18,5 +18,6 @@ metrics = {path = "../../../components/metrics"}
msg = {path = "../../../components/msg"} msg = {path = "../../../components/msg"}
net_traits = {path = "../../../components/net_traits"} net_traits = {path = "../../../components/net_traits"}
profile_traits = {path = "../../../components/profile_traits"} profile_traits = {path = "../../../components/profile_traits"}
servo_url = {path = "../../../components/url"}
style = {path = "../../../components/style"} style = {path = "../../../components/style"}
time = "0.1.12" time = "0.1.12"

View file

@ -6,6 +6,7 @@ use ipc_channel::ipc;
use metrics::{InteractiveMetrics, InteractiveFlag}; use metrics::{InteractiveMetrics, InteractiveFlag};
use metrics::{ProfilerMetadataFactory, ProgressiveWebMetric}; use metrics::{ProfilerMetadataFactory, ProgressiveWebMetric};
use profile_traits::time::{ProfilerChan, TimerMetadata}; use profile_traits::time::{ProfilerChan, TimerMetadata};
use servo_url::ServoUrl;
use time; use time;
struct DummyProfilerMetadataFactory {} struct DummyProfilerMetadataFactory {}
@ -19,7 +20,10 @@ impl ProfilerMetadataFactory for DummyProfilerMetadataFactory {
fn test_interactive() -> InteractiveMetrics { fn test_interactive() -> InteractiveMetrics {
let (sender, _) = ipc::channel().unwrap(); let (sender, _) = ipc::channel().unwrap();
let profiler_chan = ProfilerChan(sender); let profiler_chan = ProfilerChan(sender);
let mut interactive = InteractiveMetrics::new(profiler_chan); let mut interactive = InteractiveMetrics::new(
profiler_chan,
ServoUrl::parse("about:blank").unwrap(),
);
assert_eq!((&interactive).get_navigation_start(), None); assert_eq!((&interactive).get_navigation_start(), None);
assert_eq!(interactive.get_tti(), None); assert_eq!(interactive.get_tti(), None);

View file

@ -12,6 +12,7 @@ extern crate metrics;
extern crate msg; extern crate msg;
extern crate net_traits; extern crate net_traits;
extern crate profile_traits; extern crate profile_traits;
extern crate servo_url;
extern crate style; extern crate style;
extern crate time; extern crate time;

View file

@ -11,6 +11,7 @@ use metrics::{PaintTimeMetrics, ProfilerMetadataFactory, ProgressiveWebMetric};
use msg::constellation_msg::TEST_PIPELINE_ID; use msg::constellation_msg::TEST_PIPELINE_ID;
use net_traits::image::base::PixelFormat; use net_traits::image::base::PixelFormat;
use profile_traits::time::{ProfilerChan, TimerMetadata}; use profile_traits::time::{ProfilerChan, TimerMetadata};
use servo_url::ServoUrl;
use style::computed_values::image_rendering::T as ImageRendering; use style::computed_values::image_rendering::T as ImageRendering;
use time; use time;
@ -32,6 +33,7 @@ fn test_paint_metrics_construction() {
profiler_chan, profiler_chan,
layout_sender, layout_sender,
script_sender, script_sender,
ServoUrl::parse("about:blank").unwrap(),
); );
assert_eq!( assert_eq!(
(&paint_time_metrics).get_navigation_start(), (&paint_time_metrics).get_navigation_start(),
@ -60,6 +62,7 @@ fn test_common(display_list: &DisplayList, epoch: Epoch) -> PaintTimeMetrics {
profiler_chan, profiler_chan,
layout_sender, layout_sender,
script_sender, script_sender,
ServoUrl::parse("about:blank").unwrap(),
); );
let dummy_profiler_metadata_factory = DummyProfilerMetadataFactory {}; let dummy_profiler_metadata_factory = DummyProfilerMetadataFactory {};