aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--components/compositing/compositor.rs2
-rw-r--r--components/metrics/lib.rs60
-rw-r--r--components/script/dom/document.rs2
-rw-r--r--components/script/dom/performance.rs8
-rw-r--r--components/script/dom/performancepainttiming.rs6
-rw-r--r--components/script/dom/performancetiming.rs8
-rw-r--r--components/script/dom/window.rs8
-rw-r--r--components/script/dom/workerglobalscope.rs4
-rw-r--r--components/script/script_thread.rs6
-rw-r--r--components/script_layout_interface/message.rs2
-rw-r--r--components/script_traits/lib.rs4
-rw-r--r--tests/unit/metrics/interactive_time.rs14
-rw-r--r--tests/unit/metrics/paint_time.rs8
13 files changed, 66 insertions, 66 deletions
diff --git a/components/compositing/compositor.rs b/components/compositing/compositor.rs
index cd9f2b2b21d..920b7aaa584 100644
--- a/components/compositing/compositor.rs
+++ b/components/compositing/compositor.rs
@@ -1311,7 +1311,7 @@ impl<Window: WindowMethods> IOCompositor<Window> {
// we get the current time, inform the layout thread about it and remove the
// pending metric from the list.
if !self.pending_paint_metrics.is_empty() {
- let paint_time = precise_time_ns() as f64;
+ let paint_time = precise_time_ns();
let mut to_remove = Vec::new();
// For each pending paint metrics pipeline id
for (id, pending_epoch) in &self.pending_paint_metrics {
diff --git a/components/metrics/lib.rs b/components/metrics/lib.rs
index 47264448927..7e7cd9afd1d 100644
--- a/components/metrics/lib.rs
+++ b/components/metrics/lib.rs
@@ -34,10 +34,10 @@ pub trait ProfilerMetadataFactory {
}
pub trait ProgressiveWebMetric {
- fn get_navigation_start(&self) -> Option<f64>;
- fn set_navigation_start(&mut self, time: f64);
+ fn get_navigation_start(&self) -> Option<u64>;
+ fn set_navigation_start(&mut self, time: u64);
fn get_time_profiler_chan(&self) -> &ProfilerChan;
- fn send_queued_constellation_msg(&self, name: ProgressiveWebMetricType, time: f64);
+ fn send_queued_constellation_msg(&self, name: ProgressiveWebMetricType, time: u64);
}
/// maximum task time is 50ms (in ns)
@@ -51,8 +51,8 @@ fn set_metric<U: ProgressiveWebMetric>(
metadata: Option<TimerMetadata>,
metric_type: ProgressiveWebMetricType,
category: ProfilerCategory,
- attr: &Cell<Option<f64>>,
- metric_time: Option<f64>)
+ attr: &Cell<Option<u64>>,
+ metric_time: Option<u64>)
{
let navigation_start = match pwm.get_navigation_start() {
Some(time) => time,
@@ -63,7 +63,7 @@ fn set_metric<U: ProgressiveWebMetric>(
};
let now = match metric_time {
Some(time) => time,
- None => precise_time_ns() as f64,
+ None => precise_time_ns(),
};
let time = now - navigation_start;
attr.set(Some(time));
@@ -76,8 +76,8 @@ fn set_metric<U: ProgressiveWebMetric>(
category,
metadata,
&pwm.get_time_profiler_chan(),
- time as u64,
- time as u64,
+ time,
+ time,
0,
0,
);
@@ -97,13 +97,13 @@ fn set_metric<U: ProgressiveWebMetric>(
#[derive(MallocSizeOf)]
pub struct InteractiveMetrics {
/// when we navigated to the page
- navigation_start: Option<f64>,
+ navigation_start: Option<u64>,
/// indicates if the page is visually ready
- dom_content_loaded: Cell<Option<f64>>,
+ dom_content_loaded: Cell<Option<u64>>,
/// main thread is available -- there's been a 10s window with no tasks longer than 50ms
- main_thread_available: Cell<Option<f64>>,
+ main_thread_available: Cell<Option<u64>>,
// max(main_thread_available, dom_content_loaded)
- time_to_interactive: Cell<Option<f64>>,
+ time_to_interactive: Cell<Option<u64>>,
#[ignore_malloc_size_of = "can't measure channels"]
time_profiler_chan: ProfilerChan,
}
@@ -142,7 +142,7 @@ impl InteractiveWindow {
#[derive(Debug)]
pub enum InteractiveFlag {
DOMContentLoaded,
- TimeToInteractive(f64),
+ TimeToInteractive(u64),
}
impl InteractiveMetrics {
@@ -158,21 +158,21 @@ impl InteractiveMetrics {
pub fn set_dom_content_loaded(&self) {
if self.dom_content_loaded.get().is_none() {
- self.dom_content_loaded.set(Some(precise_time_ns() as f64));
+ self.dom_content_loaded.set(Some(precise_time_ns()));
}
}
- pub fn set_main_thread_available(&self, time: f64) {
+ pub fn set_main_thread_available(&self, time: u64) {
if self.main_thread_available.get().is_none() {
self.main_thread_available.set(Some(time));
}
}
- pub fn get_dom_content_loaded(&self) -> Option<f64> {
+ pub fn get_dom_content_loaded(&self) -> Option<u64> {
self.dom_content_loaded.get()
}
- pub fn get_main_thread_available(&self) -> Option<f64> {
+ pub fn get_main_thread_available(&self) -> Option<u64> {
self.main_thread_available.get()
}
@@ -213,21 +213,21 @@ impl InteractiveMetrics {
Some(metric_time));
}
- pub fn get_tti(&self) -> Option<f64> {
+ pub fn get_tti(&self) -> Option<u64> {
self.time_to_interactive.get()
}
}
impl ProgressiveWebMetric for InteractiveMetrics {
- fn get_navigation_start(&self) -> Option<f64> {
+ fn get_navigation_start(&self) -> Option<u64> {
self.navigation_start
}
- fn set_navigation_start(&mut self, time: f64) {
+ fn set_navigation_start(&mut self, time: u64) {
self.navigation_start = Some(time);
}
- fn send_queued_constellation_msg(&self, _name: ProgressiveWebMetricType, _time: f64) { }
+ fn send_queued_constellation_msg(&self, _name: ProgressiveWebMetricType, _time: u64) { }
fn get_time_profiler_chan(&self) -> &ProfilerChan {
&self.time_profiler_chan
@@ -236,9 +236,9 @@ impl ProgressiveWebMetric for InteractiveMetrics {
pub struct PaintTimeMetrics {
pending_metrics: RefCell<HashMap<Epoch, (Option<TimerMetadata>, bool)>>,
- navigation_start: Option<f64>,
- first_paint: Cell<Option<f64>>,
- first_contentful_paint: Cell<Option<f64>>,
+ navigation_start: Option<u64>,
+ first_paint: Cell<Option<u64>>,
+ first_contentful_paint: Cell<Option<u64>>,
pipeline_id: PipelineId,
time_profiler_chan: ProfilerChan,
constellation_chan: IpcSender<LayoutMsg>,
@@ -322,7 +322,7 @@ impl PaintTimeMetrics {
}
}
- pub fn maybe_set_metric(&self, epoch: Epoch, paint_time: f64) {
+ pub fn maybe_set_metric(&self, epoch: Epoch, paint_time: u64) {
if self.first_paint.get().is_some() && self.first_contentful_paint.get().is_some() ||
self.navigation_start.is_none() {
// If we already set all paint metrics or we have not set navigation start yet,
@@ -354,25 +354,25 @@ impl PaintTimeMetrics {
}
}
- pub fn get_first_paint(&self) -> Option<f64> {
+ pub fn get_first_paint(&self) -> Option<u64> {
self.first_paint.get()
}
- pub fn get_first_contentful_paint(&self) -> Option<f64> {
+ pub fn get_first_contentful_paint(&self) -> Option<u64> {
self.first_contentful_paint.get()
}
}
impl ProgressiveWebMetric for PaintTimeMetrics {
- fn get_navigation_start(&self) -> Option<f64> {
+ fn get_navigation_start(&self) -> Option<u64> {
self.navigation_start
}
- fn set_navigation_start(&mut self, time: f64) {
+ fn set_navigation_start(&mut self, time: u64) {
self.navigation_start = Some(time);
}
- fn send_queued_constellation_msg(&self, name: ProgressiveWebMetricType, time: f64) {
+ fn send_queued_constellation_msg(&self, name: ProgressiveWebMetricType, time: u64) {
let msg = ConstellationControlMsg::PaintMetric(self.pipeline_id, name, time);
if let Err(e) = self.script_chan.send(msg) {
warn!("Sending metric to script thread failed ({}).", e);
diff --git a/components/script/dom/document.rs b/components/script/dom/document.rs
index 0cb0bf2def5..a43a7044ca0 100644
--- a/components/script/dom/document.rs
+++ b/components/script/dom/document.rs
@@ -1961,7 +1961,7 @@ impl Document {
if self.tti_window.borrow().needs_check() {
self.get_interactive_metrics().maybe_set_tti(self,
- InteractiveFlag::TimeToInteractive(self.tti_window.borrow().get_start() as f64));
+ InteractiveFlag::TimeToInteractive(self.tti_window.borrow().get_start()));
}
}
diff --git a/components/script/dom/performance.rs b/components/script/dom/performance.rs
index f491fbb7654..5e1f7e6fb92 100644
--- a/components/script/dom/performance.rs
+++ b/components/script/dom/performance.rs
@@ -114,13 +114,13 @@ pub struct Performance {
entries: DomRefCell<PerformanceEntryList>,
observers: DomRefCell<Vec<PerformanceObserver>>,
pending_notification_observers_task: Cell<bool>,
- navigation_start_precise: f64,
+ navigation_start_precise: u64,
}
impl Performance {
fn new_inherited(global: &GlobalScope,
navigation_start: u64,
- navigation_start_precise: f64) -> Performance {
+ navigation_start_precise: u64) -> Performance {
Performance {
reflector_: Reflector::new(),
timing: if global.is::<Window>() {
@@ -139,7 +139,7 @@ impl Performance {
pub fn new(global: &GlobalScope,
navigation_start: u64,
- navigation_start_precise: f64) -> DomRoot<Performance> {
+ navigation_start_precise: u64) -> DomRoot<Performance> {
reflect_dom_object(
Box::new(Performance::new_inherited(global, navigation_start, navigation_start_precise)),
global,
@@ -260,7 +260,7 @@ impl Performance {
Some(ref timing) => timing.navigation_start_precise(),
None => self.navigation_start_precise,
};
- (time::precise_time_ns() as f64 - nav_start) / 1000000 as f64
+ (time::precise_time_ns() - nav_start) as f64 / 1000000.
}
}
diff --git a/components/script/dom/performancepainttiming.rs b/components/script/dom/performancepainttiming.rs
index f5fc8300587..567f5e77ef4 100644
--- a/components/script/dom/performancepainttiming.rs
+++ b/components/script/dom/performancepainttiming.rs
@@ -17,7 +17,7 @@ pub struct PerformancePaintTiming {
}
impl PerformancePaintTiming {
- fn new_inherited(metric_type: ProgressiveWebMetricType, start_time: f64) -> PerformancePaintTiming {
+ fn new_inherited(metric_type: ProgressiveWebMetricType, start_time: u64) -> PerformancePaintTiming {
let name = match metric_type {
ProgressiveWebMetricType::FirstPaint => DOMString::from("first-paint"),
ProgressiveWebMetricType::FirstContentfulPaint => DOMString::from("first-contentful-paint"),
@@ -26,7 +26,7 @@ impl PerformancePaintTiming {
PerformancePaintTiming {
entry: PerformanceEntry::new_inherited(name,
DOMString::from("paint"),
- start_time,
+ start_time as f64,
0.)
}
}
@@ -34,7 +34,7 @@ impl PerformancePaintTiming {
#[allow(unrooted_must_root)]
pub fn new(global: &GlobalScope,
metric_type: ProgressiveWebMetricType,
- start_time: f64) -> DomRoot<PerformancePaintTiming> {
+ start_time: u64) -> DomRoot<PerformancePaintTiming> {
let entry = PerformancePaintTiming::new_inherited(metric_type, start_time);
reflect_dom_object(Box::new(entry), global, PerformancePaintTimingBinding::Wrap)
}
diff --git a/components/script/dom/performancetiming.rs b/components/script/dom/performancetiming.rs
index 1192418a4b9..0ede2f69b07 100644
--- a/components/script/dom/performancetiming.rs
+++ b/components/script/dom/performancetiming.rs
@@ -15,13 +15,13 @@ use dom_struct::dom_struct;
pub struct PerformanceTiming {
reflector_: Reflector,
navigation_start: u64,
- navigation_start_precise: f64,
+ navigation_start_precise: u64,
document: Dom<Document>,
}
impl PerformanceTiming {
fn new_inherited(nav_start: u64,
- nav_start_precise: f64,
+ nav_start_precise: u64,
document: &Document)
-> PerformanceTiming {
PerformanceTiming {
@@ -35,7 +35,7 @@ impl PerformanceTiming {
#[allow(unrooted_must_root)]
pub fn new(window: &Window,
navigation_start: u64,
- navigation_start_precise: f64)
+ navigation_start_precise: u64)
-> DomRoot<PerformanceTiming> {
let timing = PerformanceTiming::new_inherited(navigation_start,
navigation_start_precise,
@@ -90,7 +90,7 @@ impl PerformanceTimingMethods for PerformanceTiming {
impl PerformanceTiming {
- pub fn navigation_start_precise(&self) -> f64 {
+ pub fn navigation_start_precise(&self) -> u64 {
self.navigation_start_precise
}
}
diff --git a/components/script/dom/window.rs b/components/script/dom/window.rs
index deaa6e7e522..e089338afca 100644
--- a/components/script/dom/window.rs
+++ b/components/script/dom/window.rs
@@ -186,7 +186,7 @@ pub struct Window {
custom_element_registry: MutNullableDom<CustomElementRegistry>,
performance: MutNullableDom<Performance>,
navigation_start: Cell<u64>,
- navigation_start_precise: Cell<f64>,
+ navigation_start_precise: Cell<u64>,
screen: MutNullableDom<Screen>,
session_storage: MutNullableDom<Storage>,
local_storage: MutNullableDom<Storage>,
@@ -1045,7 +1045,7 @@ impl Window {
}
}
- pub fn get_navigation_start(&self) -> f64 {
+ pub fn get_navigation_start(&self) -> u64 {
self.navigation_start_precise.get()
}
@@ -1734,7 +1734,7 @@ impl Window {
let current_time = time::get_time();
let now = (current_time.sec * 1000 + current_time.nsec as i64 / 1000000) as u64;
self.navigation_start.set(now);
- self.navigation_start_precise.set(time::precise_time_ns() as f64);
+ self.navigation_start_precise.set(time::precise_time_ns());
}
fn send_to_constellation(&self, msg: ScriptMsg) {
@@ -1777,7 +1777,7 @@ impl Window {
window_size: Option<WindowSizeData>,
origin: MutableOrigin,
navigation_start: u64,
- navigation_start_precise: f64,
+ navigation_start_precise: u64,
webgl_chan: WebGLChan,
webvr_chan: Option<IpcSender<WebVRMsg>>,
microtask_queue: Rc<MicrotaskQueue>,
diff --git a/components/script/dom/workerglobalscope.rs b/components/script/dom/workerglobalscope.rs
index 039cbd235dd..13321e3ee03 100644
--- a/components/script/dom/workerglobalscope.rs
+++ b/components/script/dom/workerglobalscope.rs
@@ -90,7 +90,7 @@ pub struct WorkerGlobalScope {
/// `IpcSender` doesn't exist
from_devtools_receiver: Receiver<DevtoolScriptControlMsg>,
- navigation_start_precise: f64,
+ navigation_start_precise: u64,
performance: MutNullableDom<Performance>,
}
@@ -124,7 +124,7 @@ impl WorkerGlobalScope {
navigator: Default::default(),
from_devtools_sender: init.from_devtools_sender,
from_devtools_receiver,
- navigation_start_precise: precise_time_ns() as f64,
+ navigation_start_precise: precise_time_ns(),
performance: Default::default(),
}
}
diff --git a/components/script/script_thread.rs b/components/script/script_thread.rs
index a8220220191..5cd9261ed2b 100644
--- a/components/script/script_thread.rs
+++ b/components/script/script_thread.rs
@@ -169,7 +169,7 @@ struct InProgressLoad {
/// Timestamp reporting the time when the browser started this load.
navigation_start: u64,
/// High res timestamp reporting the time when the browser started this load.
- navigation_start_precise: f64,
+ navigation_start_precise: u64,
}
impl InProgressLoad {
@@ -183,7 +183,7 @@ impl InProgressLoad {
url: ServoUrl,
origin: MutableOrigin) -> InProgressLoad {
let current_time = get_time();
- let navigation_start_precise = precise_time_ns() as f64;
+ let navigation_start_precise = precise_time_ns();
layout_chan.send(message::Msg::SetNavigationStart(navigation_start_precise)).unwrap();
InProgressLoad {
pipeline_id: id,
@@ -2655,7 +2655,7 @@ impl ScriptThread {
fn handle_paint_metric(&self,
pipeline_id: PipelineId,
metric_type: ProgressiveWebMetricType,
- metric_value: f64) {
+ metric_value: u64) {
let window = self.documents.borrow().find_window(pipeline_id);
if let Some(window) = window {
let entry = PerformancePaintTiming::new(&window.upcast::<GlobalScope>(),
diff --git a/components/script_layout_interface/message.rs b/components/script_layout_interface/message.rs
index 083167d6c34..7a1cb7e5316 100644
--- a/components/script_layout_interface/message.rs
+++ b/components/script_layout_interface/message.rs
@@ -97,7 +97,7 @@ pub enum Msg {
RegisterPaint(Atom, Vec<Atom>, Box<Painter>),
/// Send to layout the precise time when the navigation started.
- SetNavigationStart(f64),
+ SetNavigationStart(u64),
}
#[derive(Debug, PartialEq)]
diff --git a/components/script_traits/lib.rs b/components/script_traits/lib.rs
index b12a656690f..f9e1f38151b 100644
--- a/components/script_traits/lib.rs
+++ b/components/script_traits/lib.rs
@@ -122,7 +122,7 @@ pub enum LayoutControlMsg {
/// and `false` is returned if all fonts have loaded.
GetWebFontLoadState(IpcSender<bool>),
/// Send the paint time for a specific epoch to the layout thread.
- PaintMetric(Epoch, f64),
+ PaintMetric(Epoch, u64),
}
/// can be passed to `LoadUrl` to load a page with GET/POST
@@ -324,7 +324,7 @@ pub enum ConstellationControlMsg {
/// Notifies the script thread of WebVR events.
WebVREvents(PipelineId, Vec<WebVREvent>),
/// Notifies the script thread about a new recorded paint metric.
- PaintMetric(PipelineId, ProgressiveWebMetricType, f64),
+ PaintMetric(PipelineId, ProgressiveWebMetricType, u64),
}
impl fmt::Debug for ConstellationControlMsg {
diff --git a/tests/unit/metrics/interactive_time.rs b/tests/unit/metrics/interactive_time.rs
index 567699f968a..b0b672f1f55 100644
--- a/tests/unit/metrics/interactive_time.rs
+++ b/tests/unit/metrics/interactive_time.rs
@@ -3,7 +3,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use ipc_channel::ipc;
-use metrics::{InteractiveMetrics, InteractiveFlag, InteractiveWindow};
+use metrics::{InteractiveMetrics, InteractiveFlag};
use metrics::{ProfilerMetadataFactory, ProgressiveWebMetric};
use profile_traits::time::{ProfilerChan, TimerMetadata};
use time;
@@ -24,7 +24,7 @@ fn test_interactive() -> InteractiveMetrics {
assert_eq!((&interactive).get_navigation_start(), None);
assert_eq!(interactive.get_tti(), None);
- interactive.set_navigation_start(time::precise_time_ns() as f64);
+ interactive.set_navigation_start(time::precise_time_ns());
interactive
}
@@ -52,16 +52,16 @@ fn test_set_mta() {
let t = time::precise_time_ns();
interactive.maybe_set_tti(
&profiler_metadata_factory,
- InteractiveFlag::TimeToInteractive(t as f64),
+ InteractiveFlag::TimeToInteractive(t),
);
let mta = interactive.get_main_thread_available();
assert!(mta.is_some());
- assert_eq!(mta, Some(t as f64));
+ assert_eq!(mta, Some(t));
//try to overwrite
interactive.maybe_set_tti(
&profiler_metadata_factory,
- InteractiveFlag::TimeToInteractive(time::precise_time_ns() as f64),
+ InteractiveFlag::TimeToInteractive(time::precise_time_ns()),
);
assert_eq!(interactive.get_main_thread_available(), mta);
assert_eq!(interactive.get_tti(), None);
@@ -75,7 +75,7 @@ fn test_set_tti_dcl() {
let t = time::precise_time_ns();
interactive.maybe_set_tti(
&profiler_metadata_factory,
- InteractiveFlag::TimeToInteractive(t as f64),
+ InteractiveFlag::TimeToInteractive(t),
);
let mta = interactive.get_main_thread_available();
assert!(mta.is_some());
@@ -100,7 +100,7 @@ fn test_set_tti_mta() {
let t = time::precise_time_ns();
interactive.maybe_set_tti(
&profiler_metadata_factory,
- InteractiveFlag::TimeToInteractive(t as f64),
+ InteractiveFlag::TimeToInteractive(t),
);
let mta = interactive.get_main_thread_available();
assert!(mta.is_some());
diff --git a/tests/unit/metrics/paint_time.rs b/tests/unit/metrics/paint_time.rs
index 6c49060c15f..7945ea8b60d 100644
--- a/tests/unit/metrics/paint_time.rs
+++ b/tests/unit/metrics/paint_time.rs
@@ -70,7 +70,7 @@ fn test_common(display_list: &DisplayList, epoch: Epoch) -> PaintTimeMetrics {
);
// Should not set any metric until navigation start is set.
- paint_time_metrics.maybe_set_metric(epoch, 0.);
+ paint_time_metrics.maybe_set_metric(epoch, 0);
assert_eq!(
paint_time_metrics.get_first_paint(),
None,
@@ -82,7 +82,7 @@ fn test_common(display_list: &DisplayList, epoch: Epoch) -> PaintTimeMetrics {
"first contentful paint is None"
);
- let navigation_start = time::precise_time_ns() as f64;
+ let navigation_start = time::precise_time_ns();
paint_time_metrics.set_navigation_start(navigation_start);
assert_eq!(
(&paint_time_metrics).get_navigation_start().unwrap(),
@@ -101,7 +101,7 @@ fn test_first_paint_setter() {
};
let epoch = Epoch(0);
let paint_time_metrics = test_common(&empty_display_list, epoch);
- let now = time::precise_time_ns() as f64;
+ let now = time::precise_time_ns();
paint_time_metrics.maybe_set_metric(epoch, now);
assert!(
paint_time_metrics.get_first_paint().is_some(),
@@ -135,7 +135,7 @@ fn test_first_contentful_paint_setter() {
};
let epoch = Epoch(0);
let paint_time_metrics = test_common(&display_list, epoch);
- let now = time::precise_time_ns() as f64;
+ let now = time::precise_time_ns();
paint_time_metrics.maybe_set_metric(epoch, now);
assert!(
paint_time_metrics.get_first_contentful_paint().is_some(),