mirror of
https://github.com/servo/servo.git
synced 2025-08-03 20:50:07 +01:00
implement console.timeLog
(#33377)
* Implement console.timeLog Signed-off-by: Simon Wülker <simon.wuelker@arcor.de> * Adjust WPT expectations Signed-off-by: Simon Wülker <simon.wuelker@arcor.de> --------- Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
This commit is contained in:
parent
8c0a566860
commit
cc3c69b953
6 changed files with 34 additions and 54 deletions
|
@ -2285,6 +2285,21 @@ impl GlobalScope {
|
|||
}
|
||||
}
|
||||
|
||||
/// Computes the delta time since a label has been created
|
||||
///
|
||||
/// Returns an error if the label does not exist.
|
||||
pub fn time_log(&self, label: &str) -> Result<u64, ()> {
|
||||
self.console_timers
|
||||
.borrow()
|
||||
.get(label)
|
||||
.ok_or(())
|
||||
.map(|&start| (Instant::now() - start).as_millis() as u64)
|
||||
}
|
||||
|
||||
/// Computes the delta time since a label has been created and stops
|
||||
/// tracking the label.
|
||||
///
|
||||
/// Returns an error if the label does not exist.
|
||||
pub fn time_end(&self, label: &str) -> Result<u64, ()> {
|
||||
self.console_timers
|
||||
.borrow_mut()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue