зеркало из https://github.com/mozilla/gecko-dev.git
servo: Merge #19498 - Fix float conversion of paint timing metrics (from ferjm:pwm.f64); r=jdm
This is a follow up of #19077 - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors Source-Repo: https://github.com/servo/servo Source-Revision: ff70c4426d9ea2f36dc18216678f743e9f56f561 --HG-- extra : subtree_source : https%3A//hg.mozilla.org/projects/converted-servo-linear extra : subtree_revision : a54b8a720c19fdb3b5850b48e8f371a0fb8468df
This commit is contained in:
Родитель
e15c276db2
Коммит
5d913c504f
|
@ -46,6 +46,15 @@ pub const MAX_TASK_NS: u64 = 50000000;
|
|||
/// 10 second window (in ns)
|
||||
const INTERACTIVE_WINDOW_SECONDS_IN_NS: u64 = 10000000000;
|
||||
|
||||
pub trait ToMs<T> {
|
||||
fn to_ms(&self) -> T;
|
||||
}
|
||||
|
||||
impl ToMs<f64> for u64 {
|
||||
fn to_ms(&self) -> f64 {
|
||||
*self as f64 / 1000000.
|
||||
}
|
||||
}
|
||||
|
||||
fn set_metric<U: ProgressiveWebMetric>(
|
||||
pwm: &U,
|
||||
|
@ -85,8 +94,8 @@ fn set_metric<U: ProgressiveWebMetric>(
|
|||
|
||||
// Print the metric to console if the print-pwm option was given.
|
||||
if opts::get().print_pwm {
|
||||
println!("Navigation start: {}", pwm.get_navigation_start().unwrap());
|
||||
println!("{:?} {:?}", metric_type, time);
|
||||
println!("Navigation start: {}", pwm.get_navigation_start().unwrap().to_ms());
|
||||
println!("{:?} {:?}", metric_type, time.to_ms());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -20,6 +20,7 @@ use dom::performanceobserver::PerformanceObserver as DOMPerformanceObserver;
|
|||
use dom::performancetiming::PerformanceTiming;
|
||||
use dom::window::Window;
|
||||
use dom_struct::dom_struct;
|
||||
use metrics::ToMs;
|
||||
use std::cell::Cell;
|
||||
use std::cmp::Ordering;
|
||||
use time;
|
||||
|
@ -260,7 +261,7 @@ impl Performance {
|
|||
Some(ref timing) => timing.navigation_start_precise(),
|
||||
None => self.navigation_start_precise,
|
||||
};
|
||||
(time::precise_time_ns() - nav_start) as f64 / 1000000.
|
||||
(time::precise_time_ns() - nav_start).to_ms()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@ use dom::bindings::str::DOMString;
|
|||
use dom::globalscope::GlobalScope;
|
||||
use dom::performanceentry::PerformanceEntry;
|
||||
use dom_struct::dom_struct;
|
||||
use metrics::ToMs;
|
||||
use script_traits::ProgressiveWebMetricType;
|
||||
|
||||
#[dom_struct]
|
||||
|
@ -26,7 +27,7 @@ impl PerformancePaintTiming {
|
|||
PerformancePaintTiming {
|
||||
entry: PerformanceEntry::new_inherited(name,
|
||||
DOMString::from("paint"),
|
||||
start_time as f64,
|
||||
start_time.to_ms(),
|
||||
0.)
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче